diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts index d2fef08531..e2e5a65517 100644 --- a/packages/nc-gui-v2/composables/useTabs.ts +++ b/packages/nc-gui-v2/composables/useTabs.ts @@ -15,7 +15,42 @@ function getPredicate(key: Partial) { export default () => { const tabs = useState('tabs', () => []) - const activeTab = useState('activeTab', () => 0) + // const activeTab = useState('activeTab', () => 0) + + const route = useRoute() + const router = useRouter() + const { tables } = useProject() + + const activeTab: WritableComputedRef = computed({ + get() { + if ((route?.name as string)?.startsWith('nc-projectId-index-index-table-title') && tables?.value?.length) { + const tab: Partial = { type: 'table', title: route.params.title as string } + const id = tables.value?.find((t) => t.title === tab.title)?.id + tab.id = id as string + let index = tabs.value.findIndex((t) => t.id === tab.id) + if (index === -1) { + tabs.value.push(tab as TabItem) + index = tabs.value.length - 1 + } + return index + } + return -1 + }, + set(index: number) { + if (index === -1) { + router.push(`/nc/${route.params.projectId}`) + } else { + router.push(`/nc/${route.params.projectId}/table/${tabs.value?.[index]?.title}`) + } + }, + + // if (route.params.title) { + // const tab = tabs.value.find(t => t.id === route.params.tab) + // if (tab) { + // activeTab.value = tabs.value.indexOf(tab) + // } + // } + }) const addTab = (tabMeta: TabItem) => { const tabIndex = tabs.value.findIndex((tab) => tab.id === tabMeta.id) diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue index 8119a0ec08..2f2ce1a288 100644 --- a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue @@ -1,11 +1,32 @@ - - + diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue new file mode 100644 index 0000000000..8435a144c0 --- /dev/null +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/[viewTitle]/index.vue @@ -0,0 +1,9 @@ + + + + + diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue new file mode 100644 index 0000000000..10745f6de9 --- /dev/null +++ b/packages/nc-gui-v2/pages/nc/[projectId]/index/index/table/[title]/index.vue @@ -0,0 +1,9 @@ + + + + +