mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-11-26 04:23:40 +08:00
release: update 3.8.0
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// import "@/utils/sso";
|
||||
import { getConfig } from "@/config";
|
||||
import { toRouteType } from "./types";
|
||||
import NProgress from "@/utils/progress";
|
||||
import { findIndex } from "lodash-unified";
|
||||
import { sessionKey, type DataInfo } from "@/utils/auth";
|
||||
@@ -21,19 +21,28 @@ import {
|
||||
formatTwoStageRoutes,
|
||||
formatFlatteningRoutes
|
||||
} from "./utils";
|
||||
import {
|
||||
buildHierarchyTree,
|
||||
openLink,
|
||||
isUrl,
|
||||
storageSession
|
||||
} from "@pureadmin/utils";
|
||||
import { buildHierarchyTree } from "@/utils/tree";
|
||||
import { isUrl, openLink, storageSession } from "@pureadmin/utils";
|
||||
|
||||
import homeRouter from "./modules/home";
|
||||
import errorRouter from "./modules/error";
|
||||
import remainingRouter from "./modules/remaining";
|
||||
|
||||
/** 自动导入全部静态路由,无需再手动引入!匹配 src/router/modules 目录(任何嵌套级别)中具有 .ts 扩展名的所有文件,除了 remaining.ts 文件
|
||||
* 如何匹配所有文件请看:https://github.com/mrmlnc/fast-glob#basic-syntax
|
||||
* 如何排除文件请看:https://cn.vitejs.dev/guide/features.html#negative-patterns
|
||||
*/
|
||||
const modules: Record<string, any> = import.meta.glob(
|
||||
["./modules/**/*.ts", "!./modules/**/remaining.ts"],
|
||||
{
|
||||
eager: true
|
||||
}
|
||||
);
|
||||
|
||||
/** 原始静态路由(未做任何处理) */
|
||||
const routes = [homeRouter, errorRouter];
|
||||
const routes = [];
|
||||
|
||||
Object.keys(modules).forEach(key => {
|
||||
routes.push(modules[key].default);
|
||||
});
|
||||
|
||||
/** 导出处理后的静态路由(三级及以上的路由全部拍成二级) */
|
||||
export const constantRoutes: Array<RouteRecordRaw> = formatTwoStageRoutes(
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import type { RouteConfigsTable } from "/#/index";
|
||||
|
||||
const errorRouter: RouteConfigsTable = {
|
||||
export default {
|
||||
path: "/error",
|
||||
redirect: "/error/403",
|
||||
meta: {
|
||||
@@ -34,6 +32,4 @@ const errorRouter: RouteConfigsTable = {
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default errorRouter;
|
||||
} as RouteConfigsTable;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { RouteConfigsTable } from "/#/index";
|
||||
const Layout = () => import("@/layout/index.vue");
|
||||
|
||||
const homeRouter: RouteConfigsTable = {
|
||||
export default {
|
||||
path: "/",
|
||||
name: "Home",
|
||||
component: Layout,
|
||||
@@ -21,6 +20,4 @@ const homeRouter: RouteConfigsTable = {
|
||||
}
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
export default homeRouter;
|
||||
} as RouteConfigsTable;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import type { RouteConfigsTable } from "/#/index";
|
||||
const Layout = () => import("@/layout/index.vue");
|
||||
|
||||
const remainingRouter: Array<RouteConfigsTable> = [
|
||||
export default [
|
||||
{
|
||||
path: "/login",
|
||||
name: "Login",
|
||||
@@ -29,6 +28,4 @@ const remainingRouter: Array<RouteConfigsTable> = [
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
export default remainingRouter;
|
||||
] as Array<RouteConfigsTable>;
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { RouteLocationNormalized } from "vue-router";
|
||||
|
||||
export interface toRouteType extends RouteLocationNormalized {
|
||||
meta: {
|
||||
roles: Array<string>;
|
||||
keepAlive?: boolean;
|
||||
dynamicLevel?: string;
|
||||
};
|
||||
}
|
||||
@@ -14,9 +14,9 @@ import { RouteConfigs } from "@/layout/types";
|
||||
import {
|
||||
isString,
|
||||
storageSession,
|
||||
buildHierarchyTree,
|
||||
isIncludeAllChildren
|
||||
} from "@pureadmin/utils";
|
||||
import { buildHierarchyTree } from "@/utils/tree";
|
||||
import { cloneDeep, intersection } from "lodash-unified";
|
||||
import { sessionKey, type DataInfo } from "@/utils/auth";
|
||||
import { usePermissionStoreHook } from "@/store/modules/permission";
|
||||
@@ -76,7 +76,7 @@ function isOneOfArray(a: Array<string>, b: Array<string>) {
|
||||
/** 从sessionStorage里取出当前登陆用户的角色roles,过滤无权限的菜单 */
|
||||
function filterNoPermissionTree(data: RouteComponent[]) {
|
||||
const currentRoles =
|
||||
storageSession.getItem<DataInfo<number>>(sessionKey).roles ?? [];
|
||||
storageSession.getItem<DataInfo<number>>(sessionKey)?.roles ?? [];
|
||||
const newTree = cloneDeep(data).filter((v: any) =>
|
||||
isOneOfArray(v.meta?.roles, currentRoles)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user