This commit is contained in:
浅念
2026-01-13 15:10:33 +08:00
parent f768835f15
commit 56f09c263f
19 changed files with 3253 additions and 910 deletions
+20 -6
View File
@@ -37,6 +37,16 @@
onLoad(options) {
this.fsappid = options.appid || '';
uni.setStorageSync('fsappid', this.fsappid);
// 保存登录成功后的回跳地址(支持 redirect/r)
const redirect = options.redirect || options.r || ''
if (redirect) {
// options 里可能已被 decode,也可能没有,保险起见 try 一下
try {
uni.setStorageSync('post_login_redirect', decodeURIComponent(redirect))
} catch (e) {
uni.setStorageSync('post_login_redirect', redirect)
}
}
this._startedAt = Date.now()
this.startDots()
this.silentAuth()
@@ -65,8 +75,8 @@
const token = uni.getStorageSync('token')
if (token) {
this.title = '已登录'
this.desc = '正在进入首页'
return this.goHomeSmooth()
this.desc = '正在进入页面'
return this.goRedirectSmooth()
}
// 2) 获取飞书授权跳转地址(静默授权/免登)
@@ -98,13 +108,17 @@
uni.showToast({ title: err?.message || '登录失败', icon: 'none' })
}
},
goHomeSmooth() {
getRedirectTarget() {
return uni.getStorageSync('post_login_redirect') || '/pages/index/index'
},
goRedirectSmooth() {
const elapsed = Date.now() - this._startedAt
const wait = Math.max(0, this.minStayMs - elapsed)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
})
const target = this.getRedirectTarget()
// 用完即清,避免后续误跳
uni.removeStorageSync('post_login_redirect')
uni.reLaunch({ url: target })
}, wait)
},
sleep(ms) {