feat: 优化租户切换组件,支持租户切换并清除tab缓存

This commit is contained in:
AN
2025-05-18 20:10:56 +08:00
parent f6320260c1
commit 62da7e41be
3 changed files with 15 additions and 9 deletions

View File

@ -3,7 +3,7 @@ import { computed, onMounted, ref } from 'vue';
import type { SelectOption } from 'naive-ui';
import { useLoading } from '@sa/hooks';
import { fetchTenantList } from '@/service/api';
import { fetchClearTenant } from '@/service/api/system/tenant';
import { fetchChangeTenant, fetchClearTenant } from '@/service/api/system/tenant';
import { useAppStore } from '@/store/modules/app';
import { useTabStore } from '@/store/modules/tab';
import { useAuthStore } from '@/store/modules/auth';
@ -45,7 +45,7 @@ const showTenantSelect = computed<boolean>(() => {
async function closeAndRefresh(msg: string, val: CommonType.IdType = '') {
lastSelected.value = val;
window.$message?.success(msg);
clearTabs();
clearTabs([], true);
toHome();
appStore.reloadPage(500);
}
@ -57,6 +57,7 @@ async function handleChangeTenant(_tenantId: CommonType.IdType) {
if (lastSelected.value === _tenantId) {
return;
}
await fetchChangeTenant(_tenantId);
closeAndRefresh('切换租户成功', _tenantId);
}