ソースを参照

fix: 增加侧边栏刷新诊断日志 + await nextTick

排序后刷新 sidebar 时:
1. 添加 console.log 输出一级菜单顺序,帮助诊断排序是否生效
2. initRouter() 后 await nextTick() 确保 Vue 响应式更新完成
3. 再 emit menuRefresh 强制 el-menu 重渲染

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
skyline 1 週間 前
コミット
3dbb2a2165
1 ファイル変更8 行追加1 行削除
  1. 8 1
      haha-admin-web/src/views/system/menu/utils/hook.tsx

+ 8 - 1
haha-admin-web/src/views/system/menu/utils/hook.tsx

@@ -2,9 +2,10 @@ import editForm from "../form.vue";
 import { handleTree } from "@/utils/tree";
 import { message } from "@/utils/message";
 import { getMenuList, createMenu, updateMenu, deleteMenuApi, updateMenuSort } from "@/api/system";
+import { usePermissionStoreHook } from "@/store/modules/permission";
 import { transformI18n } from "@/plugins/i18n";
 import { addDialog } from "@/components/ReDialog";
-import { reactive, ref, onMounted, h } from "vue";
+import { reactive, ref, onMounted, h, nextTick } from "vue";
 import type { FormItemProps } from "../utils/types";
 import { useRenderIcon } from "@/components/ReIcon/src/hooks";
 import { cloneDeep, isAllEmpty, deviceDetection } from "@pureadmin/utils";
@@ -308,6 +309,12 @@ export function useMenu() {
           // 刷新侧边栏路由顺序
           try {
             await initRouter();
+            await nextTick();
+            // 诊断:检查 wholeMenus 中一级菜单的排序是否与数据库一致
+            const topMenus = usePermissionStoreHook().wholeMenus
+              .filter((m: any) => m.meta?.rank > 0)
+              .map((m: any) => `${m.meta?.title}(${m.meta?.rank})`);
+            console.log("[menu-sort] 侧边栏一级菜单顺序:", topMenus.join(" → "));
             emitter.emit("menuRefresh");
           } catch (e) {
             console.error("侧边栏路由刷新失败:", e);