Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin into dev
commit
99c848a39d
|
@ -22,7 +22,7 @@ function setupCommonGuard(router: Router) {
|
|||
// 记录已经加载的页面
|
||||
const loadedPaths = new Set<string>();
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
router.beforeEach((to) => {
|
||||
to.meta.loaded = loadedPaths.has(to.path);
|
||||
|
||||
// 页面加载进度条
|
||||
|
|
|
@ -22,7 +22,7 @@ function setupCommonGuard(router: Router) {
|
|||
// 记录已经加载的页面
|
||||
const loadedPaths = new Set<string>();
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
router.beforeEach((to) => {
|
||||
to.meta.loaded = loadedPaths.has(to.path);
|
||||
|
||||
// 页面加载进度条
|
||||
|
|
|
@ -21,7 +21,7 @@ function setupCommonGuard(router: Router) {
|
|||
// 记录已经加载的页面
|
||||
const loadedPaths = new Set<string>();
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
router.beforeEach((to) => {
|
||||
to.meta.loaded = loadedPaths.has(to.path);
|
||||
|
||||
// 页面加载进度条
|
||||
|
|
|
@ -41,8 +41,8 @@ export function useTabs() {
|
|||
await tabbarStore.toggleTabPin(tab || route);
|
||||
}
|
||||
|
||||
async function refreshTab() {
|
||||
await tabbarStore.refresh(router);
|
||||
async function refreshTab(name?: string) {
|
||||
await tabbarStore.refresh(name || router);
|
||||
}
|
||||
|
||||
async function openTabInNewWindow(tab?: RouteLocationNormalized) {
|
||||
|
|
|
@ -158,7 +158,7 @@ export function useTabbar() {
|
|||
},
|
||||
{
|
||||
disabled: disabledRefresh,
|
||||
handler: refreshTab,
|
||||
handler: () => refreshTab(),
|
||||
icon: RotateCw,
|
||||
key: 'reload',
|
||||
text: $t('preferences.tabbar.contextMenu.reload'),
|
||||
|
|
|
@ -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 重置标签页标题
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,7 @@ function setupCommonGuard(router: Router) {
|
|||
// 记录已经加载的页面
|
||||
const loadedPaths = new Set<string>();
|
||||
|
||||
router.beforeEach(async (to) => {
|
||||
router.beforeEach((to) => {
|
||||
to.meta.loaded = loadedPaths.has(to.path);
|
||||
|
||||
// 页面加载进度条
|
||||
|
|
Loading…
Reference in New Issue