no message
This commit is contained in:
parent
4ef5949f5b
commit
f80dbbadfe
@ -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 }
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user