mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat: 优化租户切换组件,支持租户切换并清除tab缓存
This commit is contained in:
@ -129,13 +129,23 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
|
||||
*
|
||||
* @param excludes Exclude tab ids
|
||||
*/
|
||||
async function clearTabs(excludes: string[] = []) {
|
||||
async function clearTabs(excludes: string[] = [], clearCache: boolean = false) {
|
||||
const remainTabIds = [...getFixedTabIds(tabs.value), ...excludes];
|
||||
const removedTabsIds = tabs.value.map(tab => tab.id).filter(id => !remainTabIds.includes(id));
|
||||
|
||||
const isRemoveActiveTab = removedTabsIds.includes(activeTabId.value);
|
||||
const updatedTabs = filterTabsByIds(removedTabsIds, tabs.value);
|
||||
|
||||
if (clearCache) {
|
||||
// 清除缓存
|
||||
removedTabsIds.forEach(tabId => {
|
||||
const tab = tabs.value.find(t => t.id === tabId);
|
||||
if (tab) {
|
||||
routeStore.resetRouteCache(tab.routeKey);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function update() {
|
||||
tabs.value = updatedTabs;
|
||||
}
|
||||
|
Reference in New Issue
Block a user