fix(app): 解决页面跳转冲突和登录重定向问题

- 在App.vue中延迟引导页跳转以避免首页未就绪导致的timeout错误
- 添加401跳登录页防重锁机制,防止多个接口同时返回401时的并发冲突
- 移除index.vue中的重复跳转逻辑,统一由App.vue处理首次启动跳转
- 优化record.vue中的品牌选择界面,添加"更多"展开功能和视觉改进
- 改进用量和度数输入框的样式和交互体验
This commit is contained in:
cg
2026-08-16 22:38:45 +08:00
parent 019262289c
commit 9fa22d5d1b
5 changed files with 111 additions and 20 deletions
+17 -1
View File
@@ -9,6 +9,22 @@ import UniAppWebSocket from './uni-websocket'
// ==========================================
export const API_HOST = 'https://dev.wash-painting.cn'
// ==========================================
// 401 跳登录页防重锁:token 失效时多个接口会同时返回 401,
// 各自 reLaunch 会并发冲突导致 reLaunch:fail timeout,只放行第一次
// ==========================================
let authRedirectLock = false
function redirectToLogin() {
if (authRedirectLock) return
authRedirectLock = true
setTimeout(() => { authRedirectLock = false }, 3000)
const pages = getCurrentPages()
const current = pages.length ? pages[pages.length - 1].route : ''
// 已在登录页则不重复跳转
if (current === 'pages/login/login') return
uni.reLaunch({ url: '/pages/login/login', fail: () => {} })
}
// ==========================================
// HTTP 请求函数(供 SDK 内部调用)
// 参考 goodBooth 项目的 fetchsomething
@@ -49,7 +65,7 @@ function httpRequest(url, params) {
uni.removeStorageSync('refresh_token')
uni.removeStorageSync('is_logged_in')
if (!silent) {
uni.reLaunch({ url: '/pages/login/login' })
redirectToLogin()
uni.showToast({ title: '登录已过期,请重新登录', icon: 'none', duration: 2500 })
}
reject({ msg: '登录已过期,请重新登录', code })