From 03c275439949875a857538df89a41696642c42b3 Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期一, 01 九月 2025 17:15:39 +0800 Subject: [PATCH] '首页公告与详情' --- src/router/utils.ts | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/router/utils.ts b/src/router/utils.ts index 9137806..f074f76 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -26,7 +26,10 @@ const IFrame = () => import("@/layout/frame.vue"); // https://cn.vitejs.dev/guide/features.html#glob-import const modulesRoutes = import.meta.glob("/src/views/**/*.{vue,tsx}"); +const quanxianList = ["/item"]; +const managerList = ["/user"]; +// const userInfo = storageLocal().getItem<DataInfo<number>>(userKey); // 鍔ㄦ�佽矾鐢� import { getAsyncRoutes } from "@/api/routes"; @@ -55,9 +58,17 @@ /** 杩囨护meta涓璼howLink涓篺alse鐨勮彍鍗� */ function filterTree(data: RouteComponent[]) { + const hasFlsh = useUserStoreHook().nowRole.hasFlsh; + const isManager = useUserStoreHook().isManager; const newTree = cloneDeep(data).filter( - (v: { meta: { showLink: boolean } }) => v.meta?.showLink !== false + (v: { path: string; meta: { showLink: boolean } }) => { + quanxianList.includes(v.path) ? (v.meta.showLink = hasFlsh) : null; + managerList.includes(v.path) ? (v.meta.showLink = isManager) : null; + return v.meta?.showLink !== false; + } ); + console.log(newTree); + newTree.forEach( (v: { children }) => v.children && (v.children = filterTree(v.children)) ); @@ -85,7 +96,7 @@ /** 浠巐ocalStorage閲屽彇鍑哄綋鍓嶇櫥褰曠敤鎴风殑瑙掕壊roles锛岃繃婊ゆ棤鏉冮檺鐨勮彍鍗� */ function filterNoPermissionTree(data: RouteComponent[]) { const currentRoles = - storageLocal().getItem<DataInfo<number>>(userKey)?.exRoles ?? []; + storageLocal().getItem<DataInfo<number>>(userKey)?.roles ?? []; const newTree = cloneDeep(data).filter((v: any) => isOneOfArray(v.meta?.roles, currentRoles) ); -- Gitblit v1.9.1