mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): remove enum
This commit is contained in:
3
src/typings/business.d.ts
vendored
3
src/typings/business.d.ts
vendored
@ -5,9 +5,8 @@ declare namespace Auth {
|
||||
* - super: 超级管理员(该权限具有所有路由数据)
|
||||
* - admin: 管理员
|
||||
* - user: 用户
|
||||
* - custom: 自定义角色
|
||||
*/
|
||||
type RoleType = keyof typeof import('@/enum').EnumUserRole;
|
||||
type RoleType = 'super' | 'admin' | 'user';
|
||||
|
||||
/** 用户信息 */
|
||||
interface UserInfo {
|
||||
|
3
src/typings/global.d.ts
vendored
3
src/typings/global.d.ts
vendored
@ -12,6 +12,9 @@ declare namespace Common {
|
||||
* [状态, 为true时执行的回调函数]
|
||||
*/
|
||||
type StrategyAction = [boolean, () => void];
|
||||
|
||||
/** 选项数据 */
|
||||
type OptionWithKey<K> = { value: K; label: string };
|
||||
}
|
||||
|
||||
/** 构建时间 */
|
||||
|
57
src/typings/system.d.ts
vendored
57
src/typings/system.d.ts
vendored
@ -1,24 +1,3 @@
|
||||
/** 枚举的key类型 */
|
||||
declare namespace EnumType {
|
||||
/** 布局组件名称 */
|
||||
type LayoutComponentName = keyof typeof import('@/enum').EnumLayoutComponentName;
|
||||
|
||||
/** 布局模式 */
|
||||
type ThemeLayoutMode = keyof typeof import('@/enum').EnumThemeLayoutMode;
|
||||
|
||||
/** 多页签风格 */
|
||||
type ThemeTabMode = keyof typeof import('@/enum').EnumThemeTabMode;
|
||||
|
||||
/** 水平模式的菜单位置 */
|
||||
type ThemeHorizontalMenuPosition = keyof typeof import('@/enum').EnumThemeHorizontalMenuPosition;
|
||||
|
||||
/** 过渡动画 */
|
||||
type ThemeAnimateMode = keyof typeof import('@/enum').EnumThemeAnimateMode;
|
||||
|
||||
/** 登录模块 */
|
||||
type LoginModuleKey = keyof typeof import('@/enum').EnumLoginModule;
|
||||
}
|
||||
|
||||
/** 请求的相关类型 */
|
||||
declare namespace Service {
|
||||
/**
|
||||
@ -143,13 +122,9 @@ declare namespace Theme {
|
||||
/** 最小宽度 */
|
||||
minWidth: number;
|
||||
/** 布局模式 */
|
||||
mode: EnumType.ThemeLayoutMode;
|
||||
mode: UnionKey.ThemeLayoutMode;
|
||||
/** 布局模式列表 */
|
||||
modeList: LayoutModeList[];
|
||||
}
|
||||
interface LayoutModeList {
|
||||
value: EnumType.ThemeLayoutMode;
|
||||
label: import('@/enum').EnumThemeLayoutMode;
|
||||
modeList: Common.OptionWithKey<UnionKey.ThemeLayoutMode>[];
|
||||
}
|
||||
|
||||
/** 其他主题颜色 */
|
||||
@ -188,19 +163,13 @@ declare namespace Theme {
|
||||
/** 多页签高度 */
|
||||
height: number;
|
||||
/** 多页签风格 */
|
||||
mode: EnumType.ThemeTabMode;
|
||||
mode: UnionKey.ThemeTabMode;
|
||||
/** 多页签风格列表 */
|
||||
modeList: ThemeTabModeList[];
|
||||
modeList: Common.OptionWithKey<UnionKey.ThemeTabMode>[];
|
||||
/** 开启多页签缓存 */
|
||||
isCache: boolean;
|
||||
}
|
||||
|
||||
/** 多页签风格列表 */
|
||||
interface ThemeTabModeList {
|
||||
value: EnumType.ThemeTabMode;
|
||||
label: import('@/enum').EnumThemeTabMode;
|
||||
}
|
||||
|
||||
/** 侧边栏样式 */
|
||||
interface Sider {
|
||||
/** 侧边栏反转色 */
|
||||
@ -220,14 +189,9 @@ declare namespace Theme {
|
||||
/** 菜单样式 */
|
||||
interface Menu {
|
||||
/** 水平模式的菜单的位置 */
|
||||
horizontalPosition: EnumType.ThemeHorizontalMenuPosition;
|
||||
horizontalPosition: UnionKey.ThemeHorizontalMenuPosition;
|
||||
/** 水平模式的菜单的位置列表 */
|
||||
horizontalPositionList: HorizontalMenuPositionList[];
|
||||
}
|
||||
/** 水平模式的菜单的位置列表 */
|
||||
interface HorizontalMenuPositionList {
|
||||
value: EnumType.ThemeHorizontalMenuPosition;
|
||||
label: import('@/enum').EnumThemeHorizontalMenuPosition;
|
||||
horizontalPositionList: Common.OptionWithKey<UnionKey.ThemeHorizontalMenuPosition>[];
|
||||
}
|
||||
|
||||
/** 底部样式 */
|
||||
@ -245,14 +209,9 @@ declare namespace Theme {
|
||||
/** 页面是否开启动画 */
|
||||
animate: boolean;
|
||||
/** 动画类型 */
|
||||
animateMode: EnumType.ThemeAnimateMode;
|
||||
animateMode: UnionKey.ThemeAnimateMode;
|
||||
/** 动画类型列表 */
|
||||
animateModeList: AnimateModeList[];
|
||||
}
|
||||
/** 动画类型列表 */
|
||||
interface AnimateModeList {
|
||||
value: EnumType.ThemeAnimateMode;
|
||||
label: import('@/enum').EnumThemeAnimateMode;
|
||||
animateModeList: Common.OptionWithKey<UnionKey.ThemeAnimateMode>[];
|
||||
}
|
||||
}
|
||||
|
||||
|
56
src/typings/union-key.d.ts
vendored
Normal file
56
src/typings/union-key.d.ts
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
declare namespace UnionKey {
|
||||
/** http请求头的content-type类型 */
|
||||
type ContentType = 'application/json' | 'application/x-www-form-urlencoded' | 'multipart/form-data';
|
||||
|
||||
/**
|
||||
* 登录模块
|
||||
* - pwd-login: 账密登录
|
||||
* - code-login: 手机验证码登录
|
||||
* - register: 注册
|
||||
* - reset-pwd: 重置密码
|
||||
* - bind-wechat: 微信绑定
|
||||
*/
|
||||
type LoginModule = 'pwd-login' | 'code-login' | 'register' | 'reset-pwd' | 'bind-wechat';
|
||||
|
||||
/**
|
||||
* 布局模式
|
||||
* - vertical: 左侧菜单模式
|
||||
* - horizontal: 顶部菜单模式
|
||||
* - vertical-mix: 左侧菜单混合模式
|
||||
* - horizontal-mix: 顶部菜单混合模式
|
||||
*/
|
||||
type ThemeLayoutMode = 'vertical' | 'horizontal' | 'vertical-mix' | 'horizontal-mix';
|
||||
|
||||
/**
|
||||
* 多页签风格
|
||||
* - chrome: 谷歌风格
|
||||
* - button: 按钮风格
|
||||
*/
|
||||
type ThemeTabMode = 'chrome' | 'button';
|
||||
|
||||
/**
|
||||
* 水平模式的菜单位置
|
||||
* - flex-start: 居左
|
||||
* - center: 居中
|
||||
* - flex-end: 居右
|
||||
*/
|
||||
type ThemeHorizontalMenuPosition = 'flex-start' | 'center' | 'flex-end';
|
||||
|
||||
/**
|
||||
* 过渡动画类型
|
||||
* - zoom-fade: 渐变
|
||||
* - zoom-out: 闪现
|
||||
* - fade-slide: 滑动
|
||||
* - fade: 消退
|
||||
* - fade-bottom: 底部消退
|
||||
* - fade-scale: 缩放消退
|
||||
*/
|
||||
type ThemeAnimateMode = 'zoom-fade' | 'zoom-out' | 'fade-slide' | 'fade' | 'fade-bottom' | 'fade-scale';
|
||||
|
||||
/**
|
||||
* 布局组件的名称
|
||||
* - basic 基础布局
|
||||
* - blank 空白布局
|
||||
*/
|
||||
type LayoutComponentName = 'basic' | 'blank';
|
||||
}
|
25
src/typings/utils.d.ts
vendored
25
src/typings/utils.d.ts
vendored
@ -1,9 +1,30 @@
|
||||
declare namespace TypeUtil {
|
||||
type Noop = (...args: any) => any;
|
||||
|
||||
type UnionInclude<T, K extends keyof T> = K extends keyof T ? true : false;
|
||||
interface DataType {
|
||||
number: number;
|
||||
string: string;
|
||||
boolean: boolean;
|
||||
null: null;
|
||||
undefined: undefined;
|
||||
symbol: symbol;
|
||||
bigInt: bigint;
|
||||
object: Record<string, any>;
|
||||
array: Array<any>;
|
||||
function: (...args: any[]) => any | void;
|
||||
date: Date;
|
||||
regExp: RegExp;
|
||||
promise: Promise<any>;
|
||||
set: Set<any>;
|
||||
map: Map<any, any>;
|
||||
file: File;
|
||||
}
|
||||
|
||||
type GetFunArgs<F extends Noop> = F extends (...args: infer P) => any ? P : never;
|
||||
type DataTypeStringKey = keyof DataType;
|
||||
|
||||
type DataTypeString<T extends DataTypeStringKey = DataTypeStringKey> = `[object ${Capitalize<T>}]`;
|
||||
|
||||
type UnionInclude<T, K extends keyof T> = K extends keyof T ? true : false;
|
||||
|
||||
type Writable<T> = { [K in keyof T]: T[K] };
|
||||
|
||||
|
Reference in New Issue
Block a user