Browse Source

Merge pull request #5172 from nocodb/fix/tab-control

fix: tab control
pull/5305/head
աɨռɢӄաօռɢ 2 years ago committed by GitHub
parent
commit
b12738a66c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 11
      packages/nc-gui/pages/[projectType]/[projectId]/index.vue
  2. 25
      packages/nc-gui/store/tab.ts

11
packages/nc-gui/pages/[projectType]/[projectId]/index.vue

@ -168,8 +168,6 @@ onKeyStroke(
{ eventName: 'keydown' },
)
clearTabs()
onBeforeMount(async () => {
try {
await loadProject()
@ -183,8 +181,8 @@ onBeforeMount(async () => {
message.error(await extractSdkResponseErrorMsg(e))
}
if (!route.params.type && isUIAllowed('teamAndAuth')) {
addTab({ type: TabType.AUTH, title: t('title.teamAndAuth') })
if (route.name === 'projectType-projectId-index-index' && isUIAllowed('teamAndAuth')) {
addTab({ id: TabType.AUTH, type: TabType.AUTH, title: t('title.teamAndAuth') })
}
/** If v1 url found navigate to corresponding new url */
@ -199,7 +197,10 @@ onMounted(() => {
toggleHasSidebar(true)
})
onBeforeUnmount(reset)
onBeforeUnmount(() => {
clearTabs()
reset()
})
function openKeyboardShortcutDialog() {
$e('a:actions:keyboard-shortcut')

25
packages/nc-gui/store/tab.ts

@ -18,6 +18,10 @@ export const useTabs = defineStore('tabStore', () => {
const route = $(router.currentRoute)
const { t } = useI18n()
const { isUIAllowed } = useUIPermission()
const projectStore = useProject()
const projectType = $computed(() => route.params.projectType as string)
@ -56,8 +60,8 @@ export const useTabs = defineStore('tabStore', () => {
}
return index
} else if (routeName.startsWith('nc-projectId-index-index-auth')) {
return tabs.value.findIndex((t) => t.type === 'auth')
} else if (routeName.startsWith('projectType-projectId-index-index-auth')) {
return tabs.value.findIndex((t) => t.type === TabType.AUTH)
}
// by default, it's showing Team & Auth
@ -156,5 +160,22 @@ export const useTabs = defineStore('tabStore', () => {
}
}
watch(
() => route.name,
(n, o) => {
if (n === o) return
if (!n || !/^projectType-projectId-index-index/.test(n.toString())) return
const activeTabRoute = n.toString().replace('projectType-projectId-index-index-', '')
switch (activeTabRoute) {
case TabType.AUTH:
if (isUIAllowed('teamAndAuth')) addTab({ id: TabType.AUTH, type: TabType.AUTH, title: t('title.teamAndAuth') })
break
default:
break
}
},
{ immediate: true },
)
return { tabs, addTab, activeTabIndex, activeTab, clearTabs, closeTab, updateTab }
})

Loading…
Cancel
Save