refactor: 重构项目结构 - enums/config/types/plugins
- 重构 enums: 按业务域合并为 5 个文件 - 创建 config: storage.ts, vxe-table.ts - 删除 plugins,功能迁移到 main.ts - 创建完整 types 结构 - 新增 utils: validators, websocket, register-components - 创建 router/guards/permission.ts - 更新配置文件
This commit is contained in:
24
src/types/api/auth.ts
Normal file
24
src/types/api/auth.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* 认证相关类型定义
|
||||
*/
|
||||
|
||||
export interface LoginRequest {
|
||||
username: string;
|
||||
password: string;
|
||||
captchaId?: string;
|
||||
captchaCode?: string;
|
||||
rememberMe?: boolean;
|
||||
tenantId?: number;
|
||||
}
|
||||
|
||||
export interface LoginResult {
|
||||
accessToken: string;
|
||||
refreshToken: string;
|
||||
tokenType: string;
|
||||
expiresIn: number;
|
||||
}
|
||||
|
||||
export interface CaptchaInfo {
|
||||
captchaId: string;
|
||||
captchaBase64: string;
|
||||
}
|
||||
32
src/types/api/common.ts
Normal file
32
src/types/api/common.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* 通用 API 类型定义
|
||||
*/
|
||||
|
||||
export interface ApiResponse<T = any> {
|
||||
code: string;
|
||||
data: T;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
export interface PageQuery {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface PageResult<T> {
|
||||
list: T;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface OptionType {
|
||||
value: string | number;
|
||||
label: string;
|
||||
children?: OptionType[];
|
||||
}
|
||||
|
||||
export interface ExcelResult {
|
||||
code: string;
|
||||
invalidCount: number;
|
||||
validCount: number;
|
||||
messageList: string[];
|
||||
}
|
||||
6
src/types/api/index.ts
Normal file
6
src/types/api/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* API 类型统一导出
|
||||
*/
|
||||
|
||||
export * from "./common";
|
||||
export * from "./auth";
|
||||
35
src/types/env.d.ts
vendored
35
src/types/env.d.ts
vendored
@@ -1,35 +0,0 @@
|
||||
// https://cn.vitejs.dev/guide/env-and-mode
|
||||
|
||||
// TypeScript 类型提示都为 string: https://github.com/vitejs/vite/issues/6930
|
||||
interface ImportMetaEnv {
|
||||
/** 应用端口 */
|
||||
VITE_APP_PORT: number;
|
||||
/** 应用名称 */
|
||||
VITE_APP_NAME: string;
|
||||
/** API 基础路径(代理前缀) */
|
||||
VITE_APP_BASE_API: string;
|
||||
/** API 地址 */
|
||||
VITE_APP_API_URL: string;
|
||||
/** 是否开启 Mock 服务 */
|
||||
VITE_MOCK_DEV_SERVER: boolean;
|
||||
}
|
||||
|
||||
interface ImportMeta {
|
||||
readonly env: ImportMetaEnv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台的名称、版本、运行所需的`node`版本、依赖、构建时间的类型提示
|
||||
*/
|
||||
declare const __APP_INFO__: {
|
||||
pkg: {
|
||||
name: string;
|
||||
version: string;
|
||||
engines: {
|
||||
node: string;
|
||||
};
|
||||
dependencies: Record<string, string>;
|
||||
devDependencies: Record<string, string>;
|
||||
};
|
||||
buildTimestamp: number;
|
||||
};
|
||||
121
src/types/global.d.ts
vendored
121
src/types/global.d.ts
vendored
@@ -1,111 +1,16 @@
|
||||
/**
|
||||
* 全局类型声明
|
||||
*
|
||||
* @deprecated 请使用 @/types 下的具名导出
|
||||
*/
|
||||
declare global {
|
||||
/**
|
||||
* 响应数据
|
||||
*/
|
||||
interface ApiResponse<T = any> {
|
||||
code: string;
|
||||
data: T;
|
||||
msg: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询参数
|
||||
*/
|
||||
interface PageQuery {
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页响应对象
|
||||
*/
|
||||
interface PageResult<T> {
|
||||
/** 数据列表 */
|
||||
list: T;
|
||||
/** 总数 */
|
||||
total: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 页签对象
|
||||
*/
|
||||
interface TagView {
|
||||
/** 页签名称 */
|
||||
name: string;
|
||||
/** 页签标题 */
|
||||
title: string;
|
||||
/** 页签路由路径 */
|
||||
path: string;
|
||||
/** 页签路由完整路径 */
|
||||
fullPath: string;
|
||||
/** 页签图标 */
|
||||
icon?: string;
|
||||
/** 是否固定页签 */
|
||||
affix?: boolean;
|
||||
/** 是否开启缓存 */
|
||||
keepAlive?: boolean;
|
||||
/** 路由查询参数 */
|
||||
query?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统设置
|
||||
*/
|
||||
interface AppSettings {
|
||||
/** 系统标题 */
|
||||
title: string;
|
||||
/** 系统版本 */
|
||||
version: string;
|
||||
/** 是否显示设置 */
|
||||
showSettings: boolean;
|
||||
/** 是否显示多标签导航 */
|
||||
showTagsView: boolean;
|
||||
/** 是否显示应用Logo */
|
||||
showAppLogo: boolean;
|
||||
/** 导航栏布局(left|top|mix) */
|
||||
layout: "left" | "top" | "mix";
|
||||
/** 主题颜色 */
|
||||
themeColor: string;
|
||||
/** 主题模式(dark|light) */
|
||||
theme: import("@/enums/settings/theme-enum").ThemeMode;
|
||||
/** 布局大小(default |large |small) */
|
||||
size: string;
|
||||
/** 语言( zh-cn| en) */
|
||||
language: string;
|
||||
/** 是否显示水印 */
|
||||
showWatermark: boolean;
|
||||
/** 水印内容 */
|
||||
watermarkContent: string;
|
||||
/** 侧边栏配色方案 */
|
||||
sidebarColorScheme: "classic-blue" | "minimal-white";
|
||||
/** 是否启用 AI 助手 */
|
||||
enableAiAssistant: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉选项数据类型
|
||||
*/
|
||||
interface OptionType {
|
||||
/** 值 */
|
||||
value: string | number;
|
||||
/** 文本 */
|
||||
label: string;
|
||||
/** 子列表 */
|
||||
children?: OptionType[];
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入结果
|
||||
*/
|
||||
interface ExcelResult {
|
||||
/** 状态码 */
|
||||
code: string;
|
||||
/** 无效数据条数 */
|
||||
invalidCount: number;
|
||||
/** 有效数据条数 */
|
||||
validCount: number;
|
||||
/** 错误信息 */
|
||||
messageList: Array<string>;
|
||||
}
|
||||
type ApiResponse<T = any> = import("@/types/api").ApiResponse<T>;
|
||||
type PageQuery = import("@/types/api").PageQuery;
|
||||
type PageResult<T> = import("@/types/api").PageResult<T>;
|
||||
type OptionType = import("@/types/api").OptionType;
|
||||
type ExcelResult = import("@/types/api").ExcelResult;
|
||||
type TagView = import("@/types/ui").TagView;
|
||||
type AppSettings = import("@/types/ui").AppSettings;
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
6
src/types/index.ts
Normal file
6
src/types/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* 类型统一导出
|
||||
*/
|
||||
|
||||
export * from "./api";
|
||||
export * from "./ui";
|
||||
54
src/types/router.d.ts
vendored
54
src/types/router.d.ts
vendored
@@ -1,54 +0,0 @@
|
||||
import "vue-router";
|
||||
|
||||
declare module "vue-router" {
|
||||
// https://router.vuejs.org/zh/guide/advanced/meta.html#typescript
|
||||
// 可以通过扩展 RouteMeta 接口来输入 meta 字段
|
||||
interface RouteMeta {
|
||||
/**
|
||||
* 菜单名称
|
||||
* @example 'Dashboard'
|
||||
*/
|
||||
title?: string;
|
||||
|
||||
/**
|
||||
* 菜单图标
|
||||
* @example 'el-icon-edit'
|
||||
*/
|
||||
icon?: string;
|
||||
|
||||
/**
|
||||
* 是否隐藏菜单
|
||||
* true 隐藏, false 显示
|
||||
* @default false
|
||||
*/
|
||||
hidden?: boolean;
|
||||
|
||||
/**
|
||||
* 始终显示父级菜单,即使只有一个子菜单
|
||||
* true 显示父级菜单, false 隐藏父级菜单,显示唯一子节点
|
||||
* @default false
|
||||
*/
|
||||
alwaysShow?: boolean;
|
||||
|
||||
/**
|
||||
* 是否固定在页签上
|
||||
* true 固定, false 不固定
|
||||
* @default false
|
||||
*/
|
||||
affix?: boolean;
|
||||
|
||||
/**
|
||||
* 是否缓存页面
|
||||
* true 缓存, false 不缓存
|
||||
* @default false
|
||||
*/
|
||||
keepAlive?: boolean;
|
||||
|
||||
/**
|
||||
* 是否在面包屑导航中隐藏
|
||||
* true 隐藏, false 显示
|
||||
* @default false
|
||||
*/
|
||||
breadcrumb?: boolean;
|
||||
}
|
||||
}
|
||||
5
src/types/shims-vue.d.ts
vendored
5
src/types/shims-vue.d.ts
vendored
@@ -1,5 +0,0 @@
|
||||
declare module "*.vue" {
|
||||
import type { DefineComponent } from "vue";
|
||||
const component: DefineComponent<{}, {}, any>;
|
||||
export default component;
|
||||
}
|
||||
6
src/types/socket.d.ts
vendored
6
src/types/socket.d.ts
vendored
@@ -1,6 +0,0 @@
|
||||
// https://github.com/sockjs/sockjs-client/issues/565
|
||||
|
||||
declare module "sockjs-client/dist/sockjs.min.js" {
|
||||
import Client from "sockjs-client";
|
||||
export default Client;
|
||||
}
|
||||
6
src/types/ui/index.ts
Normal file
6
src/types/ui/index.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* UI 类型统一导出
|
||||
*/
|
||||
|
||||
export * from "./tagsview";
|
||||
export * from "./settings";
|
||||
22
src/types/ui/settings.ts
Normal file
22
src/types/ui/settings.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 应用设置相关类型定义
|
||||
*/
|
||||
|
||||
import type { ThemeMode } from "@/enums";
|
||||
|
||||
export interface AppSettings {
|
||||
title: string;
|
||||
version: string;
|
||||
showSettings: boolean;
|
||||
showTagsView: boolean;
|
||||
showAppLogo: boolean;
|
||||
layout: "left" | "top" | "mix";
|
||||
themeColor: string;
|
||||
theme: ThemeMode;
|
||||
size: string;
|
||||
language: string;
|
||||
showWatermark: boolean;
|
||||
watermarkContent: string;
|
||||
sidebarColorScheme: "classic-blue" | "minimal-white";
|
||||
enableAiAssistant: boolean;
|
||||
}
|
||||
14
src/types/ui/tagsview.ts
Normal file
14
src/types/ui/tagsview.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 标签页相关类型定义
|
||||
*/
|
||||
|
||||
export interface TagView {
|
||||
name: string;
|
||||
title: string;
|
||||
path: string;
|
||||
fullPath: string;
|
||||
icon?: string;
|
||||
affix?: boolean;
|
||||
keepAlive?: boolean;
|
||||
query?: any;
|
||||
}
|
||||
Reference in New Issue
Block a user