多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
820 B

import type { FormType, GalleryType, GridType, KanbanType, TableType } from 'nocodb-sdk'
2 years ago
import type { MaybeRef } from '@vueuse/core'
import type { WatchOptions } from '@vue/runtime-core'
import { useNuxtApp } from '#app'
export default function (meta: MaybeRef<TableType | undefined>, watchOptions: WatchOptions = {}) {
2 years ago
let views = $ref<(GridType | FormType | KanbanType | GalleryType)[]>([])
const { $api } = useNuxtApp()
const loadViews = async () => {
2 years ago
const _meta = unref(meta)
if (_meta && _meta.id) {
const response = (await $api.dbView.list(_meta.id)).list as any[]
if (response) {
views = response.sort((a, b) => a.order - b.order)
}
2 years ago
}
}
watch(() => meta, loadViews, {
immediate: true,
...watchOptions,
})
2 years ago
return { views: $$(views), loadViews }
}