feat: improve developer mode support
This commit is contained in:
parent
a3155f687f
commit
caa98f6d08
26
packages/app/src/api/collections/example.ts
Normal file
26
packages/app/src/api/collections/example.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import { TableOptions } from '@nocobase/database';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: '示例',
|
||||||
|
showInDataMenu: true,
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
interface: 'string',
|
||||||
|
title: '单行文本',
|
||||||
|
component: {
|
||||||
|
showInTable: true,
|
||||||
|
showInDetail: true,
|
||||||
|
showInForm: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
interface: 'textarea',
|
||||||
|
title: '多行文本',
|
||||||
|
component: {
|
||||||
|
showInTable: true,
|
||||||
|
showInDetail: true,
|
||||||
|
showInForm: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
@ -34,6 +34,14 @@ const api = Api.create({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
api.resourcer.use(async (ctx, next) => {
|
||||||
|
const { resourceName } = ctx.action.params;
|
||||||
|
const table = ctx.db.getTable(resourceName);
|
||||||
|
if (table && table.hasField('developerMode')) {
|
||||||
|
ctx.action.setParam('filter.developerMode', false);
|
||||||
|
}
|
||||||
|
await next();
|
||||||
|
});
|
||||||
api.resourcer.use(associated);
|
api.resourcer.use(associated);
|
||||||
api.resourcer.registerActionHandlers({...actions.common, ...actions.associate});
|
api.resourcer.registerActionHandlers({...actions.common, ...actions.associate});
|
||||||
|
|
||||||
@ -47,6 +55,8 @@ api.resourcer.registerActionHandlers({...actions.common, ...actions.associate});
|
|||||||
// [path.resolve(__dirname, '../../../plugin-file-manager'), {}],
|
// [path.resolve(__dirname, '../../../plugin-file-manager'), {}],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// await api.database.getModel('collections').load();
|
||||||
|
|
||||||
api.listen(process.env.HTTP_PORT, () => {
|
api.listen(process.env.HTTP_PORT, () => {
|
||||||
console.log(`http://localhost:${process.env.HTTP_PORT}/`);
|
console.log(`http://localhost:${process.env.HTTP_PORT}/`);
|
||||||
});
|
});
|
||||||
|
@ -113,6 +113,7 @@ const data = {
|
|||||||
path: '/settings/pages',
|
path: '/settings/pages',
|
||||||
icon: 'dashboard',
|
icon: 'dashboard',
|
||||||
sort: 100,
|
sort: 100,
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '数据表配置',
|
title: '数据表配置',
|
||||||
@ -179,5 +180,7 @@ const data = {
|
|||||||
token: "38979f07e1fca68fb3d2",
|
token: "38979f07e1fca68fb3d2",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await database.getModel('collections').import(require('./collections/example').default);
|
||||||
|
|
||||||
await database.close();
|
await database.close();
|
||||||
})();
|
})();
|
||||||
|
@ -31,6 +31,7 @@ const defaultValues = {
|
|||||||
name: 'form',
|
name: 'form',
|
||||||
title: '表单',
|
title: '表单',
|
||||||
template: 'DrawerForm',
|
template: 'DrawerForm',
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'details',
|
type: 'details',
|
||||||
@ -38,6 +39,7 @@ const defaultValues = {
|
|||||||
title: '详情',
|
title: '详情',
|
||||||
template: 'Details',
|
template: 'Details',
|
||||||
actionNames: ['update'],
|
actionNames: ['update'],
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'table',
|
type: 'table',
|
||||||
|
@ -413,6 +413,7 @@ export const primaryKey = {
|
|||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
filterable: true,
|
filterable: true,
|
||||||
|
developerMode: true,
|
||||||
component: {
|
component: {
|
||||||
type: 'number',
|
type: 'number',
|
||||||
},
|
},
|
||||||
@ -429,6 +430,7 @@ export const sort = {
|
|||||||
interface: 'sort',
|
interface: 'sort',
|
||||||
type: 'integer',
|
type: 'integer',
|
||||||
required: true,
|
required: true,
|
||||||
|
developerMode: true,
|
||||||
component: {
|
component: {
|
||||||
type: 'sort',
|
type: 'sort',
|
||||||
showInTable: true,
|
showInTable: true,
|
||||||
@ -441,6 +443,7 @@ export const password = {
|
|||||||
options: {
|
options: {
|
||||||
interface: 'password',
|
interface: 'password',
|
||||||
type: 'password',
|
type: 'password',
|
||||||
|
developerMode: true,
|
||||||
hidden: true, // hidden 用来控制 api 不输出这个字段,但是可能这个字段显示在表单里 showInForm
|
hidden: true, // hidden 用来控制 api 不输出这个字段,但是可能这个字段显示在表单里 showInForm
|
||||||
component: {
|
component: {
|
||||||
type: 'password',
|
type: 'password',
|
||||||
@ -454,6 +457,7 @@ export const json = {
|
|||||||
interface: 'json',
|
interface: 'json',
|
||||||
type: 'json',
|
type: 'json',
|
||||||
dottie: true,
|
dottie: true,
|
||||||
|
developerMode: true,
|
||||||
component: {
|
component: {
|
||||||
type: 'hidden',
|
type: 'hidden',
|
||||||
},
|
},
|
||||||
|
@ -35,6 +35,9 @@ export default async function getRoutes(ctx, next) {
|
|||||||
const database: Database = ctx.database;
|
const database: Database = ctx.database;
|
||||||
const Page = database.getModel('pages');
|
const Page = database.getModel('pages');
|
||||||
let pages = await Page.findAll({
|
let pages = await Page.findAll({
|
||||||
|
where: {
|
||||||
|
developerMode: false,
|
||||||
|
},
|
||||||
order: [['sort', 'asc']],
|
order: [['sort', 'asc']],
|
||||||
});
|
});
|
||||||
const data = flatToTree(pages.map(row => row.toJSON()), {
|
const data = flatToTree(pages.map(row => row.toJSON()), {
|
||||||
|
@ -4,6 +4,7 @@ export default {
|
|||||||
name: 'pages',
|
name: 'pages',
|
||||||
title: '页面配置',
|
title: '页面配置',
|
||||||
model: 'BaseModel',
|
model: 'BaseModel',
|
||||||
|
developerMode: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
interface: 'sort',
|
interface: 'sort',
|
||||||
@ -158,6 +159,16 @@ export default {
|
|||||||
showInDetail: true,
|
showInDetail: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
interface: 'boolean',
|
||||||
|
type: 'boolean',
|
||||||
|
name: 'developerMode',
|
||||||
|
title: '开发者模式',
|
||||||
|
defaultValue: false,
|
||||||
|
component: {
|
||||||
|
type: 'boolean',
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
interface: 'linkTo',
|
interface: 'linkTo',
|
||||||
type: 'hasMany',
|
type: 'hasMany',
|
||||||
|
@ -3,6 +3,7 @@ import { TableOptions } from '@nocobase/database';
|
|||||||
export default {
|
export default {
|
||||||
name: 'users',
|
name: 'users',
|
||||||
title: '用户',
|
title: '用户',
|
||||||
|
developerMode: true,
|
||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
interface: 'string',
|
interface: 'string',
|
||||||
@ -95,18 +96,21 @@ export default {
|
|||||||
name: 'form',
|
name: 'form',
|
||||||
title: '表单',
|
title: '表单',
|
||||||
template: 'DrawerForm',
|
template: 'DrawerForm',
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'form',
|
type: 'form',
|
||||||
name: 'login',
|
name: 'login',
|
||||||
title: '登录',
|
title: '登录',
|
||||||
template: 'Login',
|
template: 'Login',
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'form',
|
type: 'form',
|
||||||
name: 'register',
|
name: 'register',
|
||||||
title: '注册',
|
title: '注册',
|
||||||
template: 'Register',
|
template: 'Register',
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'details',
|
type: 'details',
|
||||||
@ -114,6 +118,7 @@ export default {
|
|||||||
title: '详情',
|
title: '详情',
|
||||||
template: 'Details',
|
template: 'Details',
|
||||||
actionNames: ['update'],
|
actionNames: ['update'],
|
||||||
|
developerMode: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'simple',
|
type: 'simple',
|
||||||
|
Loading…
Reference in New Issue
Block a user