-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(projects): fix:tab切换路由fullpath #78
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ export function getTabRouteByVueRoute(route: RouteRecordNormalized | RouteLocati | |
name: route.name, | ||
path: route.path, | ||
meta: route.meta, | ||
fullPath: (<RouteLocationNormalizedLoaded>route).fullPath, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里不要类型断言,参数route的类型需要重新定义 |
||
scrollPosition: { | ||
left: 0, | ||
top: 0 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,7 @@ export const useTabStore = defineStore('tab-store', { | |
homeTab: { | ||
name: 'root', | ||
path: '/', | ||
fullPath: '/', | ||
meta: { | ||
title: 'root' | ||
}, | ||
|
@@ -124,15 +125,15 @@ export const useTabStore = defineStore('tab-store', { | |
}, | ||
/** | ||
* 点击单个tab | ||
* @param path - 路由path | ||
* @param route - 路由route | ||
*/ | ||
handleClickTab(path: string) { | ||
handleClickTab(route: GlobalTabRoute) { | ||
const { routerPush } = useRouterPush(false); | ||
|
||
const isActive = this.activeTab === path; | ||
const isActive = this.activeTab === route.path; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里会不会有个问题,如果是同一个页面,但是params或者query参数不一致,页面是如何显示在Tab上的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 应该是以fullpath为主,有参数和没参数的各起一个tab? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个还得用页面测试一下 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 常用的业务场景就是查看一个表格的某行的详情信息,可以开不同的详情页面 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 好的,我继续改一下。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
那这里的设计是每个不一样的参数都起一个tab呢,还是同一个path就起一个tab There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 不一样的参数不同tab There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我这两天会添加这个功能 |
||
if (!isActive) { | ||
this.setActiveTab(path); | ||
routerPush(path); | ||
this.setActiveTab(route.path); | ||
routerPush(route.fullPath || route.path); | ||
} | ||
}, | ||
/** | ||
|
@@ -164,7 +165,6 @@ export const useTabStore = defineStore('tab-store', { | |
/** 初始化Tab状态 */ | ||
iniTabStore(currentRoute: RouteLocationNormalizedLoaded) { | ||
const theme = useThemeStore(); | ||
|
||
const isHome = currentRoute.path === this.homeTab.path; | ||
const tabs: GlobalTabRoute[] = theme.tab.isCache ? getTabRoutes() : []; | ||
const hasHome = isInTabRoutes(tabs, this.homeTab.path); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
components.d.ts这个文件不要修改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道为啥变调了,提交的时候没注意...