refactor(ui): 界面升级与代码规范优化
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import request from "@/utils/request";
|
||||
import type { LoginRequest, LoginResponse, CaptchaInfo } from "./types";
|
||||
import type { CaptchaInfo, LoginRequest, LoginResult } from "./types";
|
||||
|
||||
const AUTH_BASE_URL = "/api/v1/auth";
|
||||
|
||||
const AuthAPI = {
|
||||
/** 登录接口*/
|
||||
login(data: LoginRequest) {
|
||||
const payload: Pick<
|
||||
LoginRequest,
|
||||
@@ -16,30 +15,28 @@ const AuthAPI = {
|
||||
captchaCode: data.captchaCode,
|
||||
};
|
||||
|
||||
// tenantId 可选,仅在提供时包含(多租户功能)
|
||||
// 仅多租户场景传入 tenantId
|
||||
if (typeof data.tenantId !== "undefined") {
|
||||
payload.tenantId = data.tenantId;
|
||||
}
|
||||
|
||||
return request<unknown, LoginResponse>({
|
||||
return request<unknown, LoginResult>({
|
||||
url: `${AUTH_BASE_URL}/login`,
|
||||
method: "post",
|
||||
data: payload,
|
||||
});
|
||||
},
|
||||
|
||||
/** 切换租户(平台用户) - 返回新的 token */
|
||||
switchTenant(tenantId: number) {
|
||||
return request<unknown, LoginResponse>({
|
||||
return request<unknown, LoginResult>({
|
||||
url: `${AUTH_BASE_URL}/switch-tenant`,
|
||||
method: "post",
|
||||
params: { tenantId },
|
||||
});
|
||||
},
|
||||
|
||||
/** 刷新 token 接口*/
|
||||
refreshToken(refreshToken: string) {
|
||||
return request<unknown, LoginResponse>({
|
||||
return request<unknown, LoginResult>({
|
||||
url: `${AUTH_BASE_URL}/refresh-token`,
|
||||
method: "post",
|
||||
params: { refreshToken },
|
||||
@@ -49,7 +46,6 @@ const AuthAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
/** 退出登录接口 */
|
||||
logout() {
|
||||
return request({
|
||||
url: `${AUTH_BASE_URL}/logout`,
|
||||
@@ -57,7 +53,6 @@ const AuthAPI = {
|
||||
});
|
||||
},
|
||||
|
||||
/** 获取验证码接口*/
|
||||
getCaptcha() {
|
||||
return request<unknown, CaptchaInfo>({
|
||||
url: `${AUTH_BASE_URL}/captcha`,
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/**
|
||||
* 认证相关类型定义
|
||||
*/
|
||||
|
||||
/**
|
||||
* 登录请求参数
|
||||
*/
|
||||
@@ -10,20 +6,20 @@ export interface LoginRequest {
|
||||
username: string;
|
||||
/** 密码 */
|
||||
password: string;
|
||||
/** 验证码缓存key */
|
||||
/** 验证码缓存 key */
|
||||
captchaId?: string;
|
||||
/** 验证码 */
|
||||
captchaCode?: string;
|
||||
/** 记住我 */
|
||||
rememberMe?: boolean;
|
||||
/** 租户ID */
|
||||
/** 租户 ID */
|
||||
tenantId?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录响应
|
||||
* 登录结果
|
||||
*/
|
||||
export interface LoginResponse {
|
||||
export interface LoginResult {
|
||||
/** 访问令牌 */
|
||||
accessToken: string;
|
||||
/** 刷新令牌 */
|
||||
@@ -35,11 +31,11 @@ export interface LoginResponse {
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码响应
|
||||
* 验证码信息
|
||||
*/
|
||||
export interface CaptchaInfo {
|
||||
/** 验证码缓存key */
|
||||
/** 验证码缓存 key */
|
||||
captchaId: string;
|
||||
/** 验证码图片Base64 */
|
||||
/** 验证码图片 Base64 */
|
||||
captchaBase64: string;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import request from "@/utils/request";
|
||||
import type { GeneratorPreviewItem, TableQueryParams, TableItem, GenConfigForm } from "./types";
|
||||
import type { PageResult } from "@/api/common";
|
||||
|
||||
const GENERATOR_BASE_URL = "/api/v1/codegen";
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
/**
|
||||
* 通用 API 类型定义
|
||||
* API 响应壳
|
||||
*/
|
||||
|
||||
/** API 响应结构 */
|
||||
export interface ApiResponse<T = unknown> {
|
||||
/** 响应码 */
|
||||
export interface ApiResult<T = unknown> {
|
||||
/** 业务状态码 */
|
||||
code: string;
|
||||
/** 响应数据 */
|
||||
/** 业务数据 */
|
||||
data: T;
|
||||
/** 响应消息 */
|
||||
/** 业务消息 */
|
||||
msg: string;
|
||||
}
|
||||
|
||||
/** 基础查询参数 */
|
||||
/**
|
||||
* 分页查询基础参数
|
||||
*/
|
||||
export interface BaseQueryParams {
|
||||
/** 页码 */
|
||||
pageNum: number;
|
||||
@@ -26,7 +26,9 @@ export interface BaseQueryParams {
|
||||
order?: string;
|
||||
}
|
||||
|
||||
/** 分页数据结构(仅分页接口) */
|
||||
/**
|
||||
* 分页接口结果
|
||||
*/
|
||||
export interface PageResult<T> {
|
||||
/** 数据列表 */
|
||||
list: T[];
|
||||
@@ -34,7 +36,9 @@ export interface PageResult<T> {
|
||||
total: number;
|
||||
}
|
||||
|
||||
/** 下拉选项 */
|
||||
/**
|
||||
* 通用选项项
|
||||
*/
|
||||
export interface OptionItem {
|
||||
/** 选项值 */
|
||||
value: string | number;
|
||||
@@ -44,9 +48,11 @@ export interface OptionItem {
|
||||
children?: OptionItem[];
|
||||
}
|
||||
|
||||
/** Excel 导入结果 */
|
||||
/**
|
||||
* Excel 导入结果
|
||||
*/
|
||||
export interface ExcelResult {
|
||||
/** 响应码 */
|
||||
/** 业务状态码 */
|
||||
code: string;
|
||||
/** 无效数据数量 */
|
||||
invalidCount: number;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import request from "@/utils/request";
|
||||
import type { ConfigQueryParams, ConfigForm, ConfigItem } from "./types";
|
||||
import type { PageResult } from "@/api/common";
|
||||
|
||||
const CONFIG_BASE_URL = "/api/v1/configs";
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import type {
|
||||
DictItemForm,
|
||||
DictItemOption,
|
||||
} from "./types";
|
||||
import type { OptionItem, PageResult } from "@/api/common";
|
||||
|
||||
const DICT_BASE_URL = "/api/v1/dicts";
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import type {
|
||||
VisitTrendDetail,
|
||||
VisitOverviewDetail,
|
||||
} from "./types";
|
||||
import type { PageResult } from "@/api/common";
|
||||
|
||||
const LOG_BASE_URL = "/api/v1/logs";
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import request from "@/utils/request";
|
||||
import type { NoticeQueryParams, NoticeForm, NoticeItem, NoticeDetail } from "./types";
|
||||
import type { PageResult } from "@/api/common";
|
||||
|
||||
const NOTICE_BASE_URL = "/api/v1/notices";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import request from "@/utils/request";
|
||||
import type { RoleQueryParams, RoleItem, RoleForm } from "./types";
|
||||
import type { OptionItem } from "@/api/common";
|
||||
import type { OptionItem, PageResult } from "@/api/common";
|
||||
|
||||
const ROLE_BASE_URL = "/api/v1/roles";
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import request from "@/utils/request";
|
||||
import type { TenantPlanForm, TenantPlanItem, TenantPlanQueryParams } from "./types";
|
||||
import type { OptionItem } from "@/api/common";
|
||||
import type { OptionItem, PageResult } from "@/api/common";
|
||||
|
||||
const TENANT_PLAN_BASE_URL = "/api/v1/tenant-plans";
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import type {
|
||||
TenantQueryParams,
|
||||
TenantItem,
|
||||
} from "./types";
|
||||
import type { PageResult } from "@/api/common";
|
||||
|
||||
const TENANT_BASE_URL = "/api/v1/tenants";
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
MobileUpdateForm,
|
||||
EmailUpdateForm,
|
||||
} from "./types";
|
||||
import type { OptionItem, ExcelResult } from "@/api/common";
|
||||
import type { ExcelResult, OptionItem, PageResult } from "@/api/common";
|
||||
|
||||
const USER_BASE_URL = "/api/v1/users";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user