feat: layout调整
This commit is contained in:
@ -4,9 +4,32 @@ import { IconExport, IconFile, IconCaretDown } from '@arco-design/web-vue/es/ico
|
||||
import { fetchMenusTree } from '@/api/all';
|
||||
import { handleUserLogout } from '@/utils/user';
|
||||
import { fetchLogOut } from '@/api/all/login';
|
||||
import { useSidebarStore } from '@/stores/modules/side-bar';
|
||||
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||
import router from '@/router';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
interface MenuItem {
|
||||
name: string;
|
||||
id: number;
|
||||
children: Array<{
|
||||
name: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
const lists = ref<MenuItem[]>([]);
|
||||
const sidebarStore = useSidebarStore();
|
||||
const route = useRoute();
|
||||
|
||||
const selectedKey = computed(() => {
|
||||
// 判断是否为工作台页面(假设路由名为 'Home' 或 path 为 '/')
|
||||
if (route.name === 'Home' || route.path === '/') {
|
||||
return [`${MENU_GROUP_IDS.WORK_BENCH_ID}`];
|
||||
}
|
||||
// 其他页面,activeMenuId 作为 key
|
||||
return [String(sidebarStore.activeMenuId)];
|
||||
});
|
||||
|
||||
const lists = ref([]);
|
||||
const router = useRouter();
|
||||
const clickExit = async () => {
|
||||
const { code } = await fetchLogOut();
|
||||
if (code === 200) {
|
||||
@ -29,26 +52,26 @@ const setServerMenu = () => {
|
||||
};
|
||||
const handleSelect = (index: any) => {
|
||||
if (index === 0) {
|
||||
router.push('/workplace');
|
||||
router.push('/');
|
||||
} else {
|
||||
router.push('/dataEngine/hotTranslation');
|
||||
}
|
||||
};
|
||||
|
||||
const handleDopdownClick = (index: any, ind: any) => {
|
||||
let children = lists.value[index].children;
|
||||
let indPath = children[ind];
|
||||
if (indPath.name == '行业热门话题洞察') {
|
||||
const { children } = lists.value[index];
|
||||
const indPath = children[ind] as any;
|
||||
if (indPath.name === '行业热门话题洞察') {
|
||||
router.push('/dataEngine/hotTranslation');
|
||||
} else if (indPath.name == '行业词云') {
|
||||
} else if (indPath.name === '行业词云') {
|
||||
router.push('/dataEngine/hotCloud');
|
||||
} else if (indPath.name == '行业关键词动向') {
|
||||
} else if (indPath.name === '行业关键词动向') {
|
||||
router.push('/dataEngine/keyWord');
|
||||
} else if (indPath.name == '用户痛点观察') {
|
||||
} else if (indPath.name === '用户痛点观察') {
|
||||
router.push('/dataEngine/userPainPoints');
|
||||
} else if (indPath.name == '重点品牌动向') {
|
||||
} else if (indPath.name === '重点品牌动向') {
|
||||
router.push('/dataEngine/keyBrandMovement');
|
||||
} else if (indPath.name == '用户画像') {
|
||||
} else if (indPath.name === '用户画像') {
|
||||
router.push('/dataEngine/userPersona');
|
||||
}
|
||||
};
|
||||
@ -63,11 +86,15 @@ const handleDopdownClick = (index: any, ind: any) => {
|
||||
</div>
|
||||
<div class="center-side">
|
||||
<div class="menu-demo">
|
||||
<a-menu mode="horizontal" :default-selected-keys="['1']">
|
||||
<a-menu-item key="1" @click="handleSelect(0)">
|
||||
<a-menu
|
||||
mode="horizontal"
|
||||
:selected-keys="selectedKey"
|
||||
:default-selected-keys="[`${MENU_GROUP_IDS.WORK_BENCH_ID}`]"
|
||||
>
|
||||
<a-menu-item :key="`${MENU_GROUP_IDS.WORK_BENCH_ID}`" @click="handleSelect(0)">
|
||||
<view>工作台</view>
|
||||
</a-menu-item>
|
||||
<a-menu-item v-for="(item, index) in lists" :key="index + 2">
|
||||
<a-menu-item v-for="(item, index) in lists" :key="String(item.id)">
|
||||
<a-dropdown :popup-max-height="false">
|
||||
<a-button>{{ item.name }}<icon-caret-down /></a-button>
|
||||
<template #content>
|
||||
|
||||
Reference in New Issue
Block a user