|
@@ -1,16 +1,16 @@
|
|
|
<template>
|
|
<template>
|
|
|
<header class="header">
|
|
<header class="header">
|
|
|
<img :src="logo" alt="logo" class="header__logo" />
|
|
<img :src="logo" alt="logo" class="header__logo" />
|
|
|
- <span class="platform-name">上飞院安全智能管控平台</span>
|
|
|
|
|
|
|
+ <span class="platform-name">{{ title }}</span>
|
|
|
<nav class="header__nav">
|
|
<nav class="header__nav">
|
|
|
<div
|
|
<div
|
|
|
class="header__nav--item"
|
|
class="header__nav--item"
|
|
|
v-for="item in NAV_LIST"
|
|
v-for="item in NAV_LIST"
|
|
|
:key="item.path"
|
|
:key="item.path"
|
|
|
- :class="{ active: activeNav === item.name }"
|
|
|
|
|
|
|
+ :class="{ active: selectedKey === item.name }"
|
|
|
@click="handleNavClick(item)"
|
|
@click="handleNavClick(item)"
|
|
|
>
|
|
>
|
|
|
- <span>{{ item.name }}</span>
|
|
|
|
|
|
|
+ <span>{{ item.meta.title }}</span>
|
|
|
</div>
|
|
</div>
|
|
|
</nav>
|
|
</nav>
|
|
|
<div class="platform__right">
|
|
<div class="platform__right">
|
|
@@ -35,15 +35,18 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
- import { ref } from 'vue';
|
|
|
|
|
- import { useRouter } from 'vue-router';
|
|
|
|
|
|
|
+ import { ref, computed, watch } from 'vue';
|
|
|
|
|
+ import { useRouter, useRoute } from 'vue-router';
|
|
|
import { NAV_LIST } from '@/constant/nav';
|
|
import { NAV_LIST } from '@/constant/nav';
|
|
|
import logo from 'assets/images/home/comac-logo@1X.png';
|
|
import logo from 'assets/images/home/comac-logo@1X.png';
|
|
|
import searchIcon from 'assets/svg/search.svg';
|
|
import searchIcon from 'assets/svg/search.svg';
|
|
|
import Login from '@/components/Login.vue';
|
|
import Login from '@/components/Login.vue';
|
|
|
import UserInfo from '@/components/UserInfo.vue';
|
|
import UserInfo from '@/components/UserInfo.vue';
|
|
|
import useMockUserStore from '@/store/modules/mockUser';
|
|
import useMockUserStore from '@/store/modules/mockUser';
|
|
|
|
|
+ import { useGlobSetting } from '@/hooks/setting';
|
|
|
|
|
+
|
|
|
import { storeToRefs } from 'pinia';
|
|
import { storeToRefs } from 'pinia';
|
|
|
|
|
+
|
|
|
const mockUserStore = useMockUserStore();
|
|
const mockUserStore = useMockUserStore();
|
|
|
const { userInfo } = storeToRefs(mockUserStore);
|
|
const { userInfo } = storeToRefs(mockUserStore);
|
|
|
const activeNav = ref(NAV_LIST[0].name);
|
|
const activeNav = ref(NAV_LIST[0].name);
|
|
@@ -61,17 +64,49 @@
|
|
|
showLogin.value = true;
|
|
showLogin.value = true;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const currentRoute = useRoute();
|
|
|
|
|
+ const { title } = useGlobSetting();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取当前打开的子菜单
|
|
|
|
|
+ const matched = currentRoute.matched;
|
|
|
|
|
+ const activeMenu = (currentRoute.meta?.activeMenu as string) || null; // act
|
|
|
|
|
+ // const selectedKey = ref<string>((activeMenu ?? currentRoute.name) as string);
|
|
|
|
|
+
|
|
|
const handleNavClick = (item: { name: string; path: string }) => {
|
|
const handleNavClick = (item: { name: string; path: string }) => {
|
|
|
// 如果不是首页,先检查用户是否登录
|
|
// 如果不是首页,先检查用户是否登录
|
|
|
- if (item.name !== '首页' && !userInfo.value) {
|
|
|
|
|
- handleLogin('login');
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // if (item.name !== '首页' && !userInfo.value) {
|
|
|
|
|
+ // handleLogin('login');
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
if (!item.path) return;
|
|
if (!item.path) return;
|
|
|
|
|
|
|
|
activeNav.value = item.name;
|
|
activeNav.value = item.name;
|
|
|
router.push(item.path);
|
|
router.push(item.path);
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+ const matchedSubmenus = computed(() => {
|
|
|
|
|
+ return currentRoute.matched[0].children;
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ console.log('currentRoute', currentRoute);
|
|
|
|
|
+
|
|
|
|
|
+ const selectedKey = computed(() => {
|
|
|
|
|
+ const activeMenu = (currentRoute.meta?.activeMenu as string) || null; // act
|
|
|
|
|
+ return activeMenu ? activeMenu : (currentRoute.name as string);
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log('selectedKeys', selectedKey.value);
|
|
|
|
|
+
|
|
|
|
|
+ // 跟随页面路由变化,切换菜单选中状态
|
|
|
|
|
+ // watch(
|
|
|
|
|
+ // () => currentRoute.fullPath,
|
|
|
|
|
+ // () => {
|
|
|
|
|
+ // updateMenu();
|
|
|
|
|
+ // const matched = currentRoute.matched;
|
|
|
|
|
+ // openKeys.value = matched.map((item) => item.name);
|
|
|
|
|
+ // const activeMenu: string = (currentRoute.meta?.activeMenu as string) || '';
|
|
|
|
|
+ // selectedKeys.value = activeMenu ? activeMenu : (currentRoute.name as string);
|
|
|
|
|
+ // },
|
|
|
|
|
+ // );
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|