统一前后端代码格式化配置

This commit is contained in:
yml2213
2026-08-16 17:27:12 +08:00
parent 8705f6a6a1
commit 5c7c3e14e3
278 changed files with 6386 additions and 5500 deletions
+7 -24
View File
@@ -37,13 +37,9 @@ http.interceptors.response.use(
},
(error) => {
const responseMessage =
typeof error?.response?.data?.msg === 'string'
? error.response.data.msg.trim()
: ''
typeof error?.response?.data?.msg === 'string' ? error.response.data.msg.trim() : ''
const fallbackMessage = resolveFallbackHttpMessage(error)
const normalizedError = new Error(
responseMessage || fallbackMessage,
) as Error & {
const normalizedError = new Error(responseMessage || fallbackMessage) as Error & {
errorCode?: string
status?: number
}
@@ -56,10 +52,7 @@ http.interceptors.response.use(
normalizedError.status = error.response.status
}
if (
error?.config?.url &&
String(error.config.url).startsWith('/api/v1/admin')
) {
if (error?.config?.url && String(error.config.url).startsWith('/api/v1/admin')) {
const status = Number(error?.response?.status || 0)
const errorCode = String(error?.response?.data?.errorCode || '').trim()
@@ -75,10 +68,7 @@ http.interceptors.response.use(
}
}
if (
error?.config?.url &&
String(error.config.url).startsWith('/api/v1/worker')
) {
if (error?.config?.url && String(error.config.url).startsWith('/api/v1/worker')) {
const status = Number(error?.response?.status || 0)
const errorCode = String(error?.response?.data?.errorCode || '').trim()
@@ -126,13 +116,8 @@ function resolveFallbackHttpMessage(error: unknown) {
return '网络连接错误'
}
if (
typeof (error as { response?: { statusText?: string } })?.response
?.statusText === 'string'
) {
return String(
(error as { response: { statusText: string } }).response.statusText,
).trim()
if (typeof (error as { response?: { statusText?: string } })?.response?.statusText === 'string') {
return String((error as { response: { statusText: string } }).response.statusText).trim()
}
return '接口请求失败'
@@ -158,9 +143,7 @@ function shouldClearWorkerSession(errorCode: string) {
].includes(errorCode)
}
function request<T>(
config: Parameters<typeof http.request<ApiEnvelope<T>>>[0],
) {
function request<T>(config: Parameters<typeof http.request<ApiEnvelope<T>>>[0]) {
return http.request<ApiEnvelope<T>, ApiEnvelope<T>>(config)
}