From cf47b9f282ba0833dc9e3411db3e0ec7b543a5e9 Mon Sep 17 00:00:00 2001 From: chenos Date: Sun, 27 Dec 2020 21:53:44 +0800 Subject: [PATCH] add examples --- packages/app/src/api/collections/authors.ts | 90 +++++++++++++++++++ packages/app/src/api/collections/books.ts | 68 ++++++++++++++ packages/app/src/api/migrate.ts | 2 + .../src/collections/tabs.ts | 2 +- .../src/collections/views.ts | 2 +- 5 files changed, 162 insertions(+), 2 deletions(-) create mode 100644 packages/app/src/api/collections/authors.ts create mode 100644 packages/app/src/api/collections/books.ts diff --git a/packages/app/src/api/collections/authors.ts b/packages/app/src/api/collections/authors.ts new file mode 100644 index 000000000..a25486102 --- /dev/null +++ b/packages/app/src/api/collections/authors.ts @@ -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, + }, + } + ], +}; diff --git a/packages/app/src/api/collections/books.ts b/packages/app/src/api/collections/books.ts new file mode 100644 index 000000000..6f786146c --- /dev/null +++ b/packages/app/src/api/collections/books.ts @@ -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, + }, + } + ], +}; diff --git a/packages/app/src/api/migrate.ts b/packages/app/src/api/migrate.ts index 85fb1f798..0a6be4e3b 100644 --- a/packages/app/src/api/migrate.ts +++ b/packages/app/src/api/migrate.ts @@ -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(); })(); diff --git a/packages/plugin-collections/src/collections/tabs.ts b/packages/plugin-collections/src/collections/tabs.ts index 29dbd23e9..510a5f0ad 100644 --- a/packages/plugin-collections/src/collections/tabs.ts +++ b/packages/plugin-collections/src/collections/tabs.ts @@ -178,7 +178,7 @@ export default { interface: 'boolean', type: 'boolean', name: 'default', - title: '默认标签页', + title: '作为默认标签页', defaultValue: false, component: { type: 'checkbox', diff --git a/packages/plugin-collections/src/collections/views.ts b/packages/plugin-collections/src/collections/views.ts index 4d42c901c..2eef9d3c8 100644 --- a/packages/plugin-collections/src/collections/views.ts +++ b/packages/plugin-collections/src/collections/views.ts @@ -141,7 +141,7 @@ export default { interface: 'boolean', type: 'boolean', name: 'default', - title: '默认视图', + title: '作为默认试图', defaultValue: false, component: { type: 'checkbox',