mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-26 16:46:19 +08:00
feat: support to refresh the tab page by route name (#6153)
Co-authored-by: anyup <anyupxing@163.com>
This commit is contained in:
@@ -334,7 +334,13 @@ export const useTabbarStore = defineStore('core-tabbar', {
|
||||
/**
|
||||
* 刷新标签页
|
||||
*/
|
||||
async refresh(router: Router) {
|
||||
async refresh(router: Router | string) {
|
||||
// 如果是Router路由,那么就根据当前路由刷新
|
||||
// 如果是string字符串,为路由名称,则定向刷新指定标签页,不能是当前路由名称,否则不会刷新
|
||||
if (typeof router === 'string') {
|
||||
return await this.refreshByName(router);
|
||||
}
|
||||
|
||||
const { currentRoute } = router;
|
||||
const { name } = currentRoute.value;
|
||||
|
||||
@@ -349,6 +355,15 @@ export const useTabbarStore = defineStore('core-tabbar', {
|
||||
stopProgress();
|
||||
},
|
||||
|
||||
/**
|
||||
* 根据路由名称刷新指定标签页
|
||||
*/
|
||||
async refreshByName(name: string) {
|
||||
this.excludeCachedTabs.add(name);
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
this.excludeCachedTabs.delete(name);
|
||||
},
|
||||
|
||||
/**
|
||||
* @zh_CN 重置标签页标题
|
||||
*/
|
||||
|
Reference in New Issue
Block a user