import { computed, h, ref } from 'vue'; import { NTag } from 'naive-ui'; import { FormSchema } from '@/components/Form'; import { useDictStore } from '@/store/modules/dict'; const dict = useDictStore(); export interface ContentState { id: string; objectType: string; postId: string; authorId: string; contentText: string; flowerCode: string; visibility: string; status: string; auditStatus: string; rejectReason: string; likeCount: number; commentCount: number; createdAt: string; } export const schemas = ref([ { field: 'objectType', component: 'NSelect', label: '内容类型', defaultValue: 'feed_post', componentProps: { options: computed(() => dict.getOptions('CultivateContentTypeOptions')) } }, { field: 'status', component: 'NSelect', label: '状态', componentProps: { options: computed(() => dict.getOptions('CultivateContentStatusOptions')), clearable: true } }, { field: 'authorId', component: 'NInput', label: '作者ID', componentProps: { placeholder: '请输入作者ID' } }, { field: 'keyword', component: 'NInput', label: '内容关键词', componentProps: { placeholder: '请输入正文关键词' } }, ]); export const columns = [ { title: '内容ID', key: 'id', width: 190 }, { title: '类型', key: 'objectType', width: 90, render: (row: ContentState) => dict.getLabel('CultivateContentTypeOptions', row.objectType) }, { title: '作者ID', key: 'authorId', width: 150 }, { title: '正文', key: 'contentText', width: 300, ellipsis: { tooltip: true } }, { title: '可见范围', key: 'visibility', width: 100 }, { title: '状态', key: 'status', width: 110, render(row: ContentState) { return h(NTag, { type: row.status === 'published' ? 'success' : row.status === 'reviewing' ? 'warning' : row.status === 'rejected' ? 'error' : 'default' }, { default: () => dict.getLabel('CultivateContentStatusOptions', row.status) }); } }, { title: '点赞', key: 'likeCount', width: 80 }, { title: '评论', key: 'commentCount', width: 80 }, { title: '创建时间', key: 'createdAt', width: 180 }, ]; export function loadOptions() { dict.loadOptions(['CultivateContentTypeOptions', 'CultivateContentStatusOptions']); }