|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import type { WritableComputedRef } from '@vue/reactivity' |
|
|
|
|
import { computed, navigateTo, ref, useInjectionState, useProject, useRoute, useRouter, watch } from '#imports' |
|
|
|
|
import { computed, createSharedComposable, navigateTo, ref, useProject, useRouter, watch } from '#imports' |
|
|
|
|
import type { TabItem } from '~/lib' |
|
|
|
|
import { TabType } from '~/lib' |
|
|
|
|
|
|
|
|
@ -10,13 +10,13 @@ function getPredicate(key: Partial<TabItem>) {
|
|
|
|
|
(!('type' in key) || tab.type === key.type) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const [setup, use] = useInjectionState(() => { |
|
|
|
|
export const useTabs = createSharedComposable(() => { |
|
|
|
|
const tabs = ref<TabItem[]>([]) |
|
|
|
|
|
|
|
|
|
const route = useRoute() |
|
|
|
|
|
|
|
|
|
const router = useRouter() |
|
|
|
|
|
|
|
|
|
const route = $(router.currentRoute) |
|
|
|
|
|
|
|
|
|
const { bases, tables } = useProject() |
|
|
|
|
|
|
|
|
|
const projectType = $computed(() => route.params.projectType as string) |
|
|
|
@ -157,13 +157,3 @@ const [setup, use] = useInjectionState(() => {
|
|
|
|
|
|
|
|
|
|
return { tabs, addTab, activeTabIndex, activeTab, clearTabs, closeTab, updateTab } |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
export function useTabs() { |
|
|
|
|
const state = use() |
|
|
|
|
|
|
|
|
|
if (!state) { |
|
|
|
|
return setup() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return state |
|
|
|
|
} |
|
|
|
|