query 增加了自处理异常
Publish to npm / publish (push) Failing after 8s

This commit is contained in:
2026-05-04 02:27:43 +08:00
parent 39626de073
commit e0754ad635
2 changed files with 76 additions and 72 deletions
+4 -1
View File
@@ -237,7 +237,8 @@ export class SimApiCore {
uri: string,
params: any = {},
endpointKey?: string,
extraHeaders?: Record<string, string>
extraHeaders?: Record<string, string>,
selfHandleError: boolean = false
): Promise<SimApiBaseResponse<T>> {
const headers: Record<string, string> = {...extraHeaders, ...{}}
const queryId = this.genS4()
@@ -271,11 +272,13 @@ export class SimApiCore {
const processedData = this.api.responseCallback.success(respData) as SimApiBaseResponse<T>
// 业务回调处理
if (!selfHandleError) {
if (this.api.businessCallback.hasOwnProperty(processedData.code)) {
this.api.businessCallback[processedData.code](processedData)
} else if (this.api.businessCallback['common'] && processedData.code !== 200) {
this.api.businessCallback['common'](processedData)
}
}
// code != 200 时抛出业务错误
if (processedData.code !== 200) {
+3 -2
View File
@@ -73,9 +73,10 @@ export const useSimApi = defineStore('simapi', {
uri: string,
params?: any,
endpointKey?: string,
extraHeaders?: Record<string, string>
extraHeaders?: Record<string, string>,
selfHandleError: boolean = false
): Promise<SimApiBaseResponse<T>> {
return this._core.query<T>(uri, params, endpointKey, extraHeaders)
return this._core.query<T>(uri, params, endpointKey, extraHeaders, selfHandleError)
},
getEndpoint(name?: string): string {