|
|
@ -1,4 +1,4 @@ |
|
|
|
import type { OracleUi, ProjectType, TableType } from 'nocodb-sdk' |
|
|
|
import type { BaseType, OracleUi, ProjectType, TableType } from 'nocodb-sdk' |
|
|
|
import { SqlUiFactory } from 'nocodb-sdk' |
|
|
|
import { SqlUiFactory } from 'nocodb-sdk' |
|
|
|
import { isString } from '@vueuse/core' |
|
|
|
import { isString } from '@vueuse/core' |
|
|
|
import { |
|
|
|
import { |
|
|
@ -35,7 +35,7 @@ const [setup, use] = useInjectionState(() => { |
|
|
|
const projectLoadedHook = createEventHook<ProjectType>() |
|
|
|
const projectLoadedHook = createEventHook<ProjectType>() |
|
|
|
|
|
|
|
|
|
|
|
const project = ref<ProjectType>({}) |
|
|
|
const project = ref<ProjectType>({}) |
|
|
|
|
|
|
|
const bases = computed<BaseType[]>(() => project.value?.bases || []) |
|
|
|
const tables = ref<TableType[]>([]) |
|
|
|
const tables = ref<TableType[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const projectMetaInfo = ref<ProjectMetaInfo | undefined>() |
|
|
|
const projectMetaInfo = ref<ProjectMetaInfo | undefined>() |
|
|
@ -55,15 +55,35 @@ const [setup, use] = useInjectionState(() => { |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const projectBaseType = $computed(() => project.value?.bases?.[0]?.type || ClientType.MYSQL) |
|
|
|
const sqlUis = computed(() => { |
|
|
|
|
|
|
|
const temp: Record<string, any> = {} |
|
|
|
|
|
|
|
for (const base of bases.value) { |
|
|
|
|
|
|
|
if (base.id) { |
|
|
|
|
|
|
|
temp[base.id] = SqlUiFactory.create({ client: base.type }) as Exclude< |
|
|
|
|
|
|
|
ReturnType<typeof SqlUiFactory['create']>, |
|
|
|
|
|
|
|
typeof OracleUi |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return temp |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getBaseType(baseId: string) { |
|
|
|
|
|
|
|
return bases.value.find((base) => base.id === baseId)?.type || ClientType.MYSQL |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const sqlUi = computed( |
|
|
|
function isMysql(baseId: string) { |
|
|
|
() => SqlUiFactory.create({ client: projectBaseType }) as Exclude<ReturnType<typeof SqlUiFactory['create']>, typeof OracleUi>, |
|
|
|
return ['mysql', ClientType.MYSQL].includes(getBaseType(baseId)) |
|
|
|
) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isMssql(baseId: string) { |
|
|
|
|
|
|
|
return getBaseType(baseId) === 'mssql' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isPg(baseId: string) { |
|
|
|
|
|
|
|
return getBaseType(baseId) === 'pg' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isMysql = computed(() => ['mysql', ClientType.MYSQL].includes(projectBaseType)) |
|
|
|
|
|
|
|
const isMssql = computed(() => projectBaseType === 'mssql') |
|
|
|
|
|
|
|
const isPg = computed(() => projectBaseType === 'pg') |
|
|
|
|
|
|
|
const isSharedBase = computed(() => projectType === 'base') |
|
|
|
const isSharedBase = computed(() => projectType === 'base') |
|
|
|
|
|
|
|
|
|
|
|
async function loadProjectMetaInfo(force?: boolean) { |
|
|
|
async function loadProjectMetaInfo(force?: boolean) { |
|
|
@ -151,6 +171,7 @@ const [setup, use] = useInjectionState(() => { |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
project, |
|
|
|
project, |
|
|
|
|
|
|
|
bases, |
|
|
|
tables, |
|
|
|
tables, |
|
|
|
loadProjectRoles, |
|
|
|
loadProjectRoles, |
|
|
|
loadProject, |
|
|
|
loadProject, |
|
|
@ -159,7 +180,7 @@ const [setup, use] = useInjectionState(() => { |
|
|
|
isMysql, |
|
|
|
isMysql, |
|
|
|
isMssql, |
|
|
|
isMssql, |
|
|
|
isPg, |
|
|
|
isPg, |
|
|
|
sqlUi, |
|
|
|
sqlUis, |
|
|
|
isSharedBase, |
|
|
|
isSharedBase, |
|
|
|
loadProjectMetaInfo, |
|
|
|
loadProjectMetaInfo, |
|
|
|
projectMetaInfo, |
|
|
|
projectMetaInfo, |
|
|
|