From f80dbbadfeeaac919bedace51dbcb5f33cd0583b Mon Sep 17 00:00:00 2001 From: wangdongbo <> Date: Sun, 20 Sep 2026 16:33:10 +0800 Subject: [PATCH] no message --- store/account.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/store/account.js b/store/account.js index 9203c64..b727525 100644 --- a/store/account.js +++ b/store/account.js @@ -18,11 +18,16 @@ export default defineStore("accountStore", () => { const corpId = env.MP_CORP_ID; // 从缓存中恢复数据 - const account = ref(cache.get(CACHE_KEYS.ACCOUNT, null)); + const cachedAccount = cache.get(CACHE_KEYS.ACCOUNT, null); + if (cachedAccount && cachedAccount.corpId !== corpId) { + cache.remove(CACHE_KEYS.ACCOUNT); + cache.remove(CACHE_KEYS.OPENID); + } + const account = ref(cachedAccount?.corpId === corpId ? cachedAccount : null); const loginPromise = ref(null); // IM 相关 - const openid = ref(cache.get(CACHE_KEYS.OPENID, "")); + const openid = ref(account.value?.openid || cache.get(CACHE_KEYS.OPENID, "")); const isIMInitialized = ref(false); // 医生信息 - 不做缓冲处理,每次都重新获取 const doctorInfo = ref(null); @@ -60,7 +65,7 @@ export default defineStore("accountStore", () => { // uni.redirectTo({ url: target }); // return; // } - account.value = res.data; + account.value = { ...res.data, corpId }; openid.value = res.data.openid; // 持久化账户信息 // cache.set(CACHE_KEYS.ACCOUNT, res.data); @@ -69,7 +74,7 @@ export default defineStore("accountStore", () => { // 登录成功后初始化腾讯IM await getDoctorInfo({ openid: openid.value }); await initIMAfterLogin(); - return res.data + return account.value } } toast('登录失败,请重新登录'); @@ -176,4 +181,4 @@ export default defineStore("accountStore", () => { }) return { account, openid, isIMInitialized, doctorInfo, login, getDoctorInfo, initIMAfterLogin, logout } -}) \ No newline at end of file +})