修改退出登录没带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 SimApiVersion: string;
declare const AppVersion: string; declare const AppVersion: string;
// ── Helper: Fetch with Timeout ──────────────────────────────────────── // ── Helper: Fetch with Timeout ────────────────────────────────────────
function fetchWithTimeout( function fetchWithTimeout(
@@ -89,11 +90,13 @@ export class SimApiCore {
defaultEndpoint: 'default', defaultEndpoint: 'default',
businessCallback: { businessCallback: {
401: () => localStorage.removeItem(this.auth.token_name), 401: () => localStorage.removeItem(this.auth.token_name),
common: () => {}, common: () => {
},
}, },
responseCallback: { responseCallback: {
success: (response: any) => response, success: (response: any) => response,
error: (_err: any) => {}, error: (_err: any) => {
},
}, },
timeout: 10000, timeout: 10000,
} }
@@ -307,16 +310,17 @@ export class SimApiCore {
} }
async logout(url?: string | null): Promise<any> { async logout(url?: string | null): Promise<any> {
this.removeToken()
if (url !== null) { if (url !== null) {
return this.query(url ?? this.auth.logout_url).catch(() => true) return this.query(url ?? this.auth.logout_url).catch(() => true)
} }
this.removeToken()
return true return true
} }
async checkLogin(url?: string | null): Promise<void> { async checkLogin(url?: string | null): Promise<void> {
if (url !== null) { 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()) { } else if (this.getToken()) {
this.api.businessCallback[401]?.(null) this.api.businessCallback[401]?.(null)
} }