|
|
|
@ -26,7 +26,7 @@ export function useTabs() {
|
|
|
|
|
const tabs = useState<TabItem[]>('tabs', () => []) |
|
|
|
|
|
|
|
|
|
const route = useRoute() |
|
|
|
|
|
|
|
|
|
const router = useRouter() |
|
|
|
|
const { tables } = useProject() |
|
|
|
|
|
|
|
|
|
const activeTabIndex: WritableComputedRef<number> = computed({ |
|
|
|
@ -36,6 +36,8 @@ export function useTabs() {
|
|
|
|
|
|
|
|
|
|
const id = tables.value?.find((t) => t.title === tab.title)?.id |
|
|
|
|
|
|
|
|
|
if (!id) return -1 |
|
|
|
|
|
|
|
|
|
tab.id = id as string |
|
|
|
|
|
|
|
|
|
let index = tabs.value.findIndex((t) => t.id === tab.id) |
|
|
|
@ -108,7 +110,14 @@ export function useTabs() {
|
|
|
|
|
const updateTab = (key: number | Partial<TabItem>, newTabItemProps: Partial<TabItem>) => { |
|
|
|
|
const tab = typeof key === 'number' ? tabs.value[key] : tabs.value.find(getPredicate(key)) |
|
|
|
|
if (tab) { |
|
|
|
|
const isActive = tabs.value.indexOf(tab) === activeTabIndex.value |
|
|
|
|
Object.assign(tab, newTabItemProps) |
|
|
|
|
if (isActive && tab.title) |
|
|
|
|
router.replace({ |
|
|
|
|
params: { |
|
|
|
|
title: tab.title, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|