修改
This commit is contained in:
+20
-6
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user