增加前端格式检查配置
This commit is contained in:
@@ -26,7 +26,10 @@ export async function fetchAdminAnnouncements(params: {
|
||||
page?: number
|
||||
page_size?: number
|
||||
}): Promise<PaginatedResult<Announcement>> {
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<Announcement>>>('/admin/announcements', { params })
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<Announcement>>>(
|
||||
'/admin/announcements',
|
||||
{ params }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -40,7 +43,10 @@ export async function createAnnouncement(req: CreateAnnouncementRequest): Promis
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function updateAnnouncement(id: number, req: UpdateAnnouncementRequest): Promise<Announcement> {
|
||||
export async function updateAnnouncement(
|
||||
id: number,
|
||||
req: UpdateAnnouncementRequest
|
||||
): Promise<Announcement> {
|
||||
const { data } = await apiClient.put<ApiResponse<Announcement>>(`/admin/announcements/${id}`, req)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -26,7 +26,12 @@ export interface AdminAuditQuery {
|
||||
}
|
||||
|
||||
export async function fetchAdminAuditLogs(query: AdminAuditQuery = {}) {
|
||||
const params = Object.fromEntries(Object.entries(query).filter(([, value]) => value !== '' && value !== undefined))
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminAuditLog>>>('/admin/audit-logs', { params })
|
||||
const params = Object.fromEntries(
|
||||
Object.entries(query).filter(([, value]) => value !== '' && value !== undefined)
|
||||
)
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminAuditLog>>>(
|
||||
'/admin/audit-logs',
|
||||
{ params }
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -45,7 +45,12 @@ export async function fetchAdminCaptcha() {
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function loginAdmin(username: string, password: string, captchaId: string, captchaCode: string) {
|
||||
export async function loginAdmin(
|
||||
username: string,
|
||||
password: string,
|
||||
captchaId: string,
|
||||
captchaCode: string
|
||||
) {
|
||||
const { data } = await apiClient.post<ApiResponse<AdminLoginData>>('/admin/auth/login', {
|
||||
username,
|
||||
password,
|
||||
@@ -66,9 +71,12 @@ export async function logoutAdmin() {
|
||||
}
|
||||
|
||||
export async function updateSupportStatus(status: 'online' | 'offline' | 'busy') {
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean; support_status: string }>>('/admin/me/support-status', {
|
||||
status,
|
||||
})
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean; support_status: string }>>(
|
||||
'/admin/me/support-status',
|
||||
{
|
||||
status,
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -76,7 +84,11 @@ export async function updateSupportStatus(status: 'online' | 'offline' | 'busy')
|
||||
export async function refreshAdminSession() {
|
||||
const refreshToken = getRefreshToken('admin')
|
||||
if (!refreshToken) throw new Error('no refresh token')
|
||||
const { data } = await axios.post<ApiResponse<AdminTokenPair>>('/api/admin/auth/refresh', { refresh_token: refreshToken }, { timeout: 10000 })
|
||||
const { data } = await axios.post<ApiResponse<AdminTokenPair>>(
|
||||
'/api/admin/auth/refresh',
|
||||
{ refresh_token: refreshToken },
|
||||
{ timeout: 10000 }
|
||||
)
|
||||
setAuthTokens('admin', data.data)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -37,9 +37,12 @@ export interface ChangePasswordRequest {
|
||||
}
|
||||
|
||||
export async function fetchAdminMgrUsers(page = 1, pageSize = 20) {
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminMgrUser>>>('/admin/admin-users', {
|
||||
params: { page, page_size: pageSize },
|
||||
})
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminMgrUser>>>(
|
||||
'/admin/admin-users',
|
||||
{
|
||||
params: { page, page_size: pageSize },
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -59,18 +62,26 @@ export async function updateAdminMgrUser(id: number, req: UpdateAdminRequest) {
|
||||
}
|
||||
|
||||
export async function deleteAdminMgrUser(id: number) {
|
||||
const { data } = await apiClient.delete<ApiResponse<{ deleted: boolean }>>(`/admin/admin-users/${id}`)
|
||||
const { data } = await apiClient.delete<ApiResponse<{ deleted: boolean }>>(
|
||||
`/admin/admin-users/${id}`
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function assignAdminRoles(id: number, roleIds: number[]) {
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean }>>(`/admin/admin-users/${id}/roles`, {
|
||||
role_ids: roleIds,
|
||||
})
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean }>>(
|
||||
`/admin/admin-users/${id}/roles`,
|
||||
{
|
||||
role_ids: roleIds,
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function changeAdminPassword(id: number, req: ChangePasswordRequest) {
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean }>>(`/admin/admin-users/${id}/password`, req)
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean }>>(
|
||||
`/admin/admin-users/${id}/password`,
|
||||
req
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -58,9 +58,12 @@ export async function deleteRole(id: number) {
|
||||
}
|
||||
|
||||
export async function assignRolePermissions(roleId: number, permissionIds: number[]) {
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean }>>(`/admin/roles/${roleId}/permissions`, {
|
||||
permission_ids: permissionIds,
|
||||
})
|
||||
const { data } = await apiClient.put<ApiResponse<{ updated: boolean }>>(
|
||||
`/admin/roles/${roleId}/permissions`,
|
||||
{
|
||||
permission_ids: permissionIds,
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
|
||||
@@ -20,14 +20,19 @@ export interface AdminUserItem {
|
||||
}
|
||||
|
||||
export async function fetchAdminUsers(page = 1, pageSize = 20) {
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminUserItem>>>('/admin/users', {
|
||||
params: { page, page_size: pageSize },
|
||||
})
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminUserItem>>>(
|
||||
'/admin/users',
|
||||
{
|
||||
params: { page, page_size: pageSize },
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function freezeAdminUser(id: number, reason: string) {
|
||||
const { data } = await apiClient.post<ApiResponse<AdminUserItem>>(`/admin/users/${id}/freeze`, { reason })
|
||||
const { data } = await apiClient.post<ApiResponse<AdminUserItem>>(`/admin/users/${id}/freeze`, {
|
||||
reason,
|
||||
})
|
||||
return data.data
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,13 @@ export interface AdminWalletLedgerQuery {
|
||||
}
|
||||
|
||||
export async function fetchAdminWalletLedger(query: AdminWalletLedgerQuery = {}) {
|
||||
const params = Object.fromEntries(Object.entries(query).filter(([, value]) => value !== '' && value !== undefined))
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminWalletLedger>>>('/admin/wallet/ledger', { params })
|
||||
const params = Object.fromEntries(
|
||||
Object.entries(query).filter(([, value]) => value !== '' && value !== undefined)
|
||||
)
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<AdminWalletLedger>>>(
|
||||
'/admin/wallet/ledger',
|
||||
{ params }
|
||||
)
|
||||
const result = data.data
|
||||
return {
|
||||
items: Array.isArray(result?.items) ? result.items : [],
|
||||
|
||||
@@ -53,9 +53,12 @@ export async function fetchAdminWithdrawals(params: {
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<WithdrawalDetail>>>('/admin/withdrawals', {
|
||||
params,
|
||||
})
|
||||
const { data } = await apiClient.get<ApiResponse<PaginatedResult<WithdrawalDetail>>>(
|
||||
'/admin/withdrawals',
|
||||
{
|
||||
params,
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -65,11 +68,17 @@ export async function fetchAdminWithdrawal(id: number) {
|
||||
}
|
||||
|
||||
export async function reviewWithdrawal(id: number, req: ReviewWithdrawalRequest) {
|
||||
const { data } = await apiClient.post<ApiResponse<WithdrawalDetail>>(`/admin/withdrawals/${id}/review`, req)
|
||||
const { data } = await apiClient.post<ApiResponse<WithdrawalDetail>>(
|
||||
`/admin/withdrawals/${id}/review`,
|
||||
req
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function confirmPayment(id: number, req: ConfirmPaymentRequest) {
|
||||
const { data } = await apiClient.post<ApiResponse<WithdrawalDetail>>(`/admin/withdrawals/${id}/confirm-payment`, req)
|
||||
const { data } = await apiClient.post<ApiResponse<WithdrawalDetail>>(
|
||||
`/admin/withdrawals/${id}/confirm-payment`,
|
||||
req
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -85,9 +85,12 @@ export async function fetchPaymentConfigs(params?: {
|
||||
page?: number
|
||||
page_size?: number
|
||||
}) {
|
||||
const { data } = await apiClient.get<ApiResponse<PaymentConfigListResponse>>('/admin/payment-configs', {
|
||||
params,
|
||||
})
|
||||
const { data } = await apiClient.get<ApiResponse<PaymentConfigListResponse>>(
|
||||
'/admin/payment-configs',
|
||||
{
|
||||
params,
|
||||
}
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -104,27 +107,39 @@ export async function exportPaymentConfigBackup() {
|
||||
})
|
||||
return {
|
||||
blob: response.data,
|
||||
filename: readDownloadFilename(response.headers['content-disposition']) || fallbackBackupFilename(),
|
||||
filename:
|
||||
readDownloadFilename(response.headers['content-disposition']) || fallbackBackupFilename(),
|
||||
}
|
||||
}
|
||||
|
||||
export async function importPaymentConfigBackup(payload: unknown) {
|
||||
const { data } = await apiClient.post<ApiResponse<PaymentConfigImportResult>>('/admin/payment-configs/import', payload)
|
||||
const { data } = await apiClient.post<ApiResponse<PaymentConfigImportResult>>(
|
||||
'/admin/payment-configs/import',
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function createPaymentConfig(payload: CreatePaymentConfigRequest) {
|
||||
const { data } = await apiClient.post<ApiResponse<PaymentConfig>>('/admin/payment-configs', payload)
|
||||
const { data } = await apiClient.post<ApiResponse<PaymentConfig>>(
|
||||
'/admin/payment-configs',
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function updatePaymentConfig(id: number, payload: UpdatePaymentConfigRequest) {
|
||||
const { data } = await apiClient.put<ApiResponse<PaymentConfig>>(`/admin/payment-configs/${id}`, payload)
|
||||
const { data } = await apiClient.put<ApiResponse<PaymentConfig>>(
|
||||
`/admin/payment-configs/${id}`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
export async function deletePaymentConfig(id: number) {
|
||||
const { data } = await apiClient.delete<ApiResponse<{ message: string }>>(`/admin/payment-configs/${id}`)
|
||||
const { data } = await apiClient.delete<ApiResponse<{ message: string }>>(
|
||||
`/admin/payment-configs/${id}`
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
@@ -136,6 +151,9 @@ function readDownloadFilename(contentDisposition: unknown) {
|
||||
}
|
||||
|
||||
function fallbackBackupFilename() {
|
||||
const stamp = new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d{3}Z$/, '')
|
||||
const stamp = new Date()
|
||||
.toISOString()
|
||||
.replace(/[-:]/g, '')
|
||||
.replace(/\.\d{3}Z$/, '')
|
||||
return `payment-config-backup-${stamp}.json`
|
||||
}
|
||||
|
||||
@@ -12,11 +12,18 @@ export interface SystemConfig {
|
||||
}
|
||||
|
||||
export async function fetchSystemConfigs() {
|
||||
const { data } = await apiClient.get<ApiResponse<{ items: SystemConfig[] }>>('/admin/system-configs')
|
||||
const { data } =
|
||||
await apiClient.get<ApiResponse<{ items: SystemConfig[] }>>('/admin/system-configs')
|
||||
return data.data.items
|
||||
}
|
||||
|
||||
export async function updateSystemConfig(key: string, payload: { value: string; description?: string }) {
|
||||
const { data } = await apiClient.put<ApiResponse<SystemConfig>>(`/admin/system-configs/${key}`, payload)
|
||||
export async function updateSystemConfig(
|
||||
key: string,
|
||||
payload: { value: string; description?: string }
|
||||
) {
|
||||
const { data } = await apiClient.put<ApiResponse<SystemConfig>>(
|
||||
`/admin/system-configs/${key}`,
|
||||
payload
|
||||
)
|
||||
return data.data
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user