Files
lingji-work-fe/src/components/_base/navbar/index.vue

163 lines
4.5 KiB
Vue
Raw Normal View History

2025-06-16 14:42:26 +08:00
<script lang="ts" setup>
import { useAppStore } from '@/stores';
import { IconExport, IconFile, IconCaretDown } from '@arco-design/web-vue/es/icon';
import { fetchMenusTree } from '@/api/all';
const lists = ref([]);
2025-06-17 11:18:39 +08:00
const router = useRouter();
const clickExit = () => {
router.replace('/login');
};
2025-06-16 14:42:26 +08:00
const getMenus = async () => {
const res = await fetchMenusTree();
lists.value = res;
};
onMounted(() => {
getMenus();
});
const appStore = useAppStore();
function setServerMenu() {
appStore.fetchServerMenuConfig();
console.log(appStore.serverMenu);
}
const handleSelect = (index: any) => {
console.log(index);
2025-06-17 11:18:39 +08:00
if (index == 0) {
router.push('/workplace');
} else {
router.push('/dataEngine/dataEngine/hotTranslation');
}
};
const handleDopdownClick = (index: any, ind: any) => {
let children = lists.value[index].children;
let indPath = children[ind];
if (indPath.name == '行业热门话题洞察') {
router.push('/dataEngine/dataEngine/hotTranslation');
} else if (indPath.name == '行业词云') {
router.push('/dataEngine/dataEngine/hotCloud');
} else if (indPath.name == '行业关键词动向') {
router.push('/dataEngine/dataEngine/keyWord');
} else if (indPath.name == '用户痛点观察') {
router.push('/dataEngine/dataEngine/userPainPoints');
} else if (indPath.name == '重点品牌动向') {
router.push('/dataEngine/dataEngine/keyBrandMovement');
} else if (indPath.name == '用户画像') {
router.push('/dataEngine/dataEngine/userPersona');
}
2025-06-16 14:42:26 +08:00
};
</script>
<template>
<div class="navbar">
<div class="left-side">
<a-space>
2025-06-17 11:18:39 +08:00
<img src="@/assets/logo.svg" alt="" />
2025-06-16 14:42:26 +08:00
</a-space>
</div>
<div class="center-side">
<div class="menu-demo">
<a-menu mode="horizontal" :default-selected-keys="['1']">
2025-06-17 11:18:39 +08:00
<a-menu-item :key="'1'" @click="handleSelect(0)">
2025-06-16 14:42:26 +08:00
<view>工作台</view>
</a-menu-item>
<a-menu-item v-for="(item, index) in lists" :key="index + 2">
2025-06-17 11:18:39 +08:00
<a-dropdown :popup-max-height="false">
2025-06-16 14:42:26 +08:00
<a-button>{{ item.name }}<icon-caret-down /></a-button>
<template #content>
2025-06-17 11:18:39 +08:00
<a-doption v-for="(child, ind) in item.children" :key="ind" @click="handleDopdownClick(index, ind)">{{
child.name
}}</a-doption>
2025-06-16 14:42:26 +08:00
</template>
</a-dropdown>
</a-menu-item>
</a-menu>
</div>
</div>
<ul class="right-side">
<li>
<a-dropdown trigger="click">
<a-avatar class="cursor-pointer" :size="32">
2025-06-17 11:18:39 +08:00
<img alt="avatar" src="@/assets/avatar.svg" />
2025-06-16 14:42:26 +08:00
</a-avatar>
2025-06-17 11:18:39 +08:00
<template #content>
<div style="padding: 14px">
<a-doption>
<a-space @click="setServerMenu">
<img src="@/assets/option.svg" style="width: 16px; height: 16px" />
<span style="width: 140px; font-size: 12px">管理中心</span>
<icon-right />
</a-space>
</a-doption>
<a-doption>
<a-space>
<img src="@/assets/change.svg" style="width: 16px; height: 16px" />
<span style="width: 140px; font-size: 12px">切换企业账号</span>
<icon-right />
</a-space>
</a-doption>
<a-doption>
<a-space @click="clickExit">
<img src="@/assets/exit.svg" style="width: 16px; height: 16px" />
<span style="width: 140px; font-size: 12px">退出登录</span>
<icon-right />
</a-space>
</a-doption>
</div>
</template>
2025-06-16 14:42:26 +08:00
</a-dropdown>
</li>
</ul>
</div>
</template>
<style scoped lang="less">
.navbar {
display: flex;
justify-content: space-between;
height: 100%;
background-color: var(--color-bg-2);
border-bottom: 1px solid var(--color-border);
}
.left-side {
display: flex;
align-items: center;
padding-left: 20px;
}
.center-side {
flex: 1;
display: flex;
align-items: center;
margin-left: 40px;
}
.cneter-tip {
font-size: 16px;
font-weight: 400;
color: var(--color-text-1);
}
.menu-demo {
flex: 1;
}
.right-side {
display: flex;
padding-right: 20px;
list-style: none;
li {
display: flex;
align-items: center;
padding: 0 10px;
}
a {
color: var(--color-text-1);
text-decoration: none;
}
.nav-btn {
border-color: rgb(var(--gray-2));
color: rgb(var(--gray-8));
font-size: 16px;
}
}
</style>