|
@@ -2,6 +2,7 @@ import editForm from "../form.vue";
|
|
|
import { handleTree } from "@/utils/tree";
|
|
import { handleTree } from "@/utils/tree";
|
|
|
import { message } from "@/utils/message";
|
|
import { message } from "@/utils/message";
|
|
|
import { getMenuList, createMenu, updateMenu, deleteMenuApi, updateMenuSort } from "@/api/system";
|
|
import { getMenuList, createMenu, updateMenu, deleteMenuApi, updateMenuSort } from "@/api/system";
|
|
|
|
|
+import { getAsyncRoutes } from "@/api/routes";
|
|
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
|
|
import { transformI18n } from "@/plugins/i18n";
|
|
import { transformI18n } from "@/plugins/i18n";
|
|
|
import { addDialog } from "@/components/ReDialog";
|
|
import { addDialog } from "@/components/ReDialog";
|
|
@@ -308,16 +309,18 @@ export function useMenu() {
|
|
|
message("排序更新成功", { type: "success" });
|
|
message("排序更新成功", { type: "success" });
|
|
|
// 刷新侧边栏路由顺序
|
|
// 刷新侧边栏路由顺序
|
|
|
try {
|
|
try {
|
|
|
|
|
+ // 先直接查 API 返回的原始数据
|
|
|
|
|
+ const routesRes = await getAsyncRoutes();
|
|
|
|
|
+ const apiRanks = (routesRes as any).data?.map((m: any) => `${m.meta?.title}(${m.meta?.rank},${m.path})`);
|
|
|
|
|
+ console.log("[menu-sort] API 原始一级菜单:", apiRanks);
|
|
|
|
|
+
|
|
|
await initRouter();
|
|
await initRouter();
|
|
|
await nextTick();
|
|
await nextTick();
|
|
|
- // 诊断:输出所有一级菜单的路径、标题和 rank
|
|
|
|
|
|
|
+ // 诊断:输出 store 中的一级菜单
|
|
|
const topMenus = usePermissionStoreHook().wholeMenus
|
|
const topMenus = usePermissionStoreHook().wholeMenus
|
|
|
.map((m: any) => `${m.meta?.title || "?"}(${m.meta?.rank},${m.path})`);
|
|
.map((m: any) => `${m.meta?.title || "?"}(${m.meta?.rank},${m.path})`);
|
|
|
- console.log("[menu-sort] wholeMenus 一级菜单:", topMenus);
|
|
|
|
|
- // 检查重复路径
|
|
|
|
|
- const paths = usePermissionStoreHook().wholeMenus.map((m: any) => m.path);
|
|
|
|
|
- const dupes = paths.filter((p, i) => paths.indexOf(p) !== i);
|
|
|
|
|
- if (dupes.length > 0) console.warn("[menu-sort] 重复路径:", dupes);
|
|
|
|
|
|
|
+ console.log("[menu-sort] store中一级菜单:", topMenus);
|
|
|
|
|
+
|
|
|
emitter.emit("menuRefresh");
|
|
emitter.emit("menuRefresh");
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error("侧边栏路由刷新失败:", e);
|
|
console.error("侧边栏路由刷新失败:", e);
|