fix: formate code and test money
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m8s
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 5m8s
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export type ApiErrorKind = 'auth' | 'forbidden' | 'validation' | 'conflict' | 'timeout' | 'server' | 'unknown'
|
||||
export type ApiErrorKind =
|
||||
| 'auth'
|
||||
| 'forbidden'
|
||||
| 'validation'
|
||||
| 'conflict'
|
||||
| 'timeout'
|
||||
| 'server'
|
||||
| 'unknown'
|
||||
|
||||
export interface NormalizedApiError {
|
||||
kind: ApiErrorKind
|
||||
@@ -20,12 +27,59 @@ export const normalizeApiError = (error: unknown): NormalizedApiError => {
|
||||
const timeout = axios.isAxiosError(error) && error.code === 'ECONNABORTED'
|
||||
|
||||
if (timeout) {
|
||||
return { kind: 'timeout', status, code, message: '请求超时,结果可能未知,请刷新确认', unknownResult: true }
|
||||
return {
|
||||
kind: 'timeout',
|
||||
status,
|
||||
code,
|
||||
message: '请求超时,结果可能未知,请刷新确认',
|
||||
unknownResult: true
|
||||
}
|
||||
}
|
||||
if (status === 401 || code === 401)
|
||||
return {
|
||||
kind: 'auth',
|
||||
status,
|
||||
code,
|
||||
message: '登录状态已失效,请重新登录',
|
||||
unknownResult: false
|
||||
}
|
||||
if (status === 403)
|
||||
return {
|
||||
kind: 'forbidden',
|
||||
status,
|
||||
code,
|
||||
message: '没有执行此操作的权限',
|
||||
unknownResult: false
|
||||
}
|
||||
if (status === 400)
|
||||
return {
|
||||
kind: 'validation',
|
||||
status,
|
||||
code,
|
||||
message: backendMessage || '请求参数或业务条件不符合要求',
|
||||
unknownResult: false
|
||||
}
|
||||
if (status === 409)
|
||||
return {
|
||||
kind: 'conflict',
|
||||
status,
|
||||
code,
|
||||
message: backendMessage || '数据已发生变化,请刷新后重试',
|
||||
unknownResult: false
|
||||
}
|
||||
if (status && status >= 500)
|
||||
return {
|
||||
kind: 'server',
|
||||
status,
|
||||
code,
|
||||
message: '服务器处理失败,请稍后重试',
|
||||
unknownResult: false
|
||||
}
|
||||
return {
|
||||
kind: 'unknown',
|
||||
status,
|
||||
code,
|
||||
message: backendMessage || '操作失败,请稍后重试',
|
||||
unknownResult: false
|
||||
}
|
||||
if (status === 401 || code === 401) return { kind: 'auth', status, code, message: '登录状态已失效,请重新登录', unknownResult: false }
|
||||
if (status === 403) return { kind: 'forbidden', status, code, message: '没有执行此操作的权限', unknownResult: false }
|
||||
if (status === 400) return { kind: 'validation', status, code, message: backendMessage || '请求参数或业务条件不符合要求', unknownResult: false }
|
||||
if (status === 409) return { kind: 'conflict', status, code, message: backendMessage || '数据已发生变化,请刷新后重试', unknownResult: false }
|
||||
if (status && status >= 500) return { kind: 'server', status, code, message: '服务器处理失败,请稍后重试', unknownResult: false }
|
||||
return { kind: 'unknown', status, code, message: backendMessage || '操作失败,请稍后重试', unknownResult: false }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@ export const getApprovalStatusText = (summary: ApprovalSummary): string => {
|
||||
summary.approval_provider === 'wecom' ||
|
||||
summary.approval_instance_id
|
||||
) {
|
||||
return summary.approval_status_name || approvalStatusNames[Number(summary.approval_status)] || '-'
|
||||
return (
|
||||
summary.approval_status_name || approvalStatusNames[Number(summary.approval_status)] || '-'
|
||||
)
|
||||
}
|
||||
return '-'
|
||||
}
|
||||
@@ -27,7 +29,8 @@ export const getCurrentApproverSummaryText = (summary: ApprovalSummary): string
|
||||
summary.approval_source !== 'wecom' &&
|
||||
summary.approval_provider !== 'wecom' &&
|
||||
!summary.approval_instance_id
|
||||
) return '-'
|
||||
)
|
||||
return '-'
|
||||
return summary.current_approver_summary || '-'
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,10 @@ export const getPaymentMerchantId = (
|
||||
}
|
||||
|
||||
export const getPaymentNotifyUrl = (
|
||||
config: Pick<PaymentSettings, 'provider_type' | 'wx_notify_url' | 'fy_notify_url' | 'ali_notify_url'>
|
||||
config: Pick<
|
||||
PaymentSettings,
|
||||
'provider_type' | 'wx_notify_url' | 'fy_notify_url' | 'ali_notify_url'
|
||||
>
|
||||
): string => {
|
||||
if (config.provider_type === 'wechat' || config.provider_type === 'wechat_v2') {
|
||||
return config.wx_notify_url || '-'
|
||||
|
||||
Reference in New Issue
Block a user