header.vue 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div class="sw-header">
  3. <a-space>
  4. <div style="width:216px">
  5. <img height="30" src="@/assets/LOGO.svg" alt="">
  6. </div>
  7. <weather/>
  8. </a-space>
  9. <div>
  10. <a-space>
  11. <QuestionCircleOutlined :style="{marginRight:'16px',color:'#fff',fontSize:'16px',cursor: 'pointer'}"/>
  12. <BellOutlined :style="{marginRight:'24px',color:'#fff',fontSize:'16px',cursor: 'pointer'}"/>
  13. <a-dropdown class="dropdown-link">
  14. <a class="ant-dropdown-link" @click.prevent>
  15. <a-avatar size="small">
  16. <template #icon><UserOutlined /></template>
  17. </a-avatar>
  18. {{nowAccount.sitename}}
  19. <DownOutlined />
  20. </a>
  21. <template #overlay>
  22. <a-menu>
  23. <a-menu-item v-for="item in accountList" :key="item.index">
  24. <a @click="accountItemClick(item,false)">{{item.sitename + '-' + item.name}}</a>
  25. </a-menu-item>
  26. <a-menu-divider />
  27. <a-menu-item>
  28. <LogoutOutlined />
  29. <a class="color-red" @click="loginOut">&nbsp;退出登录</a>
  30. </a-menu-item>
  31. </a-menu>
  32. </template>
  33. </a-dropdown>
  34. </a-space>
  35. </div>
  36. </div>
  37. </template>
  38. <script setup>
  39. import {ref,createVNode} from 'vue'
  40. import { UserOutlined, DownOutlined,BellOutlined,QuestionCircleOutlined, LogoutOutlined,ExclamationCircleOutlined} from '@ant-design/icons-vue';
  41. import { useAuthStore } from '@/stores/modules/auth'
  42. import { useRouteTabsStore } from '@/stores/modules/Htabs'
  43. import { storeToRefs } from 'pinia'
  44. import { Modal } from 'ant-design-vue';
  45. import weather from '@/components/weather/index.vue'
  46. import { useRouter } from "vue-router";
  47. const router = useRouter()
  48. import Api from '@/api/api'
  49. const store = useAuthStore()
  50. let { accountList,nowAccount } = storeToRefs(store)
  51. const rotTabs = useRouteTabsStore()
  52. let {historyRoutes} = storeToRefs(rotTabs)
  53. const accountItemClick = (account,bool)=>{
  54. store.defaultAccount(account,()=>{
  55. store.reloadPage()
  56. historyRoutes.value = []
  57. })
  58. }
  59. const loginOut = ()=>{
  60. Modal.confirm({
  61. title: '注意',
  62. icon: createVNode(ExclamationCircleOutlined),
  63. content: '确定登出当前账号吗?',
  64. okText: '确认',
  65. cancelText: '取消',
  66. onOk () {
  67. historyRoutes.value = []
  68. Api.loginout({})
  69. router.push({path:'/'})
  70. }
  71. });
  72. }
  73. </script>
  74. <style scoped>
  75. .sw-header{
  76. display: flex;
  77. align-items: center;
  78. justify-content: space-between;
  79. height: 56px;
  80. padding:0 32px 0 16px;
  81. }
  82. .ant-dropdown-link{
  83. color:#fff;
  84. }
  85. </style>