@liujitcn/kratos-uni-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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/utils/http.ts +11 -1
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "type": "git",
8
8
  "url": "git@github.com:liujitcn/kratos-admin.git"
9
9
  },
10
- "version": "0.0.99",
10
+ "version": "0.1.0",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist",
package/src/utils/http.ts CHANGED
@@ -405,7 +405,14 @@ const RELOGIN_PROMPT_TIMEOUT = 60_000
405
405
  async function promptRelogin() {
406
406
  // 401 来自旧会话的在途请求而当前已是有效登录态时直接忽略,避免刚登录成功被弹窗打断。
407
407
  if (hasValidToken()) {
408
- return
408
+ // 本地令牌未过期但服务端已判定失效时,先强制续签一次;续签成功即静默恢复,
409
+ // 续签失败清空残留登录态后继续弹窗,避免停留在“本地有效”的假登录态。
410
+ try {
411
+ await handleTokenRefresh()
412
+ return
413
+ } catch {
414
+ silentClearAuthData()
415
+ }
409
416
  }
410
417
  const pages = getCurrentPages()
411
418
  if (pages[pages.length - 1]?.route === 'pages/login/login') {
@@ -435,6 +442,9 @@ async function promptRelogin() {
435
442
  ])
436
443
 
437
444
  if (!modalRes?.confirm) {
445
+ // 用户关闭提示或超时未确认时也要完成登出,避免残留“本地有效”的假登录态
446
+ // 导致后续请求全部 401 被静默吞掉、界面看起来像按钮失灵。
447
+ await clearUserData()
438
448
  return
439
449
  }
440
450