improve code

This commit is contained in:
chenos 2021-08-26 10:30:52 +08:00
parent 0c678a013f
commit c74e8f03ad
4 changed files with 73 additions and 53 deletions

View File

@ -1,19 +1,24 @@
import React, { useContext, useEffect } from 'react';
import { Button, Dropdown, Menu } from 'antd';
import { Button, Dropdown, Menu, Select } from 'antd';
import { useHistory } from 'react-router-dom';
import { request, SchemaField } from '../../schemas';
import { AuthContext, useCurrentUser } from './Auth';
import { FormButtonGroup, FormDrawer, FormLayout, Submit } from '@formily/antd';
import { useState } from 'react';
export const UserInfo = () => {
const history = useHistory();
const { service, currentUser } = useContext(AuthContext);
const [visible, setVisible] = useState(false);
return (
<Dropdown
visible={visible}
onVisibleChange={setVisible}
overlay={
<Menu>
<Menu.Item
onClick={async () => {
setVisible(false);
const values = await FormDrawer('个人资料', () => {
return (
<FormLayout layout={'vertical'}>
@ -38,10 +43,7 @@ export const UserInfo = () => {
/>
<FormDrawer.Footer>
<FormButtonGroup align="right">
<Submit onSubmit={(values) => {
}}>
</Submit>
<Submit onSubmit={(values) => {}}></Submit>
</FormButtonGroup>
</FormDrawer.Footer>
</FormLayout>
@ -58,6 +60,20 @@ export const UserInfo = () => {
>
</Menu.Item>
<Menu.Item>
<Select
className={'roles-select'}
bordered={false}
style={{ minWidth: 100, paddingLeft: 0 }}
size={'small'}
defaultValue={'admin'}
options={[
{ label: '超级管理员', value: 'admin' },
{ label: '数据管理员', value: 'editor' },
{ label: '普通成员', value: 'member' },
]}
/>
</Menu.Item>
<Menu.Divider />
<Menu.Item
onClick={async () => {

View File

@ -32,7 +32,11 @@
// padding-bottom: 0 !important;
// }
// }
.roles-select {
.ant-select-selector {
padding-left: 0 !important;
}
}
.nb-spin-center {
position: absolute;
top: 0;

View File

@ -83,12 +83,10 @@ Chart.DesignableBar = observer((props) => {
const removed = deepRemove();
// console.log({ removed })
const last = removed.pop();
if (isGridRowOrCol(last)) {
await removeSchema(last);
}
await removeSchema(last);
}}
>
</Menu.Item>
</Menu>
}

View File

@ -98,9 +98,10 @@ const SideMenu = (props: any) => {
<Button
block
type={'dashed'}
icon={<PlusOutlined />}
className={`nb-add-new-menu-item menu-mode-inline designable-btn designable-btn-dash`}
>
<PlusOutlined />
</Button>
</Menu.AddNew>
</AntdMenu>
@ -212,9 +213,10 @@ export const Menu: any = observer((props: any) => {
mode === 'mix' ? 'horizontal' : mode
}`}
block
icon={<PlusOutlined />}
type={mode == 'inline' ? 'dashed' : 'primary'}
>
<PlusOutlined />
</Button>
</Menu.AddNew>
</AntdMenu>
@ -402,7 +404,7 @@ Menu.AddNew = observer((props: any) => {
const schemas = {
'Menu.Link': {
icon: <MenuOutlined />,
title: '创建菜单项',
title: '创建页面',
schema: {
type: 'object',
properties: {
@ -424,7 +426,7 @@ Menu.AddNew = observer((props: any) => {
},
'Menu.SubMenu': {
icon: <GroupOutlined />,
title: '创建菜单分组',
title: '创建分组',
schema: {
type: 'object',
properties: {
@ -446,7 +448,7 @@ Menu.AddNew = observer((props: any) => {
},
'Menu.URL': {
icon: <LinkOutlined />,
title: '创建自定义链接',
title: '创建链接',
schema: {
type: 'object',
properties: {
@ -465,7 +467,7 @@ Menu.AddNew = observer((props: any) => {
},
'x-component-props.href': {
type: 'string',
title: '自定义链接',
title: '链接',
required: true,
'x-decorator': 'FormItem',
'x-component': 'Input',
@ -497,14 +499,14 @@ Menu.AddNew = observer((props: any) => {
await createSchema(data);
}}
>
<AntdMenu.Item key={'Menu.Link'} icon={<MenuOutlined />}>
</AntdMenu.Item>
<AntdMenu.Item key={'Menu.SubMenu'} icon={<GroupOutlined />}>
</AntdMenu.Item>
<AntdMenu.Item key={'Menu.Link'} icon={<MenuOutlined />}>
</AntdMenu.Item>
<AntdMenu.Item key={'Menu.URL'} icon={<LinkOutlined />}>
</AntdMenu.Item>
</AntdMenu>
}
@ -520,7 +522,7 @@ Menu.DesignableBar = (props) => {
const schemas = {
'Menu.Action': {
icon: <MenuOutlined />,
title: '菜单项',
title: '页面',
schema: {
type: 'object',
properties: {
@ -542,7 +544,7 @@ Menu.DesignableBar = (props) => {
},
'Menu.Item': {
icon: <MenuOutlined />,
title: '菜单项',
title: '页面',
schema: {
type: 'object',
properties: {
@ -564,7 +566,7 @@ Menu.DesignableBar = (props) => {
},
'Menu.Link': {
icon: <MenuOutlined />,
title: '菜单项',
title: '页面',
schema: {
type: 'object',
properties: {
@ -586,7 +588,7 @@ Menu.DesignableBar = (props) => {
},
'Menu.SubMenu': {
icon: <GroupOutlined />,
title: '菜单分组',
title: '分组',
schema: {
type: 'object',
properties: {
@ -608,7 +610,7 @@ Menu.DesignableBar = (props) => {
},
'Menu.URL': {
icon: <LinkOutlined />,
title: '自定义链接',
title: '链接',
schema: {
type: 'object',
properties: {
@ -627,7 +629,7 @@ Menu.DesignableBar = (props) => {
},
'x-component-props.href': {
type: 'string',
title: '自定义链接',
title: '链接',
required: true,
'x-decorator': 'FormItem',
'x-component': 'Input',
@ -864,23 +866,23 @@ Menu.DesignableBar = (props) => {
icon={<ArrowUpOutlined />}
title={`${mode == 'inline' ? '上' : '左'}插入`}
>
<AntdMenu.Item
key={'insertBefore.Menu.Link'}
icon={<MenuOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'insertBefore.Menu.SubMenu'}
icon={<GroupOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'insertBefore.Menu.Link'}
icon={<MenuOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'insertBefore.Menu.URL'}
icon={<LinkOutlined />}
>
</AntdMenu.Item>
</AntdMenu.SubMenu>
<AntdMenu.SubMenu
@ -888,23 +890,23 @@ Menu.DesignableBar = (props) => {
icon={<ArrowDownOutlined />}
title={`${mode == 'inline' ? '下' : '右'}插入`}
>
<AntdMenu.Item
key={'insertAfter.Menu.Link'}
icon={<MenuOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'insertAfter.Menu.SubMenu'}
icon={<GroupOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'insertAfter.Menu.Link'}
icon={<MenuOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'insertAfter.Menu.URL'}
icon={<LinkOutlined />}
>
</AntdMenu.Item>
</AntdMenu.SubMenu>
{isSubMenu && (
@ -913,23 +915,23 @@ Menu.DesignableBar = (props) => {
icon={<ArrowRightOutlined />}
title={'向里插入'}
>
<AntdMenu.Item
key={'appendChild.Menu.Link'}
icon={<MenuOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'appendChild.Menu.SubMenu'}
icon={<GroupOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'appendChild.Menu.Link'}
icon={<MenuOutlined />}
>
</AntdMenu.Item>
<AntdMenu.Item
key={'appendChild.Menu.URL'}
icon={<LinkOutlined />}
>
</AntdMenu.Item>
</AntdMenu.SubMenu>
)}
@ -996,8 +998,8 @@ Menu.DesignableBar = (props) => {
key={'delete'}
onClick={() => {
Modal.confirm({
title: '删除菜单',
content: '确认删除此菜单项吗?',
title: `删除${formConfig.title}`,
content: '删除后无法恢复,确定要删除吗?',
onOk: async () => {
const target = remove();
await removeSchema(target);