pull/104/MERGE
xingyu4j 2025-05-14 11:54:29 +08:00
commit 99c848a39d
7 changed files with 23 additions and 8 deletions

View File

@ -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);
// 页面加载进度条

View File

@ -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);
// 页面加载进度条

View File

@ -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);
// 页面加载进度条

View File

@ -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) {

View File

@ -158,7 +158,7 @@ export function useTabbar() {
},
{
disabled: disabledRefresh,
handler: refreshTab,
handler: () => refreshTab(),
icon: RotateCw,
key: 'reload',
text: $t('preferences.tabbar.contextMenu.reload'),

View File

@ -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
*/

View File

@ -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);
// 页面加载进度条