feat(projects): 新增静态路由

This commit is contained in:
Soybean
2022-03-30 01:19:37 +08:00
parent bbfdcc8276
commit ca2dfa6185
34 changed files with 1591 additions and 1875 deletions

View File

@ -1,13 +1,13 @@
/** 用户相关模块 */
declare namespace Auth {
/**
* 用户角色类型
* - super: 超级管理员
* 用户角色类型(前端静态路由用角色类型进行路由权限的控制)
* - super: 超级管理员(该权限具有所有路由数据)
* - admin: 管理员
* - test: 测试
* - visitor: 游客
* - normal: 普通用户
*/
type RoleType = 'super' | 'admin' | 'test' | 'visitor';
type RoleType = 'super' | 'admin' | 'test' | 'normal';
/** 用户信息 */
interface UserInfo {

12
src/typings/env.d.ts vendored
View File

@ -7,7 +7,12 @@ declare module '*.vue' {
export default component;
}
/** env环境类型 */
/**
* env环境类型
* - dev: 后台开发环境
* - test: 后台测试环境
* - prod: 后台生产环境
*/
type EnvType = 'dev' | 'test' | 'prod';
interface ImportMetaEnv {
@ -21,6 +26,11 @@ interface ImportMetaEnv {
readonly VITE_APP_DESC: string;
/** 开发启动的服务端口号 */
readonly VITE_SERVER_PORT: string;
/**
* 权限路由模式:
* - static - 前端声明的静态
* - dynamic - 后端返回的动态 */
readonly VITE_AUTH_ROUTE_MODE: 'static' | 'dynamic';
/** vite环境类型 */
readonly VITE_ENV_TYPE?: EnvType;
/** 开启请求代理 */

View File

@ -73,7 +73,10 @@ declare namespace AuthRoute {
singleLayout?: Extract<RouteComponent, 'basic' | 'blank'>;
/** 需要登录权限 */
requiresAuth?: boolean;
/** 哪些类型的用户有权限才能访问的路由(空的话则表示不需要权限) */
/**
* 哪些类型的用户有权限才能访问的路由(空的话则表示不需要权限)
* @description 后端动态路由数据不需要该属性,直接由后端根据用户角色返回对应权限的路由数据
*/
permissions?: Auth.RoleType[];
/** 缓存页面 */
keepAlive?: boolean;
@ -89,7 +92,7 @@ declare namespace AuthRoute {
multi?: boolean;
};
/** 单个路由的类型结构(后端返回此类型结构的路由) */
/** 单个路由的类型结构(动态路由模式:后端返回此类型结构的路由) */
interface Route {
/** 路由名称(路由唯一标识) */
name: RouteKey;
@ -113,6 +116,9 @@ declare namespace AuthRoute {
props?: boolean | Record<string, any> | ((to: any) => Record<string, any>);
}
/** 前端导入的路由模块 */
type RouteModule = Record<string, { default: AuthRoute.Route }>;
/** 单独一级路由的key (单独路由需要添加一个父级路由用于应用布局组件) */
type SingleRouteKey = Exclude<
GetSingleRouteKey<RouteKey>,