mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 04:06:31 +08:00
Merge branch 'develop' of github.com:Tencent/tdesign-vue-next-starter into main
This commit is contained in:
commit
a381cb7d9b
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "tdesign-vue-next-starter",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.2",
|
||||
"scripts": {
|
||||
"dev:mock": "vite --open --mode mock",
|
||||
"dev": "vite --open --mode development",
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
<t-layout :class="`${prefix}-layout`">
|
||||
<t-tabs
|
||||
v-if="settingStore.isUseTabsRouter"
|
||||
drag-sort
|
||||
theme="card"
|
||||
:class="`${prefix}-layout-tabs-nav`"
|
||||
:value="$route.path"
|
||||
:style="{ position: 'sticky', top: 0, width: '100%' }"
|
||||
@change="handleChangeCurrentTab"
|
||||
@remove="handleRemove"
|
||||
@drag-sort="handleDragend"
|
||||
>
|
||||
<t-tab-panel
|
||||
v-for="(routeItem, index) in tabRouters"
|
||||
|
@ -147,4 +149,13 @@ const handleTabMenuClick = (visible: boolean, ctx, path: string) => {
|
|||
if (ctx.trigger === 'document') activeTabPath.value = null;
|
||||
if (visible) activeTabPath.value = path;
|
||||
};
|
||||
|
||||
const handleDragend = (options: { currentIndex: number; targetIndex: number }) => {
|
||||
const { tabRouters } = tabsRouterStore;
|
||||
|
||||
[tabRouters[options.currentIndex], tabRouters[options.targetIndex]] = [
|
||||
tabRouters[options.targetIndex],
|
||||
tabRouters[options.currentIndex],
|
||||
];
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -49,17 +49,28 @@ export const useTabsRouterStore = defineStore('tabsRouter', {
|
|||
// 处理关闭右侧
|
||||
subtractTabRouterBehind(newRoute: TRouterInfo) {
|
||||
const { routeIdx } = newRoute;
|
||||
this.tabRouterList = this.tabRouterList.slice(0, routeIdx + 1);
|
||||
const homeIdx: number = this.tabRouters.findIndex((route) => route.isHome);
|
||||
let tabRouterList: Array<TRouterInfo> = this.tabRouterList.slice(0, routeIdx + 1);
|
||||
if (routeIdx < homeIdx) {
|
||||
tabRouterList = tabRouterList.concat(homeRoute);
|
||||
}
|
||||
this.tabRouterList = tabRouterList;
|
||||
},
|
||||
// 处理关闭左侧
|
||||
subtractTabRouterAhead(newRoute: TRouterInfo) {
|
||||
const { routeIdx } = newRoute;
|
||||
this.tabRouterList = homeRoute.concat(this.tabRouterList.slice(routeIdx));
|
||||
const homeIdx: number = this.tabRouters.findIndex((route) => route.isHome);
|
||||
let tabRouterList: Array<TRouterInfo> = this.tabRouterList.slice(routeIdx);
|
||||
if (routeIdx > homeIdx) {
|
||||
tabRouterList = homeRoute.concat(tabRouterList);
|
||||
}
|
||||
this.tabRouterList = tabRouterList;
|
||||
},
|
||||
// 处理关闭其他
|
||||
subtractTabRouterOther(newRoute: TRouterInfo) {
|
||||
const { routeIdx } = newRoute;
|
||||
this.tabRouterList = routeIdx === 0 ? homeRoute : homeRoute.concat([this.tabRouterList?.[routeIdx]]);
|
||||
const homeIdx: number = this.tabRouters.findIndex((route) => route.isHome);
|
||||
this.tabRouterList = routeIdx === homeIdx ? homeRoute : homeRoute.concat([this.tabRouterList?.[routeIdx]]);
|
||||
},
|
||||
removeTabRouterList() {
|
||||
this.tabRouterList = [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user