-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 新增页签模式&地图错误修复 * fix: 修复404跳转问题 * fix: 检视意见修改
- Loading branch information
Showing
10 changed files
with
174 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/toolkits/pro/template/tinyvue/src/router/guard/tabs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useTabStore } from "@/store"; | ||
import { Router } from "vue-router"; | ||
|
||
export const setupTabsGuard = (router:Router) => { | ||
router.beforeEach((to, from, next) => { | ||
const tabStore = useTabStore(); | ||
if (tabStore.has(to.meta.locale ?? '')) { | ||
tabStore.set(to.meta.locale!); | ||
next(); | ||
return; | ||
} | ||
tabStore.add({name: to.meta.locale!, link: to.fullPath}); | ||
tabStore.set(to.meta.locale!); | ||
next(); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/toolkits/pro/template/tinyvue/src/store/modules/tabs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { defineStore } from "pinia"; | ||
|
||
type Tab = { | ||
name: string; | ||
link: string; | ||
} | ||
|
||
export const useTabStore = defineStore('tabs', { | ||
state(){ | ||
return { | ||
data: [] as Tab[], | ||
current: {} as Tab, | ||
} | ||
}, | ||
actions: { | ||
add(item: Tab) { | ||
if (!item.name){ | ||
return {...item}; | ||
} | ||
if (!this.has(item.name)){ | ||
this.data.push(item) | ||
} | ||
this.current = item; | ||
return {...item}; | ||
}, | ||
set(name: string){ | ||
this.current = this.getByName(name)[0] ?? null; | ||
return this.current; | ||
}, | ||
has(name: string){ | ||
return this.data.some((tab) => tab.name === name) | ||
}, | ||
getByName(name: string){ | ||
return this.data.filter((tab) => tab.name === name); | ||
}, | ||
getByLink(link: string) { | ||
return this.data.filter((tab) => tab.link === link); | ||
}, | ||
delByLink(link: string){ | ||
if (this.data.length === 1){ | ||
return; | ||
} | ||
const idx = this.data.findIndex((tab) => tab.link === link); | ||
if (idx === -1) { | ||
return; | ||
} | ||
const hasNext = idx < this.data.length-1; | ||
if (hasNext) { | ||
this.current = this.data[idx+1]; | ||
} else { | ||
const hasPrev = idx > 0; | ||
if (hasPrev){ | ||
this.current = this.data[idx-1]; | ||
} | ||
} | ||
this.data.splice(idx, 1); | ||
}, | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters