fix: some
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 2m16s

This commit is contained in:
luo
2026-10-14 13:40:55 +08:00
parent 131823ca12
commit f7cb28febf
6 changed files with 262 additions and 20 deletions

View File

@@ -12,6 +12,8 @@ const emptyPhoneState = () => ({
const savedPhoneState = uni.getStorageSync(PHONE_STATE_KEY);
const token = uni.getStorageSync('token') || '';
const identifier = uni.getStorageSync('identifier') || '';
const isOAuthCallback = typeof window !== 'undefined' && typeof sessionStorage !== 'undefined' &&
!!new URLSearchParams(window.location.search).get('code') && !!sessionStorage.getItem('assetToken');
const phoneState = savedPhoneState?.token === token && savedPhoneState?.identifier === identifier && token
? {
customerPhone: typeof savedPhoneState.customerPhone === 'string' ? savedPhoneState.customerPhone : null,
@@ -25,6 +27,7 @@ const state = reactive({
token,
assetToken: '',
identifier,
loginPending: isOAuthCallback,
...phoneState,
phoneRevision: 0,
isDevice: false,
@@ -36,6 +39,7 @@ const state = reactive({
});
export const useUserStore = () => {
const setLoginPending = (pending) => { state.loginPending = pending === true; };
const persistPhoneState = () => {
uni.setStorageSync(PHONE_STATE_KEY, {
token: state.token, identifier: state.identifier,
@@ -111,6 +115,7 @@ export const useUserStore = () => {
const clearUser = () => {
resetContext();
state.token = '';
state.loginPending = false;
state.assetToken = '';
state.identifier = '';
state.isDevice = false;
@@ -124,6 +129,7 @@ export const useUserStore = () => {
return {
state,
setToken,
setLoginPending,
setAssetToken,
setIdentifier,
setIsDevice,