refactor: 重构 API 层目录结构 & 样式模块化拆分

- API 层按业务域拆分(api/auth/, api/file/, api/system/*)
- 类型定义从 types/api/ 移入对应 api 模块内(就近原则)
- 公共类型统一为 api/common.ts,移除冗余类型重导出
- 样式文件按职责拆分(base/, layout/, vendors/),移除 common.scss
- 移除失效的单元测试文件
This commit is contained in:
Ray.Hao
2026-03-30 08:11:03 +08:00
parent 3a27da6607
commit 3fedf4943d
107 changed files with 464 additions and 8264 deletions

View File

@@ -1,5 +1,5 @@
import request from "@/utils/request";
import type { ConfigQueryParams, ConfigForm, ConfigItem } from "@/types/api";
import type { ConfigQueryParams, ConfigForm, ConfigItem } from "./types";
const CONFIG_BASE_URL = "/api/v1/configs";
@@ -38,3 +38,6 @@ const ConfigAPI = {
};
export default ConfigAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,37 @@
/**
* Config 配置类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 配置分页查询参数 */
export interface ConfigQueryParams extends BaseQueryParams {
/** 搜索关键字 */
keywords?: string;
}
/** 配置表单对象 */
export interface ConfigForm {
/** 配置ID */
id?: string;
/** 配置名称 */
configName?: string;
/** 配置键 */
configKey?: string;
/** 配置值 */
configValue?: string;
/** 备注 */
remark?: string;
}
/** 配置分页对象 */
export interface ConfigItem {
/** 配置ID */
id?: string;
/** 配置名称 */
configName?: string;
/** 配置键 */
configKey?: string;
/** 配置值 */
configValue?: string;
}

View File

@@ -1,5 +1,6 @@
import request from "@/utils/request";
import type { DeptQueryParams, DeptItem, DeptForm, OptionItem } from "@/types/api";
import type { DeptQueryParams, DeptItem, DeptForm } from "./types";
import type { OptionItem } from "@/api/common";
const DEPT_BASE_URL = "/api/v1/depts";
@@ -35,3 +36,6 @@ const DeptAPI = {
};
export default DeptAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,49 @@
/**
* Dept 部门类型定义
*/
/** 部门查询参数 */
export interface DeptQueryParams {
/** 搜索关键字 */
keywords?: string;
/** 状态 */
status?: number;
}
/** 部门视图对象 */
export interface DeptItem {
/** 子部门 */
children?: DeptItem[];
/** 创建时间 */
createTime?: Date;
/** 部门ID */
id?: string;
/** 部门名称 */
name?: string;
/** 父部门ID */
parentId?: string;
/** 排序 */
sort?: number;
/** 状态(1:启用;0:禁用) */
status?: number;
/** 父节点ID路径 */
treePath?: string;
/** 修改时间 */
updateTime?: Date;
}
/** 部门表单对象 */
export interface DeptForm {
/** 部门ID */
id?: string;
/** 部门名称 */
name?: string;
/** 部门编号 */
code?: string;
/** 父部门ID */
parentId?: string;
/** 排序 */
sort?: number;
/** 状态(1:启用;0:禁用) */
status?: number;
}

View File

@@ -7,8 +7,8 @@ import type {
DictItem,
DictItemForm,
DictItemOption,
OptionItem,
} from "@/types/api";
} from "./types";
import type { OptionItem } from "@/api/common";
const DICT_BASE_URL = "/api/v1/dicts";
@@ -96,9 +96,9 @@ const DictAPI = {
params: queryParams,
}).then((data) => ({
...data,
list: (data.list ?? []).map((item) => ({
list: (data.list ?? []).map((item: DictItem & { tagType?: string }) => ({
...item,
tagType: decodeDictTagType((item as any).tagType),
tagType: decodeDictTagType(item.tagType),
})),
}));
},
@@ -153,3 +153,6 @@ const DictAPI = {
};
export default DictAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,92 @@
/**
* Dict 字典类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 字典分页查询参数 */
export interface DictTypeQueryParams extends BaseQueryParams {
/** 搜索关键字 */
keywords?: string;
/** 状态(1:启用;0:禁用) */
status?: number;
}
/** 字典分页对象 */
export interface DictTypeItem {
/** 字典ID */
id: string;
/** 字典名称 */
name: string;
/** 字典编码 */
dictCode: string;
/** 状态(1:启用;0:禁用) */
status: number;
}
/** 字典表单对象 */
export interface DictTypeForm {
/** 字典ID */
id?: string;
/** 字典名称 */
name?: string;
/** 字典编码 */
dictCode?: string;
/** 状态(1:启用;0:禁用) */
status?: number;
/** 备注 */
remark?: string;
}
/** 字典项分页查询参数 */
export interface DictItemQueryParams extends BaseQueryParams {
/** 搜索关键字 */
keywords?: string;
/** 字典编码 */
dictCode?: string;
}
/** 字典项分页对象 */
export interface DictItem {
/** 字典项ID */
id: string;
/** 字典编码 */
dictCode: string;
/** 字典项标签 */
label: string;
/** 字典项值 */
value: string;
/** 状态(1:启用;0:禁用) */
status: number;
/** 排序 */
sort?: number;
}
/** 字典项表单对象 */
export interface DictItemForm {
/** 字典项ID */
id?: string;
/** 字典编码 */
dictCode?: string;
/** 字典项标签 */
label?: string;
/** 字典项值 */
value?: string;
/** 状态(1:启用;0:禁用) */
status?: number;
/** 排序 */
sort?: number;
/** 标签类型 */
tagType?: "success" | "warning" | "info" | "primary" | "danger" | "";
}
/** 字典项选项 */
export interface DictItemOption {
/** 字典项值 */
value: number | string;
/** 字典项标签 */
label: string;
/** 标签类型 */
tagType?: "success" | "warning" | "info" | "primary" | "danger" | "";
}

View File

@@ -1,11 +1,11 @@
import request from "@/utils/request";
import request from "@/utils/request";
import type {
LogQueryParams,
LogItem,
VisitTrendQueryParams,
VisitTrendDetail,
VisitStatsDetail,
} from "@/types/api";
} from "./types";
const LOG_BASE_URL = "/api/v1/logs";
@@ -38,3 +38,6 @@ const LogAPI = {
};
export default LogAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,89 @@
/**
* Log 日志类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 日志分页查询参数 */
export interface LogQueryParams extends BaseQueryParams {
/** 搜索关键字(IP/操作人) */
keywords?: string;
/** 操作时间 */
createTime?: [string, string];
}
/** 日志分页对象 */
export interface LogItem {
/** 日志ID */
id: number;
/** 模块 */
module?: string;
/** 操作类型 */
actionType?: string;
/** 操作标题 */
title?: string;
/** 自定义日志内容 */
content?: string;
/** 操作人ID */
operatorId?: number;
/** 操作人名称 */
operatorName?: string;
/** 请求路径 */
requestUri?: string;
/** 请求方法 */
requestMethod?: string;
/** IP地址 */
ip?: string;
/** 地区 */
region?: string;
/** 设备 */
device?: string;
/** 浏览器 */
browser?: string;
/** 操作系统 */
os?: string;
/** 状态:0失败 1成功 */
status?: number;
/** 执行时间(毫秒) */
executionTime?: number;
/** 错误信息 */
errorMsg?: string;
/** 操作时间 */
createTime?: string;
}
/** 访问趋势查询参数 */
export interface VisitTrendQueryParams {
/** 开始日期 */
startDate: string;
/** 结束日期 */
endDate: string;
}
/** 访问趋势视图对象 */
export interface VisitTrendDetail {
/** 日期列表 */
dates: string[];
/** 浏览量(PV)列表 */
pvList: number[];
/** 访客数(UV)列表 */
uvList: number[];
/** IP数列表 */
ipList: number[];
}
/** 访问量统计视图对象 */
export interface VisitStatsDetail {
/** 今日独立访客数(UV) */
todayUvCount: number;
/** 累计独立访客数(UV) */
totalUvCount: number;
/** 独立访客增长率 */
uvGrowthRate: number;
/** 今日页面浏览量(PV) */
todayPvCount: number;
/** 累计页面浏览量(PV) */
totalPvCount: number;
/** 页面浏览量增长率 */
pvGrowthRate: number;
}

View File

@@ -1,5 +1,6 @@
import request from "@/utils/request";
import type { MenuQueryParams, MenuItem, MenuForm, RouteItem, OptionItem } from "@/types/api";
import type { MenuQueryParams, MenuItem, MenuForm, RouteItem } from "./types";
import type { OptionItem } from "@/api/common";
const MENU_BASE_URL = "/api/v1/menus";
@@ -43,3 +44,6 @@ const MenuAPI = {
};
export default MenuAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,117 @@
/**
* Menu 菜单类型定义
*/
/** 菜单查询参数 */
export interface MenuQueryParams {
/** 搜索关键字 */
keywords?: string;
}
/** 菜单视图对象 */
export interface MenuItem {
/** 子菜单 */
children?: MenuItem[];
/** 组件路径 */
component?: string;
/** ICON */
icon?: string;
/** 菜单ID */
id?: string;
/** 菜单名称 */
name?: string;
/** 父菜单ID */
parentId?: string;
/** 路由路径 */
path?: string;
/** 按钮权限标识 */
perm?: string;
/** 跳转路径 */
redirect?: string;
/** 菜单排序(数字越小排名越靠前) */
sort?: number;
/** 菜单类型(C-目录 M-菜单 B-按钮) */
type?: string;
/** 菜单是否可见(1:显示;0:隐藏) */
visible?: number;
/** 菜单范围(1=平台 2=业务) */
scope?: number;
}
/** 菜单表单对象 */
export interface MenuForm {
/** 菜单ID */
id?: string;
/** 父菜单ID */
parentId?: string;
/** 菜单名称 */
name?: string;
/** 菜单类型(C-目录 M-菜单 B-按钮) */
type?: string;
/** 路由路径 */
path?: string;
/** 路由名称(用于前端路由名) */
routeName?: string;
/** 路由路径(可用于自定义路由字段) */
routePath?: string;
/** 跳转路径 */
redirect?: string;
/** 组件路径 */
component?: string;
/** ICON */
icon?: string;
/** 排序 */
sort?: number;
/** 菜单是否可见 */
visible?: number;
/** 菜单范围(1=平台 2=业务) */
scope?: number;
/** 按钮权限标识 */
perm?: string;
/** 路由参数(用于表单编辑 params) */
params?: { key?: string; value?: string }[];
/** 是否始终显示(仅对目录生效) */
alwaysShow?: number | boolean;
/** 是否缓存(用于 keepAlive) */
keepAlive?: number | boolean;
}
/** 菜单选项 */
export interface MenuOption {
key: string;
value: string;
}
/** 路由对象 */
export interface RouteItem {
/** 子路由列表 */
children: RouteItem[];
/** 组件路径 */
component?: string;
/** 路由名称 */
name?: string;
/** 路由路径 */
path?: string;
/** 路由属性 */
meta?: Meta;
/** 跳转链接 */
redirect?: string;
}
/** 路由属性 */
export interface Meta {
/** 【目录】只有一个子路由是否始终显示 */
alwaysShow?: boolean;
/** 是否隐藏(true-是 false-否) */
hidden?: boolean;
/** ICON */
icon?: string;
/** 【菜单】是否开启页面缓存 */
keepAlive?: boolean;
/** 路由参数 */
params?: Record<string, any>;
/** 角色集合 */
roles?: string[];
/** 路由title */
title?: string;
}

View File

@@ -1,5 +1,5 @@
import request from "@/utils/request";
import type { NoticeQueryParams, NoticeForm, NoticeItem, NoticeDetail } from "@/types/api";
import type { NoticeQueryParams, NoticeForm, NoticeItem, NoticeDetail } from "./types";
const NOTICE_BASE_URL = "/api/v1/notices";
@@ -55,3 +55,6 @@ const NoticeAPI = {
};
export default NoticeAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,79 @@
/**
* Notice 通知类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 通知分页查询参数 */
export interface NoticeQueryParams extends BaseQueryParams {
/** 通知标题 */
title?: string;
/** 发布状态(0:草稿;1:已发布;2:已撤回) */
publishStatus?: number;
/** 是否已读(1:是;0:否) */
isRead?: number;
}
/** 通知表单对象 */
export interface NoticeForm {
/** 通知ID */
id?: string;
/** 通知标题 */
title?: string;
/** 通知内容 */
content?: string;
/** 通知类型 */
type?: number;
/** 通知等级 */
level?: string;
/** 发布状态(0:草稿;1:已发布;-1:已撤回) */
status?: number;
/** 目标用户ID列表 */
targetUsers?: number[];
/** 目标类型 (1:全部,2:指定用户等) */
targetType?: number;
}
/** 通知分页对象 */
export interface NoticeItem {
/** 通知ID */
id: string;
/** 通知标题 */
title: string;
/** 通知内容 */
content: string;
/** 通知类型 */
type: number;
/** 通知等级 */
level: string;
/** 发布状态 */
publishStatus: number;
/** 是否已读 */
isRead: number;
/** 发布时间 */
publishTime?: Date;
/** 撤回时间 */
revokeTime?: Date;
}
/** 通知详情对象 */
export interface NoticeDetail {
/** 通知ID */
id?: string;
/** 通知标题 */
title?: string;
/** 通知内容 */
content?: string;
/** 通知类型 */
type?: number;
/** 通知等级 */
level?: string;
/** 发布状态 */
publishStatus?: number;
/** 目标用户ID */
targetUserIds?: string;
/** 发布人名称 */
publisherName?: string;
/** 发布时间 */
publishTime?: Date;
}

View File

@@ -1,5 +1,6 @@
import request from "@/utils/request";
import type { RoleQueryParams, RoleItem, RoleForm, OptionItem } from "@/types/api";
import type { RoleQueryParams, RoleItem, RoleForm } from "./types";
import type { OptionItem } from "@/api/common";
const ROLE_BASE_URL = "/api/v1/roles";
@@ -47,3 +48,6 @@ const RoleAPI = {
};
export default RoleAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,51 @@
/**
* Role 角色类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 角色分页查询参数 */
export interface RoleQueryParams extends BaseQueryParams {
/** 搜索关键字 */
keywords?: string;
}
/** 角色分页对象 */
export interface RoleItem {
/** 角色ID */
id?: string;
/** 角色编码 */
code?: string;
/** 角色名称 */
name?: string;
/** 排序 */
sort?: number;
/** 角色状态 */
status?: number;
/** 数据权限(1-所有数据 2-部门及子部门数据 3-本部门数据 4-本人数据 5-自定义部门数据) */
dataScope?: number;
/** 数据权限标签 */
dataScopeLabel?: string;
/** 修改时间 */
updateTime?: Date;
}
/** 角色表单对象 */
export interface RoleForm {
/** 角色ID */
id?: string;
/** 角色编码 */
code?: string;
/** 角色名称 */
name?: string;
/** 排序 */
sort?: number;
/** 数据权限(1-所有数据 2-部门及子部门数据 3-本部门数据 4-本人数据 5-自定义部门数据) */
dataScope?: number;
/** 自定义数据权限部门ID列表(当dataScope=5时有效) */
deptIds?: string[];
/** 角色状态 */
status?: number;
/** 备注 */
remark?: string;
}

View File

@@ -1,10 +1,6 @@
import request from "@/utils/request";
import type { OptionItem, PageResult } from "@/types/api";
import type {
TenantPlanForm,
TenantPlanItem,
TenantPlanQueryParams,
} from "@/types/api/tenant-plan";
import type { TenantPlanForm, TenantPlanItem, TenantPlanQueryParams } from "./types";
import type { OptionItem } from "@/api/common";
const TENANT_PLAN_BASE_URL = "/api/v1/tenant-plans";
@@ -68,3 +64,6 @@ const TenantPlanAPI = {
};
export default TenantPlanAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,35 @@
/**
* Tenant Plan 租户套餐类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 租户套餐分页查询参数 */
export interface TenantPlanQueryParams extends BaseQueryParams {
/** 关键字(套餐名称/套餐编码) */
keywords?: string;
/** 状态(1-启用 0-停用) */
status?: number;
}
/** 租户套餐分页对象 */
export interface TenantPlanItem {
id?: number;
name?: string;
code?: string;
status?: number;
sort?: number;
remark?: string;
createTime?: string;
updateTime?: string;
}
/** 租户套餐表单对象 */
export interface TenantPlanForm {
id?: number;
name?: string;
code?: string;
status?: number;
sort?: number;
remark?: string;
}

View File

@@ -6,7 +6,7 @@ import type {
TenantCreateResult,
TenantQueryParams,
TenantItem,
} from "@/types/api";
} from "./types";
const TENANT_BASE_URL = "/api/v1/tenants";
@@ -118,3 +118,6 @@ const TenantAPI = {
};
export default TenantAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,82 @@
/**
* Tenant 租户类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 租户信息 */
export interface TenantInfo {
/** 租户ID */
id: number;
/** 租户名称 */
name: string;
/** 租户域名 */
domain?: string;
}
/** 租户分页查询参数 */
export interface TenantQueryParams extends BaseQueryParams {
/** 关键字(租户名称/租户编码/域名) */
keywords?: string;
/** 租户状态(1-正常 0-禁用) */
status?: number;
}
/** 租户分页对象 */
export interface TenantItem {
id?: string;
name?: string;
code?: string;
contactName?: string;
contactPhone?: string;
contactEmail?: string;
domain?: string;
logo?: string;
planId?: number;
status?: number;
remark?: string;
expireTime?: string;
createTime?: string;
updateTime?: string;
}
/** 租户表单对象(编辑) */
export interface TenantForm {
id?: string;
name?: string;
code?: string;
contactName?: string;
contactPhone?: string;
contactEmail?: string;
domain?: string;
logo?: string;
planId?: number;
status?: number;
remark?: string;
expireTime?: string;
}
/** 新增租户表单对象 */
export interface TenantCreateForm {
name?: string;
code?: string;
contactName?: string;
contactPhone?: string;
contactEmail?: string;
domain?: string;
logo?: string;
planId?: number;
remark?: string;
expireTime?: string;
adminUsername?: string;
}
/** 新增租户结果 */
export interface TenantCreateResult {
tenantId?: string;
tenantCode?: string;
tenantName?: string;
adminUsername?: string;
adminInitialPassword?: string;
adminRoleCode?: string;
}

View File

@@ -10,8 +10,8 @@ import type {
PasswordVerifyForm,
MobileUpdateForm,
EmailUpdateForm,
OptionItem,
} from "@/types/api";
} from "./types";
import type { OptionItem, ExcelResult } from "@/api/common";
const USER_BASE_URL = "/api/v1/users";
@@ -240,3 +240,6 @@ const UserAPI = {
};
export default UserAPI;
// 重导出类型
export * from "./types";

View File

@@ -0,0 +1,155 @@
/**
* User 用户类型定义
*/
import type { BaseQueryParams } from "@/api/common";
/** 登录用户信息 */
export interface UserInfo {
/** 用户ID */
userId?: string;
/** 用户名 */
username?: string;
/** 用户昵称 */
nickname?: string;
/** 头像URL */
avatar?: string;
/** 租户切换权限(true 可切换租户) */
canSwitchTenant?: boolean;
/** 角色集合 */
roles: string[];
/** 权限集合 */
perms: string[];
}
/** 用户分页查询参数 */
export interface UserQueryParams extends BaseQueryParams {
/** 搜索关键字 */
keywords?: string;
/** 用户状态 */
status?: number;
/** 部门ID */
deptId?: string;
/** 创建时间 */
createTime?: [string, string];
}
/** 用户分页对象 */
export interface UserItem {
/** 用户ID */
id: string;
/** 用户头像地址 */
avatar?: string;
/** 创建时间 */
createTime?: Date;
/** 部门名称 */
deptName?: string;
/** 用户邮箱 */
email?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 用户昵称 */
nickname?: string;
/** 角色名称,多个使用英文逗号(,)分割 */
roleNames?: string;
/** 用户状态(1:启用;0:禁用) */
status?: number;
/** 用户名 */
username?: string;
}
/** 用户表单对象 */
export interface UserForm {
/** 用户ID */
id?: string;
/** 用户头像 */
avatar?: string;
/** 部门ID */
deptId?: string;
/** 用户邮箱 */
email?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 用户昵称 */
nickname?: string;
/** 角色ID集合 */
roleIds?: number[];
/** 用户状态(1:正常;0:禁用) */
status?: number;
/** 用户名 */
username?: string;
}
/** 个人中心用户信息 */
export interface UserProfileDetail {
/** 用户ID */
id?: string;
/** 用户名 */
username?: string;
/** 用户昵称 */
nickname?: string;
/** 头像URL */
avatar?: string;
/** 性别 */
gender?: number;
/** 手机号 */
mobile?: string;
/** 邮箱 */
email?: string;
/** 部门名称 */
deptName?: string;
/** 角色名称 */
roleNames?: string;
/** 创建时间 */
createTime?: Date;
}
/** 个人中心用户信息表单 */
export interface UserProfileForm {
/** 用户昵称 */
nickname?: string;
/** 头像URL */
avatar?: string;
/** 性别 */
gender?: number;
}
/** 修改密码表单 */
export interface PasswordChangeForm {
/** 原密码 */
oldPassword?: string;
/** 新密码 */
newPassword?: string;
/** 确认新密码 */
confirmPassword?: string;
}
/** 密码校验表单 */
export interface PasswordVerifyForm {
/** 当前密码 */
password?: string;
}
/** 修改手机表单 */
export interface MobileUpdateForm {
/** 手机号 */
mobile?: string;
/** 验证码 */
code?: string;
/** 当前密码 */
password?: string;
}
/** 修改邮箱表单 */
export interface EmailUpdateForm {
/** 邮箱 */
email?: string;
/** 验证码 */
code?: string;
/** 当前密码 */
password?: string;
}