mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): 新增静态路由
This commit is contained in:
@ -37,7 +37,7 @@ export function getUserInfo() {
|
||||
userId: '',
|
||||
userName: '',
|
||||
userPhone: '',
|
||||
userRole: 'visitor',
|
||||
userRole: 'test',
|
||||
};
|
||||
const userInfo: Auth.UserInfo = getLocal<Auth.UserInfo>(EnumStorageKey['user-info']) || emptyInfo;
|
||||
return userInfo;
|
||||
|
@ -27,7 +27,7 @@ export function transformToTimeCountDown(seconds: number) {
|
||||
* @param start - 开始范围
|
||||
* @param end - 结束范围
|
||||
*/
|
||||
export function getRandomInterger(end: number, start = 0) {
|
||||
export function getRandomInteger(end: number, start = 0) {
|
||||
const range = end - start;
|
||||
const random = Math.floor(Math.random() * range + start);
|
||||
return random;
|
||||
|
@ -5,7 +5,6 @@ const CryptoSecret = '__CryptoJS_Secret__';
|
||||
/**
|
||||
* 加密数据
|
||||
* @param data - 数据
|
||||
* @param secret - 密钥
|
||||
*/
|
||||
export function encrypto(data: any) {
|
||||
const newData = JSON.stringify(data);
|
||||
@ -14,11 +13,10 @@ export function encrypto(data: any) {
|
||||
|
||||
/**
|
||||
* 解密数据
|
||||
* @param ciphertext - 密文
|
||||
* @param secret - 密钥
|
||||
* @param cipherText - 密文
|
||||
*/
|
||||
export function decrypto(ciphertext: string) {
|
||||
const bytes = CryptoJS.AES.decrypt(ciphertext, CryptoSecret);
|
||||
export function decrypto(cipherText: string) {
|
||||
const bytes = CryptoJS.AES.decrypt(cipherText, CryptoSecret);
|
||||
const originalText = bytes.toString(CryptoJS.enc.Utf8);
|
||||
if (originalText) {
|
||||
return JSON.parse(originalText);
|
||||
|
23
src/utils/router/auth.ts
Normal file
23
src/utils/router/auth.ts
Normal file
@ -0,0 +1,23 @@
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
/**
|
||||
* 根据用户权限过滤路由
|
||||
* @param routes - 权限路由
|
||||
* @param permission - 权限
|
||||
*/
|
||||
export function filterAuthRoutesByUserPermission(routes: AuthRoute.Route[], permission: Auth.RoleType) {
|
||||
const filters: AuthRoute.Route[] = [];
|
||||
|
||||
routes.forEach((route) => {
|
||||
filterAuthRouteByUserPermission(route, permission);
|
||||
});
|
||||
return filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户权限过滤单个路由
|
||||
* @param route - 单个权限路由
|
||||
* @param permission - 权限
|
||||
*/
|
||||
function filterAuthRouteByUserPermission(route: AuthRoute.Route, permission: Auth.RoleType): AuthRoute.Route[] {
|
||||
return [];
|
||||
}
|
@ -33,7 +33,7 @@ export function transformAuthRoutesToSearchMenus(routes: AuthRoute.Route[], tree
|
||||
|
||||
/**
|
||||
* 将单个权限路由转换成vue路由
|
||||
* @param route - 权限路由
|
||||
* @param item - 单个权限路由
|
||||
*/
|
||||
function transformAuthRouteToVueRoute(item: AuthRoute.Route) {
|
||||
const resultRoute: RouteRecordRaw[] = [];
|
||||
|
@ -1,3 +1,4 @@
|
||||
export * from './module';
|
||||
export * from './helpers';
|
||||
export * from './cache';
|
||||
export * from './menu';
|
||||
|
28
src/utils/router/module.ts
Normal file
28
src/utils/router/module.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import { consoleError } from '../common';
|
||||
|
||||
/**
|
||||
* 权限路由排序
|
||||
* @param routes - 权限路由
|
||||
*/
|
||||
function sortRoutes(routes: AuthRoute.Route[]) {
|
||||
return routes.sort((next, pre) => Number(next.meta?.order) - Number(pre.meta?.order));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理全部导入的路由模块
|
||||
* @param modules - 路由模块
|
||||
*/
|
||||
export function handleModuleRoutes(modules: AuthRoute.RouteModule) {
|
||||
const routes: AuthRoute.Route[] = [];
|
||||
|
||||
Object.keys(modules).forEach((key) => {
|
||||
const item = modules[key].default;
|
||||
if (item) {
|
||||
routes.push(item);
|
||||
} else {
|
||||
consoleError(`路由模块解析出错: key = ${key}`);
|
||||
}
|
||||
});
|
||||
|
||||
return sortRoutes(routes);
|
||||
}
|
Reference in New Issue
Block a user