mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(utils): support replaceTab. (#713)
This commit is contained in:
@ -160,6 +160,25 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
|
||||
update();
|
||||
}
|
||||
|
||||
const { routerPushByKey } = useRouterPush();
|
||||
/**
|
||||
* Replace tab
|
||||
*
|
||||
* @param key Route key
|
||||
* @param options Router push options
|
||||
*/
|
||||
async function replaceTab(key: RouteKey, options?: App.Global.RouterPushOptions) {
|
||||
const oldTabId = activeTabId.value;
|
||||
|
||||
// push new route
|
||||
await routerPushByKey(key, options);
|
||||
|
||||
// remove old tab (exclude fixed tab)
|
||||
if (!isTabRetain(oldTabId)) {
|
||||
await removeTab(oldTabId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Switch route by tab
|
||||
*
|
||||
@ -282,6 +301,7 @@ export const useTabStore = defineStore(SetupStoreId.Tab, () => {
|
||||
removeTab,
|
||||
removeActiveTab,
|
||||
removeTabByRouteName,
|
||||
replaceTab,
|
||||
clearTabs,
|
||||
clearLeftTabs,
|
||||
clearRightTabs,
|
||||
|
Reference in New Issue
Block a user