Переглянути джерело

fix: handleWholeMenus 增加 rank 继承过程日志

输出 constantMenus 和 routes 各自的 rank 值,
以及每次 rank 继承的具体操作,定位继承是否生效。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 1 тиждень тому
батько
коміт
3c220e973c
1 змінених файлів з 5 додано та 0 видалено
  1. 5 0
      haha-admin-web/src/store/modules/permission.ts

+ 5 - 0
haha-admin-web/src/store/modules/permission.ts

@@ -27,6 +27,10 @@ export const usePermissionStore = defineStore("pure-permission", {
     handleWholeMenus(routes: any[]) {
       // 合并静态和动态路由,按 path 去重(动态路由 backstage 优先)
       const merged = this.constantMenus.concat(routes);
+      console.log("[handleWholeMenus] constantMenus ranks:",
+        this.constantMenus.map((m: any) => `${m.meta?.title}(${m.meta?.rank},${m.path})`));
+      console.log("[handleWholeMenus] routes ranks:",
+        routes.map((m: any) => `${m.meta?.title}(${m.meta?.rank},${m.path})`));
       const pathMap = new Map<string, any>();
       for (const r of merged as any[]) {
         if (!pathMap.has(r.path)) {
@@ -35,6 +39,7 @@ export const usePermissionStore = defineStore("pure-permission", {
           // 后端路由覆盖静态路由时,若后端无 rank 则继承静态的 rank
           const existing = pathMap.get(r.path);
           if (r.meta?.rank == null && existing?.meta?.rank != null) {
+            console.log(`[handleWholeMenus] inherit rank: ${r.path} ← ${existing.meta.rank}`);
             r.meta.rank = existing.meta.rank;
           }
           pathMap.set(r.path, r);