no message

This commit is contained in:
wangdongbo 2026-09-20 16:33:10 +08:00
parent 4ef5949f5b
commit f80dbbadfe

View File

@ -18,11 +18,16 @@ export default defineStore("accountStore", () => {
const corpId = env.MP_CORP_ID; 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); const loginPromise = ref(null);
// IM 相关 // 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 isIMInitialized = ref(false);
// 医生信息 - 不做缓冲处理,每次都重新获取 // 医生信息 - 不做缓冲处理,每次都重新获取
const doctorInfo = ref(null); const doctorInfo = ref(null);
@ -60,7 +65,7 @@ export default defineStore("accountStore", () => {
// uni.redirectTo({ url: target }); // uni.redirectTo({ url: target });
// return; // return;
// } // }
account.value = res.data; account.value = { ...res.data, corpId };
openid.value = res.data.openid; openid.value = res.data.openid;
// 持久化账户信息 // 持久化账户信息
// cache.set(CACHE_KEYS.ACCOUNT, res.data); // cache.set(CACHE_KEYS.ACCOUNT, res.data);
@ -69,7 +74,7 @@ export default defineStore("accountStore", () => {
// 登录成功后初始化腾讯IM // 登录成功后初始化腾讯IM
await getDoctorInfo({ openid: openid.value }); await getDoctorInfo({ openid: openid.value });
await initIMAfterLogin(); await initIMAfterLogin();
return res.data return account.value
} }
} }
toast('登录失败,请重新登录'); toast('登录失败,请重新登录');
@ -176,4 +181,4 @@ export default defineStore("accountStore", () => {
}) })
return { account, openid, isIMInitialized, doctorInfo, login, getDoctorInfo, initIMAfterLogin, logout } return { account, openid, isIMInitialized, doctorInfo, login, getDoctorInfo, initIMAfterLogin, logout }
}) })