@liujitcn/kratos-taro-app-core 0.0.99 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/http.ts +10 -1
package/package.json
CHANGED
package/src/utils/http.ts
CHANGED
|
@@ -268,7 +268,16 @@ const RELOGIN_PROMPT_TIMEOUT = 60_000
|
|
|
268
268
|
/** 提示会话过期并进入携带本次业务回跳标记的登录页。 */
|
|
269
269
|
async function promptRelogin(): Promise<void> {
|
|
270
270
|
// 401 来自旧会话的在途请求而当前已是有效登录态时直接忽略,避免刚登录成功被弹窗打断。
|
|
271
|
-
if (hasValidToken())
|
|
271
|
+
if (hasValidToken()) {
|
|
272
|
+
// 本地令牌未过期但服务端已判定失效时,先强制续签一次;续签成功即静默恢复,
|
|
273
|
+
// 续签失败清空残留登录态后继续弹窗,避免停留在“本地有效”的假登录态。
|
|
274
|
+
try {
|
|
275
|
+
await handleTokenRefresh()
|
|
276
|
+
return
|
|
277
|
+
} catch {
|
|
278
|
+
silentClearAuthData()
|
|
279
|
+
}
|
|
280
|
+
}
|
|
272
281
|
const pages = getCurrentPages()
|
|
273
282
|
// 登录页自身的请求失效只清理残留登录态,避免确认后重载登录页丢失已填写的表单。
|
|
274
283
|
if (pages[pages.length - 1]?.route === 'pages/login/login') {
|