topbar.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <template>
  2. <div class="width-100 flex-row flex-justify-between flex-align-center"
  3. style="height: 60px;border-bottom: 1px solid #F0F2F5;">
  4. <div>
  5. <img :src="logoSrc" style="width: 30px;height: 30px;">
  6. </div>
  7. <div style="cursor: pointer;" class="height-100 fz16 flex-row flex-justify-between flex-align-center">
  8. <a-dropdown>
  9. <div class="height-100">
  10. <span class="fz20 mt20" style="border: 2px solid white; border-radius: 50%; display: inline-flex;">
  11. <UserOutlined />
  12. </span>
  13. <span class="ml10 mr10" style="float: right;">{{ username }}</span>
  14. </div>
  15. <template #overlay>
  16. <a-menu class="flex-column flex-justify-between flex-align-center">
  17. <a-menu-item>
  18. <span class="mr10" style="font-size: 16px;">
  19. <PoweroffOutlined />
  20. </span>
  21. <span @click="logout">退出登录</span>
  22. </a-menu-item>
  23. </a-menu>
  24. </template>
  25. </a-dropdown>
  26. </div>
  27. </div>
  28. </template>
  29. <script lang="ts" setup>
  30. import { onMounted, ref } from 'vue'
  31. import { UserOutlined, PoweroffOutlined } from '@ant-design/icons-vue'
  32. import logoSrc from '/@/assets/icons/cloudapi.png'
  33. import { getRoot } from '/@/root'
  34. import { getPlatformInfo } from '/@/api/manage'
  35. import { ELocalStorageKey, ERouterName } from '/@/types'
  36. const root = getRoot()
  37. const username = ref(localStorage.getItem(ELocalStorageKey.Username))
  38. const workspaceName = ref('')
  39. onMounted(() => {
  40. getPlatformInfo().then(res => {
  41. workspaceName.value = res.data.workspace_name
  42. })
  43. })
  44. const onClickToWorkspace = () => {
  45. root.$router.push(ERouterName.WORKSPACE)
  46. }
  47. const logout = () => {
  48. localStorage.clear()
  49. root.$router.push(ERouterName.PROJECT)
  50. }
  51. </script>
  52. <style lang="scss" scoped>
  53. @import '/@/styles/index.scss';
  54. .fontBold {
  55. font-weight: 500;
  56. font-size: 18px;
  57. }
  58. </style>