feat(projects): 支持同一路由根据不同query和hash同时显示不同Tab

ISSUES CLOSED: #64
This commit is contained in:
Soybean
2022-06-07 00:56:25 +08:00
parent 434ab1c560
commit 4122685803
20 changed files with 364 additions and 89 deletions

View File

@ -12,7 +12,7 @@
@after-enter="handleAfterEnter"
>
<keep-alive :include="routeStore.cacheRoutes">
<component :is="Component" v-if="app.reloadFlag" :key="route.path" />
<component :is="Component" v-if="app.reloadFlag" :key="route.fullPath" />
</keep-alive>
</transition>
</router-view>

View File

@ -69,7 +69,7 @@ const options = computed<Option[]>(() => [
{
label: '关闭',
key: 'close-current',
disabled: props.currentPath === tab.homeTab.path,
disabled: props.currentPath === tab.homeTab.fullPath,
icon: iconifyRender('ant-design:close-outlined')
},
{

View File

@ -3,15 +3,15 @@
<component
:is="activeComponent"
v-for="(item, index) in tab.tabs"
:key="item.path"
:is-active="tab.activeTab === item.path"
:key="item.fullPath"
:is-active="tab.activeTab === item.fullPath"
:primary-color="theme.themeColor"
:closable="item.path !== tab.homeTab.path"
:closable="item.name !== tab.homeTab.name"
:dark-mode="theme.darkMode"
:class="{ '!mr-0': isChromeMode && index === tab.tabs.length - 1, 'mr-10px': !isChromeMode }"
@click="tab.handleClickTab(item.path)"
@close="tab.removeTab(item.path)"
@contextmenu="handleContextMenu($event, item.path)"
@click="tab.handleClickTab(item.fullPath)"
@close="tab.removeTab(item.fullPath)"
@contextmenu="handleContextMenu($event, item.fullPath)"
>
<Icon v-if="item.meta.icon" :icon="item.meta.icon" class="inline-block align-text-bottom mr-4px text-16px" />
{{ item.meta.title }}
@ -77,11 +77,11 @@ function setDropdown(x: number, y: number, currentPath: string) {
}
/** 点击右键菜单 */
async function handleContextMenu(e: MouseEvent, path: string) {
async function handleContextMenu(e: MouseEvent, fullPath: string) {
e.preventDefault();
const { clientX, clientY } = e;
hideDropdown();
setDropdown(clientX, clientY, path);
setDropdown(clientX, clientY, fullPath);
await nextTick();
showDropdown();
}

View File

@ -45,10 +45,10 @@ function init() {
}
watch(
() => route.path,
() => route.fullPath,
() => {
tab.addTab(route);
tab.setActiveTab(route.path);
tab.setActiveTab(route.fullPath);
}
);