mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 04:46:26 +00:00
chore: 完成项目多批次优化与功能迭代
本次提交包含多项改进: 1. 国际化补充:新增通知空状态文案中英文支持 2. 启动优化:重构banner输出、移除环境参数依赖,简化启动日志 3. 配置清理:移除冗余的REDIS_ENABLE/SQL_DB_ENABLE配置项,同步更新env示例与测试配置 4. 接口分页改造:将全局分页参数从Query改为Depends自动解析,统一排序逻辑 5. 菜单权限优化:调整菜单可见范围默认值、修复平台菜单路由路径错误 6. 异常处理增强:完善数据库异常捕获逻辑,新增连接失败专项处理 7. API令牌重构:重命名API令牌路由与权限标识,拆分前端API文件 8. 定时任务整合:将系统任务注册移入调度器初始化逻辑 9. 数据库连接优化:新增连接检查,简化建表/删表逻辑 10. 控制台美化:重构启动控制台面板,优化信息展示格式 11. 租户/角色服务优化:移除不必要的超级管理员装饰器,统一分页排序逻辑 12. 用户菜单适配:修复超级用户菜单过滤逻辑,移除scope强制校验
This commit is contained in:
@@ -0,0 +1,110 @@
|
||||
import { request } from "@utils";
|
||||
|
||||
const API_PATH = "/system/api_token";
|
||||
|
||||
const ApiTokenAPI = {
|
||||
/** 创建 API Token */
|
||||
createToken(body: ApiTokenCreateForm) {
|
||||
return request<ApiResponse<ApiTokenCreatedSchema>>({
|
||||
url: `${API_PATH}/create`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 分页列表 */
|
||||
listToken(query: ApiTokenPageQuery) {
|
||||
return request<ApiResponse<PageResult<ApiTokenTable>>>({
|
||||
url: `${API_PATH}/list`,
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
},
|
||||
|
||||
/** 详情 */
|
||||
detailToken(id: number) {
|
||||
return request<ApiResponse<ApiTokenTable>>({
|
||||
url: `${API_PATH}/detail/${id}`,
|
||||
method: "get",
|
||||
});
|
||||
},
|
||||
|
||||
/** 重置 token */
|
||||
resetToken(id: number, body: { name?: string; description?: string }) {
|
||||
return request<ApiResponse<ApiTokenCreatedSchema>>({
|
||||
url: `${API_PATH}/${id}/reset`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 启用/禁用 */
|
||||
setTokenStatus(id: number, body: { status: number }) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/${id}/status`,
|
||||
method: "patch",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
|
||||
/** 删除 */
|
||||
deleteToken(id: number) {
|
||||
return request<ApiResponse>({
|
||||
url: `${API_PATH}/${id}`,
|
||||
method: "delete",
|
||||
});
|
||||
},
|
||||
|
||||
/** 查看明文(二次验证) */
|
||||
revealToken(id: number, body: { password: string }) {
|
||||
return request<ApiResponse<ApiTokenRevealSchema>>({
|
||||
url: `${API_PATH}/${id}/reveal`,
|
||||
method: "post",
|
||||
data: body,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default ApiTokenAPI;
|
||||
|
||||
export interface ApiTokenPageQuery extends PageQuery {
|
||||
name?: string;
|
||||
status?: number;
|
||||
}
|
||||
|
||||
export interface ApiTokenTable extends BaseType {
|
||||
name?: string;
|
||||
token_prefix?: string;
|
||||
scopes?: string[];
|
||||
expires_at?: string;
|
||||
rate_limit?: number;
|
||||
status?: number;
|
||||
last_used_at?: string;
|
||||
used_count?: number;
|
||||
description?: string;
|
||||
tenant_id?: number;
|
||||
}
|
||||
|
||||
export interface ApiTokenCreateForm extends BaseFormType {
|
||||
name: string;
|
||||
scopes?: string[];
|
||||
expires_at?: string;
|
||||
rate_limit?: number;
|
||||
status?: number;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface ApiTokenCreatedSchema {
|
||||
id: number;
|
||||
name: string;
|
||||
token_prefix: string;
|
||||
/** 创建时完整返回,请立即保存 */
|
||||
token_plain: string;
|
||||
expires_at?: string;
|
||||
}
|
||||
|
||||
export interface ApiTokenRevealSchema {
|
||||
id: number;
|
||||
token_plain: string;
|
||||
expires_at?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user