This commit is contained in:
qsh
2026-03-17 10:52:52 +08:00
parent 0d99fbd586
commit 883759ffe1
2 changed files with 22 additions and 3 deletions

View File

@@ -99,6 +99,8 @@ export const useUserStore = defineStore('user', () => {
// 退出系统
const logOutAction = () => {
const instance_id = storage.get(constant.instanceId);
const tenant_id = storage.get(constant.tenant_id);
return new Promise((resolve, reject) => {
logout(token.value)
.then(() => {
@@ -107,8 +109,15 @@ export const useUserStore = defineStore('user', () => {
SET_CURRENT_ROLE('');
SET_PERMISSIONS([]);
removeToken();
storage.clean();
storage.clean().then(() => {
if (!isEmpty(instance_id)) {
storage.set(constant.instanceId, instance_id);
}
if (!isEmpty(tenant_id)) {
storage.set(constant.tenant_id, tenant_id);
}
resolve();
});
})
.catch(error => {
reject(error);

View File

@@ -25,7 +25,17 @@ const storage = {
uni.setStorageSync(storageKey, storageData);
},
clean: function () {
uni.removeStorageSync(storageKey);
return new Promise((resolve, reject) => {
uni.removeStorage({
key: storageKey,
success: () => {
resolve();
},
fail: err => {
reject(err);
}
});
});
}
};