开发: 登录等功能

This commit is contained in:
zhengw
2023-04-07 17:38:15 +08:00
parent f639dc8284
commit 5834254a8f
27 changed files with 1475 additions and 153 deletions

View File

@@ -6,10 +6,10 @@ const NoFoundPage: React.FC = () => (
<Result
status="404"
title="404"
subTitle="Sorry, the page you visited does not exist."
subTitle="抱歉,你访问的页面不存在"
extra={
<Button type="primary" onClick={() => history.push('/')}>
Back Home
</Button>
}
/>

View File

@@ -0,0 +1,271 @@
import { PlayCircleOutlined } from '@ant-design/icons';
import styles from './index.module.scss';
export const ChatBar: React.FC = () => {
return (
<div>
<div className={styles.chatLeft}>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div className={styles.content}>
message.useMessage context
contextHolder message
ConfigProvider
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</div>
</div>
</div>
<div className={styles.chatRight}>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div className={styles.content}>
message.useMessage context
contextHolder message
ConfigProvider
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</div>
</div>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
</div>
);
};
interface IChatTimeProps {
msgtime: number;
}
export const ChatTime: React.FC<IChatTimeProps> = (props) => {
function padWith(value: string | number) {
return `${value}`.padStart(2, '0');
}
const weekStr = ['日', '一', '二', '三', '四', '五', '六'];
const formatTime = () => {
const now = new Date();
const msgtime = new Date(props.msgtime);
console.log(msgtime.toLocaleString());
const yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
const dayDiff =
(Date.parse(
`${now.getFullYear()}-${padWith(now.getMonth() + 1)}-${padWith(now.getDate())} 00:00:00`,
) -
props.msgtime) /
(24 * 60 * 60 * 1000) +
1;
if (now.getFullYear() == msgtime.getFullYear()) {
if (
now.getFullYear() == msgtime.getFullYear() &&
now.getMonth() == msgtime.getMonth() &&
now.getDate() == msgtime.getDate()
) {
// 当天
return `${padWith(msgtime.getHours())}:${padWith(msgtime.getMinutes())}`;
} else if (
yesterday.getFullYear() == msgtime.getFullYear() &&
yesterday.getMonth() == msgtime.getMonth() &&
yesterday.getDate() == msgtime.getDate()
) {
// 昨天
return `昨天 ${padWith(msgtime.getHours())}:${padWith(msgtime.getMinutes())}`;
} else if (dayDiff < 7) {
// 星期
return `星期${weekStr[msgtime.getDay()]} ${padWith(msgtime.getHours())}:${padWith(
msgtime.getMinutes(),
)}`;
} else {
// 超过7天
return `${padWith(msgtime.getMonth() + 1)}${padWith(msgtime.getDate())}${padWith(
msgtime.getHours(),
)}:${padWith(msgtime.getMinutes())}`;
}
} else {
// 跨年
return `${msgtime.getFullYear()}${padWith(msgtime.getMonth() + 1)}${padWith(
msgtime.getDate(),
)}${padWith(msgtime.getHours())}:${padWith(msgtime.getMinutes())}`;
}
};
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<div
style={{
background: '#DADADA',
color: '#fff',
padding: '0 8px',
borderRadius: 4,
lineHeight: 1,
height: 26,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
{formatTime()}
</div>
</div>
);
};
export const ChatRevoke: React.FC = () => {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<span
style={{
background: '#DADADA',
color: '#fff',
padding: '0 8px',
borderRadius: 4,
lineHeight: 1,
height: 26,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
"xxxxx"
</span>
</div>
);
};
export const ChatAgreeOrNot: React.FC = () => {
return (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<span
style={{
background: '#DADADA',
color: '#fff',
padding: '0 8px',
borderRadius: 4,
lineHeight: 1,
height: 26,
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
[]
</span>
</div>
);
};
// 语音
export const ChatVoice = () => {
return (
<div className={styles.chatRight}>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div className={styles.content} style={{ cursor: 'pointer' }}>
<span style={{ lineHeight: 1, marginRight: 4 }}>2"</span>
<svg viewBox="0 0 1024 1024" width="18" height="18">
<path
d="M913.568627 518.334145C913.568627 483.422393 894.958532 451.162604 864.748584 433.706729 834.538616 416.250852 797.318425 416.250852 767.108477 433.706729 736.89851 451.162604 718.288414 483.422393 718.288414 518.334145 718.288414 553.245895 736.89851 585.505684 767.108477 602.961559 797.318425 620.417436 834.538616 620.417436 864.748584 602.961559 894.958532 585.505684 913.568627 553.245895 913.568627 518.334145L913.568627 518.334145ZM581.566143 215.288946C581.566143 215.288946 593.269057 203.098427 620.669932 203.098427 650.6546 203.098427 674.950626 227.414165 674.950626 257.423171 674.950626 290.452615 648.917554 305.250663 636.758739 309.031723 568.451875 353.599725 523.116685 430.436655 523.116685 518.116824 523.116685 605.970743 568.603889 682.938067 637.149606 727.440872 650.915177 731.852057 674.950626 743.064634 674.950626 778.940765 674.950626 808.949772 650.6546 833.265507 620.669932 833.265507 593.269057 833.265507 581.566143 821.07499 581.566143 821.07499 481.233659 757.536806 414.403283 645.801687 414.403283 518.181916 414.403283 390.562145 481.233659 278.805502 581.566143 215.288946L581.566143 215.288946ZM348.376225 14.135304C348.376225 14.135304 365.941399 7.529394 392.690949 7.529394 428.668185 7.529394 457.82781 36.73442 457.82781 72.719107 457.82781 98.186537 406.282822 128.195544 388.54391 137.474179 297.265513 229.695819 240.704994 356.381112 240.704994 496.452082 240.704994 650.321426 309.055287 787.849957 416.661363 881.418878 440.740242 890.980031 457.82781 914.426591 457.82781 941.914889 457.82781 977.899576 428.668185 1007.104602 392.690949 1007.104602 363.314276 1007.104602 345.336511 998.13011 345.336511 998.13011 202.12236 882.635664 110.431373 705.732666 110.431373 507.316947 110.431373 307.532423 203.446734 129.564556 348.376225 14.135304L348.376225 14.135304Z"
fill="#000000"
></path>
</svg>
</div>
</div>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
);
};
// 视频
export const ChatVideo = () => {
return (
<div className={styles.chatRight}>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div className={styles.video}>
<PlayCircleOutlined style={{ color: '#fff', fontSize: 40 }} />
<span className={styles.videoTime}>0:46</span>
</div>
</div>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
);
};
// 名片
export const ChatCard = () => {
return (
<div className={styles.chatRight}>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div
className={styles.content}
style={{ cursor: 'pointer', flexDirection: 'column', minWidth: 300 }}
>
<div style={{ display: 'flex' }}>
<div className={styles.chatAvatar} style={{ marginRight: 12 }}>
<img
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
alt=""
/>
</div>
<div className={styles.corpname}></div>
</div>
<div>corpname</div>
<div style={{ color: '#999' }}>corpname2</div>
<div style={{ color: '#999', borderTop: '1px solid #ddd' }}></div>
</div>
</div>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
);
};
// 表情
export const ChatEmotion = () => {
return (
<div className={styles.chatRight}>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div
className={styles.content}
style={{ cursor: 'pointer', flexDirection: 'column', minWidth: 300 }}
>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
);
};
// 文件
export const ChatFile = () => {
return (
<div className={styles.chatRight}>
<div className={styles.chatContentBox}>
<div className={styles.name}>name</div>
<div
className={styles.content}
style={{ cursor: 'pointer', flexDirection: 'column', minWidth: 300 }}
>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
<div className={styles.chatAvatar}>
<img src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg" alt="" />
</div>
</div>
);
};

View File

@@ -0,0 +1,109 @@
.chatLeft {
display: flex;
.chatContentBox {
display: inline-flex;
flex-direction: column;
flex-shrink: 0;
max-width: 60%;
margin-left: 16px;
}
}
.chatAvatar {
flex-shrink: 0;
width: 34px;
height: 34px;
img {
max-width: 100%;
max-height: 100%;
object-fit: cover;
background-color: #fff;
border-radius: 2px;
}
}
.name {
margin-bottom: 8px;
color: #999;
}
.content {
position: relative;
display: flex;
justify-content: center;
padding: 12px;
word-break: break-all;
background-color: #fff;
border-radius: 4px;
&::before {
position: absolute;
top: 12px;
left: -6px;
width: 12px;
height: 12px;
background-color: #fff;
transform: rotate(45deg);
content: '';
}
&:hover,
&:hover::before {
background-color: #ebebeb;
}
}
.chatRight {
display: flex;
justify-content: end;
.name {
text-align: right;
}
.chatContentBox {
display: inline-flex;
flex-direction: column;
flex-shrink: 0;
justify-content: end;
max-width: 60%;
margin-right: 16px;
}
.content {
background-color: #95ec69;
&::before {
right: -6px;
left: initial;
background-color: #95ec69;
}
&:hover,
&:hover::before {
background-color: #89d961;
}
}
}
.video {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 176px;
height: 144px;
background-color: #333;
border-radius: 4px;
cursor: pointer;
.videoTime {
position: absolute;
right: 8px;
bottom: 8px;
color: #fff;
}
}

View File

@@ -0,0 +1,161 @@
import { SearchBarPlugin, SearchBottonsCardPlugin } from '@/components/SearchBarPlugin';
import { PageContainer } from '@ant-design/pro-components';
import { Button, Col, Form, Input, Pagination, Row, Select, Table } from 'antd';
import React, { useState } from 'react';
import { ChatBar, ChatTime } from './ChatBar';
interface DataType {
key: React.Key;
firstName: string;
lastName: string;
age: number;
address: string;
tags: string[];
}
const ChatLogs: React.FC = () => {
const [param, setParam] = useState({
curr_page: 1,
page_count: 20,
});
const data: DataType[] = [
{
key: '1',
firstName: 'John',
lastName: 'Brown',
age: 32,
address: 'New York No. 1 Lake Park',
tags: ['nice', 'developer'],
},
{
key: '2',
firstName: 'Jim',
lastName: 'Green',
age: 42,
address: 'London No. 1 Lake Park',
tags: ['loser'],
},
{
key: '3',
firstName: 'Joe',
lastName: 'Black',
age: 32,
address: 'Sydney No. 1 Lake Park',
tags: ['cool', 'teacher'],
},
];
// const { notification } = App.useApp();
return (
<PageContainer>
<SearchBarPlugin>
<Form>
<Row gutter={{ xs: 0, sm: 16 }}>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Select
defaultValue="lucy"
style={{ width: '100%' }}
onChange={() => {}}
options={[
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'Yiminghe', label: 'yiminghe' },
]}
/>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Select
defaultValue="lucy"
style={{ width: '100%' }}
onChange={() => {}}
options={[
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'Yiminghe', label: 'yiminghe' },
{ value: 'disabled', label: 'Disabled', disabled: true },
]}
/>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
</Row>
</Form>
</SearchBarPlugin>
<SearchBottonsCardPlugin>
<Row justify={'center'}>
<Button type="primary"></Button>
</Row>
</SearchBottonsCardPlugin>
<ChatTime msgtime={1680761136755}></ChatTime>
<ChatBar></ChatBar>
<Table
size="middle"
dataSource={data}
style={{ padding: 16, borderRadius: 6, background: '#fff', marginTop: 16 }}
pagination={false}
bordered={true}
>
<Table.Column title="ID" dataIndex={'key'}></Table.Column>
<Table.Column title="firstName" dataIndex={'firstName'}></Table.Column>
</Table>
<Pagination
style={{
background: '#fff',
borderRadius: 6,
marginTop: 16,
padding: 16,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
current={param.curr_page}
pageSize={param.page_count}
total={1000}
pageSizeOptions={[10, 20, 50, 100]}
onShowSizeChange={(current, size) => {
param.page_count = size;
setParam({ ...param });
}}
showTotal={(total, range) => {
return <span style={{ lineHeight: 1 }}>{total}</span>;
}}
onChange={(page, pageSize) => {
param.curr_page = page;
setParam({ ...param });
}}
/>
</PageContainer>
);
};
export default ChatLogs;

View File

@@ -0,0 +1,42 @@
.departmentItem {
display: flex;
flex-shrink: 0;
justify-content: space-between;
flex: 1;
width: 100%;
.name {
flex-shrink: 0;
min-width: 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
flex: 1;
}
.btnsBox {
display: none;
.edit {
width: 24px;
color: #1890ff;
&:hover {
color: #40a9ff;
}
}
.del {
width: 24px;
color: #ff4d4f;
&:hover {
color: #ff7875;
}
}
}
&:hover .btnsBox {
display: inline-flex;
}
}

View File

@@ -0,0 +1,407 @@
import { SearchBarPlugin, SearchBottonsCardPlugin } from '@/components/SearchBarPlugin';
import { post } from '@/services/ajax';
import { DeleteOutlined, FormOutlined } from '@ant-design/icons';
import { PageContainer } from '@ant-design/pro-components';
import {
Button,
Col,
Form,
Input,
Modal,
Pagination,
Popconfirm,
Row,
Select,
Table,
Tree,
} from 'antd';
import React, { useState } from 'react';
import styles from './index.module.scss';
interface DataType {
key: React.Key;
firstName: string;
lastName: string;
age: number;
address: string;
tags: string[];
}
const DepartmentsList: React.FC = () => {
const [param, setParam] = useState({
curr_page: 1,
page_count: 20,
});
const [departmentID, setDepartmentsID] = useState(1);
const departments = [
{
id: 1,
name: '福州晨丰科技有限公司',
parent_id: 0,
sort: 2147483447,
department_leader: 'chenf,LiXiang,CFRS',
children: [
{
id: 2,
name: '总经办',
parent_id: 1,
sort: 2147483447,
department_leader: 'chenf',
children: null,
},
{
id: 3,
name: '研发部',
parent_id: 1,
sort: 2147483247,
department_leader: 'yangxb',
children: [
{
id: 18,
name: '.Net组',
parent_id: 3,
sort: 100005000,
department_leader: 'xief',
children: null,
},
{
id: 19,
name: '平台组',
parent_id: 3,
sort: 100004000,
department_leader: 'yangxb',
children: null,
},
{
id: 20,
name: 'CAD组',
parent_id: 3,
sort: 100003000,
department_leader: 'chenx',
children: null,
},
{
id: 21,
name: '测试组',
parent_id: 3,
sort: 100001000,
department_leader: '',
children: null,
},
{
id: 23,
name: '是的防守对方',
parent_id: 3,
sort: 100000000,
department_leader: '',
children: null,
},
{
id: 24,
name: '12',
parent_id: 3,
sort: 99999000,
department_leader: '',
children: [
{
id: 25,
name: '3',
parent_id: 24,
sort: 100000000,
department_leader: '',
children: null,
},
],
},
{
id: 181,
name: '.Net组',
parent_id: 3,
sort: 100005000,
department_leader: 'xief',
children: null,
},
{
id: 191,
name: '平台组',
parent_id: 3,
sort: 100004000,
department_leader: 'yangxb',
children: null,
},
{
id: 201,
name: 'CAD组',
parent_id: 3,
sort: 100003000,
department_leader: 'chenx',
children: null,
},
{
id: 211,
name: '测试组',
parent_id: 3,
sort: 100001000,
department_leader: '',
children: null,
},
{
id: 231,
name: '是的防守对方是的防守对方是的防守对方是的防守对方',
parent_id: 3,
sort: 100000000,
department_leader: '',
children: null,
},
],
},
],
},
];
const data: DataType[] = [
{
key: '2',
firstName: 'Jim',
lastName: 'Green',
age: 42,
address: 'London No. 1 Lake Park',
tags: ['loser'],
},
{
key: '3',
firstName: 'Joe',
lastName: 'Black',
age: 32,
address: 'Sydney No. 1 Lake Park',
tags: ['cool', 'teacher'],
},
];
const [open, setOpen] = useState(false);
const [popOpen, setPopOpen] = useState(-1);
return (
<PageContainer>
<div style={{ display: 'flex' }}>
<div
style={{
width: 260,
flexShrink: 0,
minHeight: 'calc(100vh - 55px - 60px - 96px)',
maxHeight: 'calc(100vh - 55px - 60px)',
overflow: 'auto',
marginRight: 12,
background: '#fff',
position: 'sticky',
top: 64,
padding: '12px 0',
}}
>
<Tree
className={'department-tree'}
blockNode
selectedKeys={[departmentID]}
defaultExpandAll
style={{}}
treeData={departments}
fieldNames={{ title: 'name', key: 'id' }}
onSelect={(selectedKeys) => {
console.log(selectedKeys);
if (selectedKeys.length) {
setDepartmentsID(Number(selectedKeys[0]));
}
}}
titleRender={(nodeData: any) => {
// console.log(nodeData);
return (
<div className={styles.departmentItem}>
<div className={styles.name} title={nodeData.name}>
{nodeData.name}
</div>
<div className={styles.btnsBox}>
<FormOutlined
title="修改"
onClick={(e) => {
e.stopPropagation();
setOpen(true);
}}
className={styles.edit}
/>
<Popconfirm
title="确认删除?"
open={popOpen == nodeData.id}
onCancel={(e) => {
setPopOpen(-1);
e?.stopPropagation();
}}
onConfirm={(e) => {
e?.stopPropagation();
console.log(nodeData.id);
}}
>
<DeleteOutlined
title="删除"
onClick={(e) => {
e.stopPropagation();
setPopOpen(nodeData.id);
}}
className={styles.del}
/>
</Popconfirm>
</div>
</div>
);
}}
></Tree>
</div>
<Modal
open={open}
title="修改部门"
onCancel={() => setOpen(false)}
centered
onOk={() => {}}
>
<Form>
<Form.Item label="名称">
<Input type="text"></Input>
</Form.Item>
</Form>
</Modal>
<div style={{ flexGrow: 1, minWidth: 0 }}>
<SearchBarPlugin>
<Form>
<Row gutter={{ xs: 0, sm: 16 }}>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Select
defaultValue="lucy"
style={{ width: '100%' }}
onChange={() => {}}
options={[
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'Yiminghe', label: 'yiminghe' },
]}
/>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Select
defaultValue="lucy"
style={{ width: '100%' }}
onChange={() => {}}
options={[
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'Yiminghe', label: 'yiminghe' },
{ value: 'disabled', label: 'Disabled', disabled: true },
]}
/>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
<Col xs={24} sm={12} md={6}>
<Form.Item label="用户名">
<Input autoComplete="off"></Input>
</Form.Item>
</Col>
</Row>
</Form>
</SearchBarPlugin>
<SearchBottonsCardPlugin>
<Row justify={'center'}>
<Button
type="primary"
onClick={() => {
post({
url: '/Departments/List',
}).then((res) => {});
}}
>
</Button>
</Row>
</SearchBottonsCardPlugin>
<Table
size="middle"
dataSource={data}
style={{ padding: 16, borderRadius: 6, background: '#fff', marginTop: 16 }}
pagination={false}
bordered={true}
>
<Table.Column title="ID" dataIndex={'key'}></Table.Column>
<Table.Column title="firstName" dataIndex={'firstName'}></Table.Column>
<Table.Column
width={90}
title="操作"
render={(_text, record: any) => {
return (
<Button
type="primary"
onClick={() => {
console.log(record);
}}
>
{record.firstName}
</Button>
);
}}
></Table.Column>
</Table>
<Pagination
style={{
background: '#fff',
borderRadius: 6,
marginTop: 16,
padding: 16,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
current={param.curr_page}
pageSize={param.page_count}
total={1000}
pageSizeOptions={[10, 20, 50, 100]}
onShowSizeChange={(current, size) => {
param.page_count = size;
setParam({ ...param });
}}
showTotal={(total, range) => {
return <span style={{ lineHeight: 1 }}>{total}</span>;
}}
onChange={(page, pageSize) => {
param.curr_page = page;
setParam({ ...param });
}}
/>
</div>
</div>
</PageContainer>
);
};
export default DepartmentsList;

View File

@@ -10,7 +10,7 @@ import {
ProFormTextArea,
ProTable,
} from '@ant-design/pro-components';
import { FormattedMessage, useIntl } from '@umijs/max';
import { FormattedMessage, useIntl, useModel } from '@umijs/max';
import { Button, Drawer, Input, message } from 'antd';
import React, { useRef, useState } from 'react';
import type { FormValueType } from './components/UpdateForm';
@@ -241,8 +241,33 @@ const TableList: React.FC = () => {
},
];
const { add, minus, counter } = useModel('demo', (ret) => ({
add: ret.increment,
minus: ret.decrement,
counter: ret.counter,
}));
return (
<PageContainer>
<div style={{ marginBottom: 12 }}>
<Button
onClick={() => {
add();
}}
style={{ marginRight: 12 }}
>
+1
</Button>
<Button
onClick={() => {
minus();
}}
style={{ marginRight: 12 }}
>
-1
</Button>
<span>{counter}</span>
</div>
<ProTable<API.RuleListItem, API.PageParams>
headerTitle={intl.formatMessage({
id: 'pages.searchTable.title',

View File

@@ -1,5 +1,5 @@
import Footer from '@/components/Footer';
import { login } from '@/services/ant-design-pro/api';
import { IAjaxReturn, post } from '@/services/ajax';
import { getFakeCaptcha } from '@/services/ant-design-pro/login';
import {
AlipayCircleOutlined,
@@ -16,11 +16,12 @@ import {
ProFormText,
} from '@ant-design/pro-components';
import { useEmotionCss } from '@ant-design/use-emotion-css';
import { FormattedMessage, history, SelectLang, useIntl, useModel, Helmet } from '@umijs/max';
import { Alert, message, Tabs } from 'antd';
import Settings from '../../../../config/defaultSettings';
import { FormattedMessage, Helmet, history, SelectLang, useIntl, useModel } from '@umijs/max';
import { Alert, App, message, Tabs } from 'antd';
import { stringify as qsStringify } from 'qs';
import React, { useState } from 'react';
import { flushSync } from 'react-dom';
import Settings from '../../../../config/defaultSettings';
const ActionIcons = () => {
const langClassName = useEmotionCss(({ token }) => {
@@ -113,33 +114,34 @@ const Login: React.FC = () => {
});
}
};
const { notification } = App.useApp();
window.NotificationCF = notification;
const handleSubmit = async (values: API.LoginParams) => {
try {
// 登录
const msg = await login({ ...values, type });
if (msg.status === 'ok') {
const defaultLoginSuccessMessage = intl.formatMessage({
id: 'pages.login.success',
defaultMessage: '登录成功!',
const data = {
user: values.username,
password: values.password,
};
post({ url: '/User/Login', data: qsStringify(data) }).then((res: IAjaxReturn) => {
if (res && res.err_code == 0) {
notification.success({
message: '登录成功',
description: '登录成功',
});
flushSync(() => {
// 登录成功!
setInitialState((s) => ({
...s,
currentUser: res.data,
currentAuthority: 'admin',
}));
});
message.success(defaultLoginSuccessMessage);
await fetchUserInfo();
const urlParams = new URL(window.location.href).searchParams;
history.push(urlParams.get('redirect') || '/');
return;
}
console.log(msg);
// 如果失败去设置用户错误信息
setUserLoginState(msg);
} catch (error) {
const defaultLoginFailureMessage = intl.formatMessage({
id: 'pages.login.failure',
defaultMessage: '登录失败,请重试!',
});
console.log(error);
message.error(defaultLoginFailureMessage);
}
});
};
const { status, type: loginType } = userLoginState;
@@ -154,32 +156,50 @@ const Login: React.FC = () => {
- {Settings.title}
</title>
</Helmet>
<Lang />
{/* <Lang /> */}
<div
style={{
flex: '1',
padding: '32px 0',
}}
>
{/* <ChatTime msgtime={1680713999000}></ChatTime>
<ChatTime msgtime={1680763041000}></ChatTime>
<ChatTime msgtime={1680710399000}></ChatTime>
<ChatTime msgtime={1680623999000}></ChatTime>
<ChatTime msgtime={1680537599000}></ChatTime>
<ChatTime msgtime={1680451199000}></ChatTime>
<ChatTime msgtime={1680331041000}></ChatTime>
<ChatTime msgtime={1680195599000}></ChatTime>
<ChatTime msgtime={1680244641000}></ChatTime>
<ChatTime msgtime={1680191999000}></ChatTime>
<ChatTime msgtime={1680158241000}></ChatTime>
<ChatRevoke></ChatRevoke>
<ChatAgreeOrNot />
<ChatVoice></ChatVoice>
<ChatVideo></ChatVideo>
<ChatCard></ChatCard>
<ChatEmotion></ChatEmotion>
<ChatBar></ChatBar> */}
<LoginForm
contentStyle={{
minWidth: 280,
maxWidth: '75vw',
}}
logo={<img alt="logo" src="/logo.svg" />}
title="Ant Design"
subTitle={intl.formatMessage({ id: 'pages.layouts.userLayout.title' })}
title="scrm.antd"
subTitle={<div style={{ height: 30 }}></div>}
initialValues={{
autoLogin: true,
}}
actions={[
<FormattedMessage
key="loginWith"
id="pages.login.loginWith"
defaultMessage="其他登录方式"
/>,
<ActionIcons key="icons" />,
]}
// actions={[
// <FormattedMessage
// key="loginWith"
// id="pages.login.loginWith"
// defaultMessage="其他登录方式"
// />,
// <ActionIcons key="icons" />,
// ]}
onFinish={async (values) => {
await handleSubmit(values as API.LoginParams);
}}
@@ -196,13 +216,13 @@ const Login: React.FC = () => {
defaultMessage: '账户密码登录',
}),
},
{
key: 'mobile',
label: intl.formatMessage({
id: 'pages.login.phoneLogin.tab',
defaultMessage: '手机号登录',
}),
},
// {
// key: 'mobile',
// label: intl.formatMessage({
// id: 'pages.login.phoneLogin.tab',
// defaultMessage: '手机号登录',
// }),
// },
]}
/>
@@ -246,7 +266,7 @@ const Login: React.FC = () => {
}}
placeholder={intl.formatMessage({
id: 'pages.login.password.placeholder',
defaultMessage: '密码: ant.design',
defaultMessage: '请输入密码',
})}
rules={[
{
@@ -364,6 +384,7 @@ const Login: React.FC = () => {
</LoginForm>
</div>
<Footer />
<div style={{ height: 12 }}></div>
</div>
);
};

View File

@@ -86,8 +86,12 @@ const InfoCard: React.FC<{
const Welcome: React.FC = () => {
const { token } = theme.useToken();
const { initialState } = useModel('@@initialState');
const count = useModel('demo');
return (
<PageContainer>
<span>{count.counter}</span>
<Card
style={{
borderRadius: 8,