| | |
| | | |
| | | onLaunch(() => { |
| | | console.log("App Launch"); |
| | | |
| | | // ✅ 同步设置认证挂起标记,比任何页面 onLoad 都早 |
| | | uni.__authPending = true; |
| | | |
| | | const launchOptions = uni.getLaunchOptionsSync(); |
| | | const currentPage = launchOptions.path || ""; |
| | | const query = launchOptions.query || {}; |
| | |
| | | |
| | | try { |
| | | const current = await uni.$uapi.get("/getInfo"); |
| | | uni.__authPending = false; |
| | | if (current && current.user) { |
| | | userStore.setUserInfo(current.user); |
| | | if (current.roles) userStore.setroleKey(current.roles); |
| | |
| | | } |
| | | } catch (error) { |
| | | console.error("初始化失败:", error); |
| | | uni.__authPending = false; |
| | | userStore.clearUser(); |
| | | if (!isPageInWhiteList(currentPage)) { |
| | | uni.redirectTo({ url: "/pages/login/Login" }); |