From d71422ecb4e6a0c855e94e0416e4fc52387dec18 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期五, 08 八月 2025 14:52:46 +0800 Subject: [PATCH] '关注项目' --- src/layout/hooks/useNav.ts | 42 +++++++++++++++++++++++++++++++++++++++--- 1 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/layout/hooks/useNav.ts b/src/layout/hooks/useNav.ts index 2448efb..17745d4 100644 --- a/src/layout/hooks/useNav.ts +++ b/src/layout/hooks/useNav.ts @@ -2,7 +2,7 @@ import { getConfig } from "@/config"; import { emitter } from "@/utils/mitt"; import Avatar from "@/assets/user.jpg"; -import { getTopMenu } from "@/router/utils"; +import { initRouter, getTopMenu, handleAliveRoute } from "@/router/utils"; import { useFullscreen } from "@vueuse/core"; import type { routeMetaType } from "../types"; import { useRouter, useRoute } from "vue-router"; @@ -14,6 +14,7 @@ import { usePermissionStoreHook } from "@/store/modules/permission"; import ExitFullscreen from "~icons/ri/fullscreen-exit-fill"; import Fullscreen from "~icons/ri/fullscreen-fill"; +import { unref } from "vue"; const errorInfo = "The current routing configuration is incorrect, please check the configuration"; @@ -51,6 +52,16 @@ : useUserStoreHook()?.nickname; }); + /** 褰撳墠瑙掕壊 */ + const userRoles = computed(() => { + return useUserStoreHook()?.nowRole; + }); + + /** 瑙掕壊 */ + const userRolesList = computed(() => { + return useUserStoreHook()?.exRoles ?? []; + }); + const avatarsStyle = computed(() => { return username.value ? { marginRight: "10px" } : ""; }); @@ -78,7 +89,29 @@ if (Title) document.title = `${meta.title} | ${Title}`; else document.title = meta.title; } - + /** 鍒锋柊璺敱 */ + function onFresh() { + const { fullPath, query } = unref(route); + router.replace({ + path: "/redirect" + fullPath, + query + }); + handleAliveRoute(route as ToRouteType, "refresh"); + } + /** 鍒囨崲瑙掕壊 */ + const changRole = item => { + useUserStoreHook() + .changeLogoInExRule({ + ruleCode: item.code + }) + .then(res => { + if (res.code == 200) { + // 鑾峰彇鍚庣璺敱 + initRouter(); + onFresh(); + } + }); + }; /** 閫�鍑虹櫥褰� */ function logout() { useUserStoreHook().logOut(); @@ -150,8 +183,11 @@ isCollapse, pureApp, username, + userRoles, + userRolesList, userAvatar, avatarsStyle, - tooltipEffect + tooltipEffect, + changRole }; } -- Gitblit v1.9.1