diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 4de4ef3..9cf56c3 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -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(); - resolve(); + 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); diff --git a/src/utils/storage.js b/src/utils/storage.js index fd9cef0..1b2ebd3 100644 --- a/src/utils/storage.js +++ b/src/utils/storage.js @@ -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); + } + }); + }); } };