feat: improve code
This commit is contained in:
parent
ad700c61b8
commit
c410c188a3
@ -37,6 +37,7 @@ const api = new Application({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const plugins = [
|
const plugins = [
|
||||||
|
'@nocobase/plugin-error-handler',
|
||||||
'@nocobase/plugin-collection-manager',
|
'@nocobase/plugin-collection-manager',
|
||||||
'@nocobase/plugin-ui-schema-storage',
|
'@nocobase/plugin-ui-schema-storage',
|
||||||
'@nocobase/plugin-ui-routes-storage',
|
'@nocobase/plugin-ui-routes-storage',
|
||||||
|
@ -2,6 +2,7 @@ import { LockOutlined } from '@ant-design/icons';
|
|||||||
import { ISchema, useForm } from '@formily/react';
|
import { ISchema, useForm } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PluginManager } from '../plugin-manager';
|
import { PluginManager } from '../plugin-manager';
|
||||||
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
|
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
|
||||||
import * as components from './Configuration';
|
import * as components from './Configuration';
|
||||||
@ -25,7 +26,7 @@ const schema: ISchema = {
|
|||||||
[uid()]: {
|
[uid()]: {
|
||||||
'x-component': 'Action.Drawer',
|
'x-component': 'Action.Drawer',
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '角色配置',
|
title: '{{t("Roles & Permissions")}}',
|
||||||
properties: {
|
properties: {
|
||||||
hello1: {
|
hello1: {
|
||||||
type: 'void',
|
type: 'void',
|
||||||
@ -38,11 +39,12 @@ const schema: ISchema = {
|
|||||||
|
|
||||||
export const ACLShortcut = () => {
|
export const ACLShortcut = () => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<ActionContext.Provider value={{ visible, setVisible }}>
|
<ActionContext.Provider value={{ visible, setVisible }}>
|
||||||
<PluginManager.Toolbar.Item
|
<PluginManager.Toolbar.Item
|
||||||
icon={<LockOutlined />}
|
icon={<LockOutlined />}
|
||||||
title={'角色和权限'}
|
title={t('Roles & Permissions')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}}
|
}}
|
||||||
|
@ -2,6 +2,7 @@ import { DatabaseOutlined } from '@ant-design/icons';
|
|||||||
import { ISchema } from '@formily/react';
|
import { ISchema } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { PluginManager } from '../plugin-manager';
|
import { PluginManager } from '../plugin-manager';
|
||||||
import { ActionContext, SchemaComponent } from '../schema-component';
|
import { ActionContext, SchemaComponent } from '../schema-component';
|
||||||
import { AddFieldAction, ConfigurationTable, EditFieldAction } from './Configuration';
|
import { AddFieldAction, ConfigurationTable, EditFieldAction } from './Configuration';
|
||||||
@ -12,7 +13,7 @@ const schema: ISchema = {
|
|||||||
[uid()]: {
|
[uid()]: {
|
||||||
'x-component': 'Action.Drawer',
|
'x-component': 'Action.Drawer',
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '数据表配置',
|
title: '{{t("Collections & Fields")}}',
|
||||||
properties: {
|
properties: {
|
||||||
configuration: {
|
configuration: {
|
||||||
'x-component': 'ConfigurationTable',
|
'x-component': 'ConfigurationTable',
|
||||||
@ -24,11 +25,12 @@ const schema: ISchema = {
|
|||||||
|
|
||||||
export const CollectionManagerShortcut = () => {
|
export const CollectionManagerShortcut = () => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<ActionContext.Provider value={{ visible, setVisible }}>
|
<ActionContext.Provider value={{ visible, setVisible }}>
|
||||||
<PluginManager.Toolbar.Item
|
<PluginManager.Toolbar.Item
|
||||||
icon={<DatabaseOutlined />}
|
icon={<DatabaseOutlined />}
|
||||||
title={'数据表配置'}
|
title={t('Collections & Fields')}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}}
|
}}
|
||||||
|
@ -5,6 +5,7 @@ import { uid } from '@formily/shared';
|
|||||||
import { Button, Dropdown, Menu } from 'antd';
|
import { Button, Dropdown, Menu } from 'antd';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useRequest } from '../../api-client';
|
import { useRequest } from '../../api-client';
|
||||||
import { ActionContext, SchemaComponent, useCompile } from '../../schema-component';
|
import { ActionContext, SchemaComponent, useCompile } from '../../schema-component';
|
||||||
import { useCreateAction } from '../action-hooks';
|
import { useCreateAction } from '../action-hooks';
|
||||||
@ -102,6 +103,7 @@ export const AddFieldAction = () => {
|
|||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [schema, setSchema] = useState({});
|
const [schema, setSchema] = useState({});
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<ActionContext.Provider value={{ visible, setVisible }}>
|
<ActionContext.Provider value={{ visible, setVisible }}>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
@ -132,7 +134,7 @@ export const AddFieldAction = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Button icon={<PlusOutlined />} type={'primary'}>
|
<Button icon={<PlusOutlined />} type={'primary'}>
|
||||||
添加字段
|
{t('Add field')}
|
||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<SchemaComponent schema={schema} components={{ ArrayTable }} scope={{ useCreateCollectionField }} />
|
<SchemaComponent schema={schema} components={{ ArrayTable }} scope={{ useCreateCollectionField }} />
|
||||||
|
@ -5,6 +5,7 @@ import { uid } from '@formily/shared';
|
|||||||
import { Button, Dropdown, Menu } from 'antd';
|
import { Button, Dropdown, Menu } from 'antd';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useRequest } from '../../api-client';
|
import { useRequest } from '../../api-client';
|
||||||
import { RecordProvider } from '../../record-provider';
|
import { RecordProvider } from '../../record-provider';
|
||||||
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
|
import { ActionContext, SchemaComponent, useActionContext, useCompile } from '../../schema-component';
|
||||||
@ -98,6 +99,7 @@ export const AddSubFieldAction = () => {
|
|||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
const [schema, setSchema] = useState({});
|
const [schema, setSchema] = useState({});
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<ActionContext.Provider value={{ visible, setVisible }}>
|
<ActionContext.Provider value={{ visible, setVisible }}>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
@ -122,7 +124,7 @@ export const AddSubFieldAction = () => {
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Button icon={<PlusOutlined />} type={'primary'}>
|
<Button icon={<PlusOutlined />} type={'primary'}>
|
||||||
添加字段
|
{t('Add field')}
|
||||||
</Button>
|
</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
<RecordProvider record={{}}>
|
<RecordProvider record={{}}>
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
import { ISchema, useField, useFieldSchema } from '@formily/react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { GeneralSchemaDesigner, SchemaSettings, useDesignable } from '../../../';
|
import { GeneralSchemaDesigner, SchemaSettings, useDesignable } from '../../../';
|
||||||
|
|
||||||
const InsertMenuItems = (props) => {
|
const InsertMenuItems = (props) => {
|
||||||
const { dn, refresh } = useDesignable();
|
|
||||||
const { eventKey, title, insertPosition } = props;
|
const { eventKey, title, insertPosition } = props;
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const { dn } = useDesignable();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const isSubMenu = fieldSchema['x-component'] === 'Menu.SubMenu';
|
const isSubMenu = fieldSchema['x-component'] === 'Menu.SubMenu';
|
||||||
if (!isSubMenu && insertPosition === 'beforeEnd') {
|
if (!isSubMenu && insertPosition === 'beforeEnd') {
|
||||||
@ -14,21 +16,21 @@ const InsertMenuItems = (props) => {
|
|||||||
<SchemaSettings.SubMenu eventKey={eventKey} title={title}>
|
<SchemaSettings.SubMenu eventKey={eventKey} title={title}>
|
||||||
<SchemaSettings.ModalItem
|
<SchemaSettings.ModalItem
|
||||||
eventKey={`${insertPosition}group`}
|
eventKey={`${insertPosition}group`}
|
||||||
title={'分组'}
|
title={t('Group')}
|
||||||
schema={
|
schema={
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
title: `${title}分组`,
|
title: t('Add group'),
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
title: '分组名称',
|
title: t('Menu item title'),
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
|
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
@ -48,21 +50,20 @@ const InsertMenuItems = (props) => {
|
|||||||
/>
|
/>
|
||||||
<SchemaSettings.ModalItem
|
<SchemaSettings.ModalItem
|
||||||
eventKey={`${insertPosition}page`}
|
eventKey={`${insertPosition}page`}
|
||||||
title={'页面'}
|
title={t('Page')}
|
||||||
schema={
|
schema={
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
title: `${title}页面`,
|
title: t('Add page'),
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
title: '菜单项名称',
|
title: t('Menu item title'),
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
|
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
@ -97,27 +98,27 @@ const InsertMenuItems = (props) => {
|
|||||||
/>
|
/>
|
||||||
<SchemaSettings.ModalItem
|
<SchemaSettings.ModalItem
|
||||||
eventKey={`${insertPosition}link`}
|
eventKey={`${insertPosition}link`}
|
||||||
title={'链接'}
|
title={t('Link')}
|
||||||
schema={
|
schema={
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
title: `${title}链接`,
|
title: t('Add link'),
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
title: '链接文字',
|
title: t('Menu item title'),
|
||||||
'x-component': 'Input',
|
|
||||||
'x-decorator': 'FormItem',
|
|
||||||
},
|
|
||||||
href: {
|
|
||||||
title: '链接',
|
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
|
href: {
|
||||||
|
title: t('Link'),
|
||||||
|
'x-component': 'Input',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as ISchema
|
} as ISchema
|
||||||
}
|
}
|
||||||
@ -141,24 +142,24 @@ export const MenuDesigner = () => {
|
|||||||
const field = useField();
|
const field = useField();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const { dn, refresh } = useDesignable();
|
const { dn, refresh } = useDesignable();
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<GeneralSchemaDesigner>
|
<GeneralSchemaDesigner>
|
||||||
<SchemaSettings.ModalItem
|
<SchemaSettings.ModalItem
|
||||||
title={'编辑'}
|
title={t('Edit')}
|
||||||
schema={
|
schema={
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
title: '编辑菜单项',
|
title: t('Edit menu item'),
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
|
title: t('Menu item title'),
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
title: '菜单项名称',
|
|
||||||
'x-component-props': {},
|
'x-component-props': {},
|
||||||
// description: `原字段标题:${collectionField?.uiSchema?.title}`,
|
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Menu item icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
@ -189,11 +190,15 @@ export const MenuDesigner = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<SchemaSettings.Divider />
|
<SchemaSettings.Divider />
|
||||||
<InsertMenuItems eventKey={'insertbeforeBegin'} title={'在前面插入'} insertPosition={'beforeBegin'} />
|
<InsertMenuItems eventKey={'insertbeforeBegin'} title={t('Insert before')} insertPosition={'beforeBegin'} />
|
||||||
<InsertMenuItems eventKey={'insertafterEnd'} title={'在后面插入'} insertPosition={'afterEnd'} />
|
<InsertMenuItems eventKey={'insertafterEnd'} title={t('Insert after')} insertPosition={'afterEnd'} />
|
||||||
<InsertMenuItems eventKey={'insertbeforeEnd'} title={'在里面插入'} insertPosition={'beforeEnd'} />
|
<InsertMenuItems eventKey={'insertbeforeEnd'} title={t('Insert inner')} insertPosition={'beforeEnd'} />
|
||||||
<SchemaSettings.Divider />
|
<SchemaSettings.Divider />
|
||||||
<SchemaSettings.Remove />
|
<SchemaSettings.Remove
|
||||||
|
confirm={{
|
||||||
|
title: t('Delete menu item'),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</GeneralSchemaDesigner>
|
</GeneralSchemaDesigner>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -46,7 +46,7 @@ export const GroupItem = itemWrap((props) => {
|
|||||||
<SchemaInitializer.Item
|
<SchemaInitializer.Item
|
||||||
{...props}
|
{...props}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const values = await FormDialog('添加分组', () => {
|
const values = await FormDialog(t('Add group'), () => {
|
||||||
return (
|
return (
|
||||||
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
||||||
<FormLayout layout={'vertical'}>
|
<FormLayout layout={'vertical'}>
|
||||||
@ -54,12 +54,12 @@ export const GroupItem = itemWrap((props) => {
|
|||||||
schema={{
|
schema={{
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
title: '分组标题',
|
title: t('Menu item title'),
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
@ -94,7 +94,7 @@ export const PageMenuItem = itemWrap((props) => {
|
|||||||
<SchemaInitializer.Item
|
<SchemaInitializer.Item
|
||||||
{...props}
|
{...props}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const values = await FormDialog('添加页面', () => {
|
const values = await FormDialog(t('Add page'), () => {
|
||||||
return (
|
return (
|
||||||
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
||||||
<FormLayout layout={'vertical'}>
|
<FormLayout layout={'vertical'}>
|
||||||
@ -102,12 +102,12 @@ export const PageMenuItem = itemWrap((props) => {
|
|||||||
schema={{
|
schema={{
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
title: '页面标题',
|
title: t('Menu item title'),
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
@ -157,7 +157,7 @@ export const LinkMenuItem = itemWrap((props) => {
|
|||||||
<SchemaInitializer.Item
|
<SchemaInitializer.Item
|
||||||
{...props}
|
{...props}
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
const values = await FormDialog('添加链接', () => {
|
const values = await FormDialog(t('Add link'), () => {
|
||||||
return (
|
return (
|
||||||
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
<SchemaComponentOptions scope={options.scope} components={{ ...options.components }}>
|
||||||
<FormLayout layout={'vertical'}>
|
<FormLayout layout={'vertical'}>
|
||||||
@ -165,20 +165,20 @@ export const LinkMenuItem = itemWrap((props) => {
|
|||||||
schema={{
|
schema={{
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
title: '链接文字',
|
title: t('Menu item title'),
|
||||||
'x-component': 'Input',
|
|
||||||
'x-decorator': 'FormItem',
|
|
||||||
},
|
|
||||||
href: {
|
|
||||||
title: '链接',
|
|
||||||
'x-component': 'Input',
|
'x-component': 'Input',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
title: '图标',
|
title: t('Icon'),
|
||||||
'x-component': 'IconPicker',
|
'x-component': 'IconPicker',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
|
href: {
|
||||||
|
title: t('Link'),
|
||||||
|
'x-component': 'Input',
|
||||||
|
'x-decorator': 'FormItem',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -29,6 +29,7 @@ export const useSchemaSettings = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
interface RemoveProps {
|
interface RemoveProps {
|
||||||
|
confirm?: any;
|
||||||
removeParentsIfNoChildren?: boolean;
|
removeParentsIfNoChildren?: boolean;
|
||||||
breakRemoveOn?: ISchema | ((s: ISchema) => boolean);
|
breakRemoveOn?: ISchema | ((s: ISchema) => boolean);
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import { SettingOutlined } from '@ant-design/icons';
|
|||||||
import { ISchema, useForm } from '@formily/react';
|
import { ISchema, useForm } from '@formily/react';
|
||||||
import { uid } from '@formily/shared';
|
import { uid } from '@formily/shared';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSystemSettings } from '.';
|
import { useSystemSettings } from '.';
|
||||||
import { PluginManager, useAPIClient, useRequest } from '..';
|
import { PluginManager, useAPIClient, useRequest } from '..';
|
||||||
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
|
import { ActionContext, SchemaComponent, useActionContext } from '../schema-component';
|
||||||
@ -54,7 +55,7 @@ const schema: ISchema = {
|
|||||||
},
|
},
|
||||||
'x-component': 'Action.Drawer',
|
'x-component': 'Action.Drawer',
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '系统设置',
|
title: '{{t("System settings")}}',
|
||||||
properties: {
|
properties: {
|
||||||
title: {
|
title: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
@ -69,7 +70,8 @@ const schema: ISchema = {
|
|||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component': 'Upload.Attachment',
|
'x-component': 'Upload.Attachment',
|
||||||
'x-component-props': {
|
'x-component-props': {
|
||||||
'action': 'attachments:upload'
|
action: 'attachments:upload',
|
||||||
|
multiple: false,
|
||||||
// accept: 'jpg,png'
|
// accept: 'jpg,png'
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -84,15 +86,15 @@ const schema: ISchema = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
allowSignUp: {
|
allowSignUp: {
|
||||||
type: 'string',
|
type: 'boolean',
|
||||||
title: '{{t("Allow sign up")}}',
|
default: true,
|
||||||
|
'x-content': '{{t("Allow sign up")}}',
|
||||||
'x-component': 'Checkbox',
|
'x-component': 'Checkbox',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
default: true,
|
|
||||||
},
|
},
|
||||||
footer1: {
|
footer1: {
|
||||||
'x-component': 'Action.Drawer.Footer',
|
|
||||||
type: 'void',
|
type: 'void',
|
||||||
|
'x-component': 'Action.Drawer.Footer',
|
||||||
properties: {
|
properties: {
|
||||||
cancel: {
|
cancel: {
|
||||||
title: 'Cancel',
|
title: 'Cancel',
|
||||||
@ -118,6 +120,7 @@ const schema: ISchema = {
|
|||||||
|
|
||||||
export const SystemSettingsShortcut = () => {
|
export const SystemSettingsShortcut = () => {
|
||||||
const [visible, setVisible] = useState(false);
|
const [visible, setVisible] = useState(false);
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<ActionContext.Provider value={{ visible, setVisible }}>
|
<ActionContext.Provider value={{ visible, setVisible }}>
|
||||||
<PluginManager.Toolbar.Item
|
<PluginManager.Toolbar.Item
|
||||||
@ -126,7 +129,7 @@ export const SystemSettingsShortcut = () => {
|
|||||||
setVisible(true);
|
setVisible(true);
|
||||||
}}
|
}}
|
||||||
icon={<SettingOutlined />}
|
icon={<SettingOutlined />}
|
||||||
title={'系统设置'}
|
title={t('System settings')}
|
||||||
/>
|
/>
|
||||||
<SchemaComponent
|
<SchemaComponent
|
||||||
scope={{ useSaveSystemSettingsValues, useSystemSettingsValues, useCloseAction }}
|
scope={{ useSaveSystemSettingsValues, useSystemSettingsValues, useCloseAction }}
|
||||||
|
@ -42,22 +42,22 @@ const schema: ISchema = {
|
|||||||
'x-decorator': 'Form',
|
'x-decorator': 'Form',
|
||||||
'x-component': 'Action.Drawer',
|
'x-component': 'Action.Drawer',
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '修改密码',
|
title: '{{t("Change password")}}',
|
||||||
properties: {
|
properties: {
|
||||||
oldPassword: {
|
oldPassword: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: '{{t("Old Password")}}',
|
title: '{{t("Old password")}}',
|
||||||
required: true,
|
required: true,
|
||||||
'x-component': 'Password',
|
'x-component': 'Password',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
},
|
},
|
||||||
newPassword: {
|
newPassword: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
title: '{{t("New Password")}}',
|
title: '{{t("New password")}}',
|
||||||
required: true,
|
required: true,
|
||||||
'x-component': 'Password',
|
'x-component': 'Password',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component-props': { placeholder: '{{t("New Password")}}', checkStrength: true, style: {} },
|
'x-component-props': { checkStrength: true, style: {} },
|
||||||
'x-reactions': [
|
'x-reactions': [
|
||||||
{
|
{
|
||||||
dependencies: ['.confirmPassword'],
|
dependencies: ['.confirmPassword'],
|
||||||
@ -72,10 +72,10 @@ const schema: ISchema = {
|
|||||||
confirmPassword: {
|
confirmPassword: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
required: true,
|
required: true,
|
||||||
title: '{{t("Confirm Password")}}',
|
title: '{{t("Confirm password")}}',
|
||||||
'x-component': 'Password',
|
'x-component': 'Password',
|
||||||
'x-decorator': 'FormItem',
|
'x-decorator': 'FormItem',
|
||||||
'x-component-props': { placeholder: '{{t("Confirm password")}}', checkStrength: true, style: {} },
|
'x-component-props': { checkStrength: true, style: {} },
|
||||||
'x-reactions': [
|
'x-reactions': [
|
||||||
{
|
{
|
||||||
dependencies: ['.newPassword'],
|
dependencies: ['.newPassword'],
|
||||||
|
@ -46,7 +46,7 @@ const schema: ISchema = {
|
|||||||
},
|
},
|
||||||
'x-component': 'Action.Drawer',
|
'x-component': 'Action.Drawer',
|
||||||
type: 'void',
|
type: 'void',
|
||||||
title: '个人资料',
|
title: '{{t("Edit profile")}}',
|
||||||
properties: {
|
properties: {
|
||||||
nickname: {
|
nickname: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -27,6 +27,7 @@ export class ErrorHandler {
|
|||||||
try {
|
try {
|
||||||
await next();
|
await next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
for (const handler of self.handlers) {
|
for (const handler of self.handlers) {
|
||||||
if (handler.guard(err)) {
|
if (handler.guard(err)) {
|
||||||
return handler.render(err, ctx);
|
return handler.render(err, ctx);
|
||||||
@ -34,7 +35,6 @@ export class ErrorHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.defaultHandler(err, ctx);
|
self.defaultHandler(err, ctx);
|
||||||
console.error(err);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
1
packages/plugin-error-handler/src/index.ts
Normal file
1
packages/plugin-error-handler/src/index.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export { PluginErrorHandler as default } from './server';
|
@ -1,10 +1,10 @@
|
|||||||
import { Plugin } from '@nocobase/server';
|
|
||||||
import { ErrorHandler } from './error-handler';
|
|
||||||
import { BaseError } from 'sequelize';
|
|
||||||
import zhCN from './locale/zh_CN';
|
|
||||||
import enUS from './locale/en_US';
|
|
||||||
import lodash from 'lodash';
|
|
||||||
import { compile } from '@formily/json-schema/lib/compiler';
|
import { compile } from '@formily/json-schema/lib/compiler';
|
||||||
|
import { Plugin } from '@nocobase/server';
|
||||||
|
import lodash from 'lodash';
|
||||||
|
import { BaseError } from 'sequelize';
|
||||||
|
import { ErrorHandler } from './error-handler';
|
||||||
|
import enUS from './locale/en_US';
|
||||||
|
import zhCN from './locale/zh_CN';
|
||||||
|
|
||||||
export class PluginErrorHandler extends Plugin {
|
export class PluginErrorHandler extends Plugin {
|
||||||
errorHandler: ErrorHandler = new ErrorHandler();
|
errorHandler: ErrorHandler = new ErrorHandler();
|
||||||
|
Loading…
Reference in New Issue
Block a user