File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @alita/plugins ' : patch
3
+ ---
4
+
5
+ closeAllTabs can be used to close all keepalive tabs
Original file line number Diff line number Diff line change @@ -94,6 +94,9 @@ export function closeTab(path: string) {
94
94
path
95
95
}});
96
96
}
97
+ export function closeAllTabs() {
98
+ keepaliveEmitter.emit({type:'closeAllTabs'});
99
+ }
97
100
` ,
98
101
} ) ;
99
102
// index.ts for export
@@ -102,7 +105,7 @@ export function closeTab(path: string) {
102
105
path : `${ DIR_NAME } /index.tsx` ,
103
106
content : `
104
107
export { KeepAliveContext,useKeepOutlets } from './context';
105
- export { dropByCacheKey, closeTab } from './support';
108
+ export { dropByCacheKey, closeTab, closeAllTabs } from './support';
106
109
` ,
107
110
} ) ;
108
111
} ) ;
Original file line number Diff line number Diff line change @@ -198,6 +198,12 @@ export function useKeepOutlets() {
198
198
navigate(`${ pathname} ${ search} ${ hash} `);
199
199
}
200
200
};
201
+ const closeAllTabs = () => {
202
+ const pathList = Object.keys(keepElements.current);
203
+ pathList.forEach(targetKey => {
204
+ dropByCacheKey(targetKey?.toLowerCase());
205
+ } );
206
+ };
201
207
const navigate = useNavigate();
202
208
{ {#isPluginModelEnable} }
203
209
const localConfig = React.useMemo(() => {
@@ -275,6 +281,9 @@ export function useKeepOutlets() {
275
281
case 'closeTab':
276
282
closeTab(payload?.path?.toLowerCase());
277
283
break;
284
+ case 'closeAllTabs':
285
+ closeAllTabs();
286
+ break;
278
287
{ {/hasTabsLayout} }
279
288
default:
280
289
break;
You can’t perform that action at this time.
0 commit comments