mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 13:16:49 +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",
|
"name": "tdesign-vue-next-starter",
|
||||||
"version": "0.7.1",
|
"version": "0.7.2",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev:mock": "vite --open --mode mock",
|
"dev:mock": "vite --open --mode mock",
|
||||||
"dev": "vite --open --mode development",
|
"dev": "vite --open --mode development",
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
<t-layout :class="`${prefix}-layout`">
|
<t-layout :class="`${prefix}-layout`">
|
||||||
<t-tabs
|
<t-tabs
|
||||||
v-if="settingStore.isUseTabsRouter"
|
v-if="settingStore.isUseTabsRouter"
|
||||||
|
drag-sort
|
||||||
theme="card"
|
theme="card"
|
||||||
:class="`${prefix}-layout-tabs-nav`"
|
:class="`${prefix}-layout-tabs-nav`"
|
||||||
:value="$route.path"
|
:value="$route.path"
|
||||||
:style="{ position: 'sticky', top: 0, width: '100%' }"
|
:style="{ position: 'sticky', top: 0, width: '100%' }"
|
||||||
@change="handleChangeCurrentTab"
|
@change="handleChangeCurrentTab"
|
||||||
@remove="handleRemove"
|
@remove="handleRemove"
|
||||||
|
@drag-sort="handleDragend"
|
||||||
>
|
>
|
||||||
<t-tab-panel
|
<t-tab-panel
|
||||||
v-for="(routeItem, index) in tabRouters"
|
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 (ctx.trigger === 'document') activeTabPath.value = null;
|
||||||
if (visible) activeTabPath.value = path;
|
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>
|
</script>
|
||||||
|
|
|
@ -49,17 +49,28 @@ export const useTabsRouterStore = defineStore('tabsRouter', {
|
||||||
// 处理关闭右侧
|
// 处理关闭右侧
|
||||||
subtractTabRouterBehind(newRoute: TRouterInfo) {
|
subtractTabRouterBehind(newRoute: TRouterInfo) {
|
||||||
const { routeIdx } = newRoute;
|
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) {
|
subtractTabRouterAhead(newRoute: TRouterInfo) {
|
||||||
const { routeIdx } = newRoute;
|
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) {
|
subtractTabRouterOther(newRoute: TRouterInfo) {
|
||||||
const { routeIdx } = newRoute;
|
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() {
|
removeTabRouterList() {
|
||||||
this.tabRouterList = [];
|
this.tabRouterList = [];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user