feat: 优化账户切换时的页面状态一致性,增加登录回跳校验和课程阅读新逻辑
- 增加账户状态监听定时器,页面切换时自动校验账户归属,避免跨账户操作 - 新增登录回跳路径校验函数,限制仅允许指定页面回跳,防止非法跳转 - 课程页改为整篇连续阅读,底部仅一次标记已读,兼容历史记录 - 完善助手、对比页、资料填写页等多处的账户状态校验逻辑,防止错版数据提交 - 优化账户资料请求逻辑,增加版本校验,避免旧请求覆盖新数据
This commit is contained in:
@@ -19,8 +19,20 @@
|
||||
import { getAccountProfile, maskPhone } from '@/packages/account/services/account.uts'
|
||||
const { pageStyle, contentStyle, bottomStyle } = usePageLayout()
|
||||
const phone = ref('')
|
||||
onShow(() => { if (getSession() == null) { uni.redirectTo({ url: '/packages/account/login/login' }); return }; phone.value = getAccountProfile().phone })
|
||||
const go = (path: string) => { uni.navigateTo({ url: '/packages/account/' + path }) }
|
||||
let ownerToken = ''; let ownerId = ''; let pageVisible = false; let accountTimer = 0
|
||||
const stopAccountTimer = () => { clearInterval(accountTimer); accountTimer = 0 }
|
||||
const sameOwner = (): boolean => {
|
||||
if (!pageVisible) return false
|
||||
const session = getSession()
|
||||
if (ownerToken.length > 0 && session?.getString('token') == ownerToken && session?.getString('userId') == ownerId) return true
|
||||
phone.value = ''; stopAccountTimer()
|
||||
uni.redirectTo({ url: session == null ? '/packages/account/login/login' : '/packages/account/profile/profile' })
|
||||
return false
|
||||
}
|
||||
onShow(() => { pageVisible = true; const session = getSession(); ownerToken = session?.getString('token') ?? ''; ownerId = session?.getString('userId') ?? ''; stopAccountTimer(); if (!sameOwner()) return; phone.value = getAccountProfile().phone; accountTimer = setInterval(() => { sameOwner() }, 1000) })
|
||||
onHide(() => { pageVisible = false; stopAccountTimer(); phone.value = '' })
|
||||
onUnload(() => { pageVisible = false; stopAccountTimer(); phone.value = '' })
|
||||
const go = (path: string) => { if (sameOwner()) uni.navigateTo({ url: '/packages/account/' + path }) }
|
||||
</script>
|
||||
<style>
|
||||
.security-content { padding: 30rpx; }
|
||||
|
||||
Reference in New Issue
Block a user