mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 05:18:03 +00:00
add examples
This commit is contained in:
parent
04e9393dea
commit
cf47b9f282
90
packages/app/src/api/collections/authors.ts
Normal file
90
packages/app/src/api/collections/authors.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import { TableOptions } from '@nocobase/database';
|
||||
|
||||
export default {
|
||||
title: '作者',
|
||||
showInDataMenu: true,
|
||||
name: 'authors',
|
||||
// createdBy: true,
|
||||
// updatedBy: true,
|
||||
fields: [
|
||||
{
|
||||
interface: 'string',
|
||||
title: '姓名',
|
||||
name: 'name',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'radio',
|
||||
title: '性别',
|
||||
dataSource: [
|
||||
{value: 'male', label: '男性'},
|
||||
{value: 'female', label: '女性'},
|
||||
],
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'number',
|
||||
title: '年龄',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'linkTo',
|
||||
title: '书籍',
|
||||
target: 'books',
|
||||
labelField: 'name',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'createdBy',
|
||||
title: '创建人',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'updatedBy',
|
||||
title: '更新人',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'createdAt',
|
||||
title: '创建日期',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'updatedAt',
|
||||
title: '更新日期',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
68
packages/app/src/api/collections/books.ts
Normal file
68
packages/app/src/api/collections/books.ts
Normal file
@ -0,0 +1,68 @@
|
||||
import { TableOptions } from '@nocobase/database';
|
||||
|
||||
export default {
|
||||
title: '书籍',
|
||||
showInDataMenu: true,
|
||||
name: 'books',
|
||||
// createdBy: true,
|
||||
// updatedBy: true,
|
||||
fields: [
|
||||
{
|
||||
interface: 'string',
|
||||
title: '书籍名称',
|
||||
name: 'name',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'linkTo',
|
||||
title: '作者',
|
||||
target: 'authors',
|
||||
labelField: 'name',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'createdBy',
|
||||
title: '创建人',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'updatedBy',
|
||||
title: '更新人',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'createdAt',
|
||||
title: '创建日期',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
interface: 'updatedAt',
|
||||
title: '更新日期',
|
||||
component: {
|
||||
showInTable: true,
|
||||
showInDetail: true,
|
||||
// showInForm: true,
|
||||
},
|
||||
}
|
||||
],
|
||||
};
|
@ -196,5 +196,7 @@ api.registerPlugin('plugin-file-manager', [path.resolve(__dirname, '../../../plu
|
||||
default: true
|
||||
});
|
||||
await database.getModel('collections').import(require('./collections/example').default);
|
||||
await database.getModel('collections').import(require('./collections/authors').default);
|
||||
await database.getModel('collections').import(require('./collections/books').default);
|
||||
await database.close();
|
||||
})();
|
||||
|
@ -178,7 +178,7 @@ export default {
|
||||
interface: 'boolean',
|
||||
type: 'boolean',
|
||||
name: 'default',
|
||||
title: '默认标签页',
|
||||
title: '作为默认标签页',
|
||||
defaultValue: false,
|
||||
component: {
|
||||
type: 'checkbox',
|
||||
|
@ -141,7 +141,7 @@ export default {
|
||||
interface: 'boolean',
|
||||
type: 'boolean',
|
||||
name: 'default',
|
||||
title: '默认视图',
|
||||
title: '作为默认试图',
|
||||
defaultValue: false,
|
||||
component: {
|
||||
type: 'checkbox',
|
||||
|
Loading…
Reference in New Issue
Block a user