feat(密钥): 用户 API 密钥服务端化——V115 按账号绑定存储 + 后台密钥管理页 + 桌面端全站拦截与配置引导
- 新增 usersecret 模块:外观专利/货源查询密钥从本地 localStorage 迁移至 biz_user_api_secret(AES 加密、按 uid 绑定) - 后台「密钥管理」页:脱敏展示、立即检测、清空;每日 04:30 分布式锁定时巡检 - 桌面端:密钥设置面板走服务端、未配齐引导 /setup-secrets、代理余量展示 - 删除专利汇令牌全链路与密钥保留时长选择器
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { http } from './http'
|
||||
import { unwrap } from './envelope'
|
||||
|
||||
export interface AdminUserSecretItem {
|
||||
id: number
|
||||
userId: number
|
||||
username: string
|
||||
moduleKey: string
|
||||
moduleLabel: string
|
||||
masked: string
|
||||
exists: boolean
|
||||
checkStatus: string
|
||||
checkCode: string
|
||||
checkMessage: string
|
||||
checkLatencyMs: number | null
|
||||
checkedAt: string | null
|
||||
source: string
|
||||
updatedAt: string | null
|
||||
}
|
||||
|
||||
export interface AdminUserSecretPage {
|
||||
items: AdminUserSecretItem[]
|
||||
total: number
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
export interface UserSecretQuery {
|
||||
keyword?: string
|
||||
moduleKey?: string
|
||||
checkStatus?: string
|
||||
page: number
|
||||
pageSize: number
|
||||
}
|
||||
|
||||
/** 分页查询用户密钥(脱敏):GET /api/admin/user-secrets */
|
||||
export async function fetchUserSecretList(params: UserSecretQuery): Promise<AdminUserSecretPage> {
|
||||
const { data } = await http.get('/api/admin/user-secrets', { params })
|
||||
return unwrap<AdminUserSecretPage>(data)
|
||||
}
|
||||
|
||||
/** 立即检测指定密钥:POST /api/admin/user-secrets/{id}/check */
|
||||
export async function checkUserSecret(id: number) {
|
||||
const { data } = await http.post(`/api/admin/user-secrets/${id}/check`)
|
||||
return unwrap<{
|
||||
moduleKey: string
|
||||
checkStatus: string
|
||||
checkCode: string
|
||||
checkMessage: string
|
||||
checkLatencyMs: number | null
|
||||
checkedAt: string | null
|
||||
viaProxy: boolean
|
||||
}>(data)
|
||||
}
|
||||
|
||||
/** 清空指定用户密钥:DELETE /api/admin/user-secrets/{id} */
|
||||
export async function deleteUserSecret(id: number): Promise<void> {
|
||||
const { data } = await http.delete(`/api/admin/user-secrets/${id}`)
|
||||
unwrap<unknown>(data)
|
||||
}
|
||||
Reference in New Issue
Block a user