fix: inconsistent performance between breadcrumbs and tabs (#4105)

pull/48/MERGE
Vben 2024-08-10 10:30:15 +08:00 committed by GitHub
parent ed14282999
commit 8725a01301
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 25 additions and 12 deletions

View File

@ -17,11 +17,12 @@ categories:
- title: "🐞 Bug Fixes" - title: "🐞 Bug Fixes"
labels: labels:
- "bug" - "bug"
- title: 📝 Documentation updates - title: 📝 Documentation
labels: labels:
- "documentation" - "documentation"
- title: 👻 Maintenance - title: 👻 Maintenance
labels: labels:
- "perf"
- "chore" - "chore"
- "dependencies" - "dependencies"
collapse-after: 5 collapse-after: 5
@ -34,12 +35,16 @@ categories:
version-resolver: version-resolver:
major: major:
labels: labels:
- "major"
- "breaking" - "breaking"
minor: minor:
labels: labels:
- "feature" - "minor"
# - "feature"
patch: patch:
labels: labels:
- "patch"
- "feature"
- "bug" - "bug"
- "maintenance" - "maintenance"
- "docs" - "docs"

View File

@ -23,6 +23,6 @@ function registerAnalytics() {
export function initHmPlugin() { export function initHmPlugin() {
if (inBrowser && import.meta.env.PROD) { if (inBrowser && import.meta.env.PROD) {
registerAnalytics(SITE_ID); registerAnalytics();
} }
} }

View File

@ -33,7 +33,8 @@ function handleClick(path?: string) {
<a href="javascript:void 0" @click.stop="handleClick(item.path)"> <a href="javascript:void 0" @click.stop="handleClick(item.path)">
<span class="flex-center z-10 h-full"> <span class="flex-center z-10 h-full">
<VbenIcon <VbenIcon
v-if="item.icon && showIcon" v-if="showIcon"
:fallback="showIcon"
:icon="item.icon" :icon="item.icon"
class="mr-1 size-4 flex-shrink-0" class="mr-1 size-4 flex-shrink-0"
/> />

View File

@ -51,7 +51,8 @@ function handleClick(path?: string) {
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger class="flex items-center gap-1"> <DropdownMenuTrigger class="flex items-center gap-1">
<VbenIcon <VbenIcon
v-if="item.icon && showIcon" v-if="showIcon"
:fallback="showIcon"
:icon="item.icon" :icon="item.icon"
class="size-5" class="size-5"
/> />
@ -77,8 +78,9 @@ function handleClick(path?: string) {
> >
<div class="flex-center"> <div class="flex-center">
<VbenIcon <VbenIcon
v-if="item.icon && showIcon" v-if="showIcon"
:class="{ 'size-5': item.isHome }" :class="{ 'size-5': item.isHome }"
:fallback="showIcon"
:icon="item.icon" :icon="item.icon"
class="mr-1 size-4" class="mr-1 size-4"
/> />
@ -88,8 +90,9 @@ function handleClick(path?: string) {
<BreadcrumbPage v-else> <BreadcrumbPage v-else>
<div class="flex-center"> <div class="flex-center">
<VbenIcon <VbenIcon
v-if="item.icon && showIcon" v-if="showIcon"
:class="{ 'size-5': item.isHome }" :class="{ 'size-5': item.isHome }"
:fallback="showIcon"
:icon="item.icon" :icon="item.icon"
class="mr-1 size-4" class="mr-1 size-4"
/> />

View File

@ -1,9 +1,6 @@
import type { TabDefinition } from '@vben/types'; import type { TabDefinition } from '@vben/types';
import type { IContextMenuItem } from '@vben-core/tabs-ui'; import type { IContextMenuItem } from '@vben-core/tabs-ui';
import type { import type { RouteLocationNormalizedGeneric } from 'vue-router';
RouteLocationNormalized,
RouteLocationNormalizedGeneric,
} from 'vue-router';
import { computed, ref, watch } from 'vue'; import { computed, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
@ -103,7 +100,14 @@ export function useTabbar() {
watch( watch(
() => route.path, () => route.path,
() => { () => {
tabbarStore.addTab(route as RouteLocationNormalized); // 这里不能用route用route时vue-router会自动将父级meta进行合并
const routes = router.getRoutes();
const currentRoute = routes.find((item) => item.path === route.path);
if (currentRoute) {
tabbarStore.addTab(
currentRoute as unknown as RouteLocationNormalizedGeneric,
);
}
}, },
{ immediate: true }, { immediate: true },
); );