UnisKB/ui/src/layout/layout-header/UserHeader.vue

69 lines
2.0 KiB
Vue
Raw Normal View History

2025-04-28 07:23:25 +00:00
·
<template>
<div class="app-top-bar-container border-b flex-center">
2025-05-29 10:41:44 +00:00
<div class="logo mt-4">
2025-04-28 07:23:25 +00:00
<LogoFull />
</div>
2025-06-17 12:35:24 +00:00
2025-04-28 10:14:16 +00:00
<div class="flex-between w-full">
2025-06-19 06:38:27 +00:00
<div class="ml-24 flex align-center">
<!-- 企业版: 工作空间下拉框-->
2025-06-20 09:02:42 +00:00
<el-divider
class="mr-8"
direction="vertical"
v-if="hasPermission(EditionConst.IS_EE, 'OR')"
/>
2025-06-20 10:10:32 +00:00
<WorkspaceDropdown
v-if="hasPermission(EditionConst.IS_EE, 'OR')"
:data="user.workspace_list"
:currentWorkspace="currentWorkspace"
@changeWorkspace="changeWorkspace"
/>
2025-06-19 06:38:27 +00:00
</div>
2025-04-28 07:23:25 +00:00
<TopMenu></TopMenu>
2025-07-16 06:23:17 +00:00
<TopAbout class="mr-12"></TopAbout>
2025-04-28 07:23:25 +00:00
</div>
<Avatar></Avatar>
</div>
</template>
<script setup lang="ts">
2025-06-20 10:10:32 +00:00
import { computed, ref } from 'vue'
2025-07-11 08:51:56 +00:00
import { useRoute, useRouter } from 'vue-router'
2025-04-28 07:23:25 +00:00
import TopMenu from './top-menu/index.vue'
import Avatar from './avatar/index.vue'
2025-04-28 10:14:16 +00:00
import TopAbout from './top-about/index.vue'
2025-06-16 11:56:52 +00:00
import { EditionConst } from '@/utils/permission/data'
import { hasPermission } from '@/utils/permission/index'
2025-06-20 10:10:32 +00:00
import type { WorkspaceItem } from '@/api/type/workspace'
import useStore from '@/stores'
2025-07-11 08:51:56 +00:00
const router = useRouter()
const route = useRoute()
2025-06-20 10:10:32 +00:00
const { user } = useStore()
const currentWorkspace = computed(() => {
return user.workspace_list.find((w) => w.id == user.workspace_id)
})
function changeWorkspace(item: WorkspaceItem) {
2025-07-11 08:51:56 +00:00
const {
meta: { activeMenu },
} = route as any
2025-06-20 10:10:32 +00:00
if (item.id === user.workspace_id) return
user.setWorkspaceId(item.id || 'default')
2025-07-12 05:22:23 +00:00
if (activeMenu.includes('application') && route.path != '/application') {
2025-07-11 08:51:56 +00:00
router.push('/application')
2025-07-12 05:22:23 +00:00
} else if (activeMenu.includes('knowledge') && route.path != '/knowledge') {
2025-07-11 08:51:56 +00:00
router.push('/knowledge')
} else {
window.location.reload()
}
2025-06-20 10:10:32 +00:00
}
2025-04-28 07:23:25 +00:00
</script>
2025-04-28 10:14:16 +00:00
<style lang="scss" scoped>
.app-top-bar-container {
height: var(--app-header-height);
box-sizing: border-box;
padding: var(--app-header-padding);
}
</style>