Skip to content

Commit

Permalink
feat: 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft committed Nov 18, 2024
1 parent 82bd842 commit 9645e02
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 337 deletions.
94 changes: 41 additions & 53 deletions packages/editor/src/components/Searchbar/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,63 +1,51 @@
import { memo } from 'react';
import { Button, Form, Input, Radio, Space, Segmented, Tooltip } from 'antd';
import { PlusOutlined, RedoOutlined, BarsOutlined, AppstoreOutlined, ArrowRightOutlined, ArrowLeftOutlined } from '@ant-design/icons';
import styles from './index.module.less';
import { useLocation } from 'react-router-dom';
import { Button, Form, Input, Space, Segmented, Tooltip } from 'antd';
import { PlusOutlined, RedoOutlined, BarsOutlined, AppstoreOutlined, ArrowLeftOutlined } from '@ant-design/icons';
import styles from './index.module.less';

const SearchBar = memo((props: any) => {
const SearchBar = (props: any) => {
const { pathname } = useLocation();
const { form, from, submit, refresh, onCreate } = props;
const options = [
{ label: '我的', value: 1 },
{ label: '市场', value: 2 },
];

return (
<>
<div className={styles.searchBar}>
<div className={styles.searchBarForm}>
<Form form={form} layout="inline" initialValues={{ type: 1 }}>
{props.showGroup === false ? null : (
<Form.Item name="type">
<Radio.Group options={options} onChange={submit} optionType="button" buttonStyle="solid" />
</Form.Item>
)}

<Form.Item name="keyword" style={{ width: 200 }}>
<Input placeholder={`请输入${from}名称`} onPressEnter={submit} />
</Form.Item>
<Form.Item>
<Space>
<Button type="primary" onClick={submit} size="middle">
搜索
</Button>
</Space>
</Form.Item>
</Form>
</div>
<Space>
{pathname === '/projects' && (
<Segmented
onChange={(value) => props.onViewChange(value)}
options={[
{ value: 'project', icon: <AppstoreOutlined /> },
{ value: 'list', icon: <BarsOutlined /> },
]}
/>
)}
{pathname === '/project/pages' && (
<Tooltip title="返回">
<Button icon={<ArrowLeftOutlined />} shape="circle" onClick={() => history.back()}></Button>
</Tooltip>
)}
<Button type="dashed" icon={<PlusOutlined />} onClick={onCreate}>
新建{from}
</Button>
<Button shape="circle" icon={<RedoOutlined />} onClick={() => refresh()}></Button>
</Space>
<div className={styles.searchBar}>
<div className={styles.searchBarForm}>
<Form form={form} layout="inline" initialValues={{ type: 1 }}>
<Form.Item name="keyword" style={{ width: 200 }}>
<Input placeholder={`请输入${from}名称`} onPressEnter={submit} />
</Form.Item>
<Form.Item>
<Space>
<Button type="primary" onClick={submit} size="middle">
搜索
</Button>
</Space>
</Form.Item>
</Form>
</div>
</>
<Space>
{pathname === '/projects' && (
<Segmented
onChange={(value) => props.onViewChange(value)}
options={[
{ value: 'project', icon: <AppstoreOutlined />, label: '项目' },
{ value: 'page', icon: <BarsOutlined />, label: '页面' },
]}
/>
)}
{pathname === '/project/pages' && (
<Tooltip title="返回">
<Button icon={<ArrowLeftOutlined />} shape="circle" onClick={() => history.back()}></Button>
</Tooltip>
)}
<Button type="dashed" icon={<PlusOutlined />} onClick={onCreate}>
新建{from}
</Button>
<Button shape="circle" icon={<RedoOutlined />} onClick={refresh}></Button>
</Space>
</div>
);
});
};

export default SearchBar;
export default memo(SearchBar);
2 changes: 1 addition & 1 deletion packages/editor/src/layout/components/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ const Header = memo(() => {
</>
}
>
<Button type="text" style={{ color: 'var(--mars-theme-text-color)' }} onClick={() => window.open('http://docs.marsview.cc', '_blank')}>
<Button type="text" style={{ color: 'var(--mars-theme-text-color)' }}>
联系我
</Button>
</Popover>
Expand Down
31 changes: 17 additions & 14 deletions packages/editor/src/pages/admin/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,25 +172,28 @@ const Config: React.FC = memo(() => {
</Form.Item>
<div className={styles.editBtn}>
{type === 'detail' ? (
<Button
type="primary"
icon={<EditOutlined />}
onClick={() => {
setType('edit');
}}
>
编辑
</Button>
<Space>
<Button
type="primary"
icon={<EditOutlined />}
onClick={() => {
setType('edit');
}}
>
编辑
</Button>
<Button icon={<RollbackOutlined />} onClick={() => history.back()}>
返回
</Button>
</Space>
) : (
<Space>
<Button type="primary" icon={<SaveOutlined />} loading={loading} onClick={handleSubmit}>
保存
</Button>
{id !== '0' && (
<Button icon={<RollbackOutlined />} onClick={() => setType('detail')}>
取消
</Button>
)}
<Button icon={<RollbackOutlined />} onClick={() => setType('detail')}>
取消
</Button>
</Space>
)}
</div>
Expand Down
149 changes: 0 additions & 149 deletions packages/editor/src/pages/home/project/Category.tsx

This file was deleted.

Loading

0 comments on commit 9645e02

Please sign in to comment.