修改退出登录没带TOKEn
Publish to npm / publish (push) Failing after 14s

This commit is contained in:
2026-05-03 23:11:55 +08:00
parent 88be4210aa
commit 13c836b4ab
+8 -4
View File
@@ -28,6 +28,7 @@ export type {
declare const SimApiVersion: string;
declare const AppVersion: string;
// ── Helper: Fetch with Timeout ────────────────────────────────────────
function fetchWithTimeout(
@@ -89,11 +90,13 @@ export class SimApiCore {
defaultEndpoint: 'default',
businessCallback: {
401: () => localStorage.removeItem(this.auth.token_name),
common: () => {},
common: () => {
},
},
responseCallback: {
success: (response: any) => response,
error: (_err: any) => {},
error: (_err: any) => {
},
},
timeout: 10000,
}
@@ -307,16 +310,17 @@ export class SimApiCore {
}
async logout(url?: string | null): Promise<any> {
this.removeToken()
if (url !== null) {
return this.query(url ?? this.auth.logout_url).catch(() => true)
}
this.removeToken()
return true
}
async checkLogin(url?: string | null): Promise<void> {
if (url !== null) {
await this.query(url ?? this.auth.check_url).catch(() => {})
await this.query(url ?? this.auth.check_url).catch(() => {
})
} else if (this.getToken()) {
this.api.businessCallback[401]?.(null)
}