perf: scan页置顶消除登录页闪烁 — 已登录用户零跳转直接渲染

This commit is contained in:
2026-08-07 17:05:00 +08:00
parent 0fcc607f17
commit d4f6266fcc
2 changed files with 10 additions and 13 deletions

View File

@ -5,17 +5,14 @@ export default {
onLaunch() {
console.log("生产流转 T1.0.2 启动");
// 🚦 统一路由守卫:根据登录态重定向到正确页面
// 🚦 路由守卫:首页已是 scan,未登录才跳登录页(零闪烁)
const token = uni.getStorageSync("access_token") || uni.getStorageSync("refresh_token");
const user = uni.getStorageSync("user");
if (token && user) {
// 已登录 → 直接进扫码干活页
uni.reLaunch({ url: "/pages/scan/index" });
} else {
// 未登录 → 去登录页
if (!token || !user) {
uni.reLaunch({ url: "/pages/login/login" });
}
// 已登录 → 原地渲染 scan 页,不需任何跳转
// 🚀 OTA 热更新检测(仅 App 端生效)
// #ifdef APP-PLUS

View File

@ -1,12 +1,5 @@
{
"pages": [
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
},
{
"path": "pages/scan/index",
"style": {
@ -15,6 +8,13 @@
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "登录",
"navigationStyle": "custom"
}
},
{
"path": "pages/scan/records",
"style": {