开发: 删除antd自带文件
This commit is contained in:
@@ -1,176 +0,0 @@
|
||||
import { Request, Response } from 'express';
|
||||
import moment from 'moment';
|
||||
import { parse } from 'url';
|
||||
|
||||
// mock tableListDataSource
|
||||
const genList = (current: number, pageSize: number) => {
|
||||
const tableListDataSource: API.RuleListItem[] = [];
|
||||
|
||||
for (let i = 0; i < pageSize; i += 1) {
|
||||
const index = (current - 1) * 10 + i;
|
||||
tableListDataSource.push({
|
||||
key: index,
|
||||
disabled: i % 6 === 0,
|
||||
href: 'https://ant.design',
|
||||
avatar: [
|
||||
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
][i % 2],
|
||||
name: `TradeCode ${index}`,
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: Math.floor(Math.random() * 1000),
|
||||
status: Math.floor(Math.random() * 10) % 4,
|
||||
updatedAt: moment().format('YYYY-MM-DD'),
|
||||
createdAt: moment().format('YYYY-MM-DD'),
|
||||
progress: Math.ceil(Math.random() * 100),
|
||||
});
|
||||
}
|
||||
tableListDataSource.reverse();
|
||||
return tableListDataSource;
|
||||
};
|
||||
|
||||
let tableListDataSource = genList(1, 100);
|
||||
|
||||
function getRule(req: Request, res: Response, u: string) {
|
||||
let realUrl = u;
|
||||
if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
|
||||
realUrl = req.url;
|
||||
}
|
||||
const { current = 1, pageSize = 10 } = req.query;
|
||||
const params = parse(realUrl, true).query as unknown as API.PageParams &
|
||||
API.RuleListItem & {
|
||||
sorter: any;
|
||||
filter: any;
|
||||
};
|
||||
|
||||
let dataSource = [...tableListDataSource].slice(
|
||||
((current as number) - 1) * (pageSize as number),
|
||||
(current as number) * (pageSize as number),
|
||||
);
|
||||
if (params.sorter) {
|
||||
const sorter = JSON.parse(params.sorter);
|
||||
dataSource = dataSource.sort((prev, next) => {
|
||||
let sortNumber = 0;
|
||||
(Object.keys(sorter) as Array<keyof API.RuleListItem>).forEach((key) => {
|
||||
let nextSort = next?.[key] as number;
|
||||
let preSort = prev?.[key] as number;
|
||||
if (sorter[key] === 'descend') {
|
||||
if (preSort - nextSort > 0) {
|
||||
sortNumber += -1;
|
||||
} else {
|
||||
sortNumber += 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (preSort - nextSort > 0) {
|
||||
sortNumber += 1;
|
||||
} else {
|
||||
sortNumber += -1;
|
||||
}
|
||||
});
|
||||
return sortNumber;
|
||||
});
|
||||
}
|
||||
if (params.filter) {
|
||||
const filter = JSON.parse(params.filter as any) as {
|
||||
[key: string]: string[];
|
||||
};
|
||||
if (Object.keys(filter).length > 0) {
|
||||
dataSource = dataSource.filter((item) => {
|
||||
return (Object.keys(filter) as Array<keyof API.RuleListItem>).some((key) => {
|
||||
if (!filter[key]) {
|
||||
return true;
|
||||
}
|
||||
if (filter[key].includes(`${item[key]}`)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (params.name) {
|
||||
dataSource = dataSource.filter((data) => data?.name?.includes(params.name || ''));
|
||||
}
|
||||
const result = {
|
||||
data: dataSource,
|
||||
total: tableListDataSource.length,
|
||||
success: true,
|
||||
pageSize,
|
||||
current: parseInt(`${params.current}`, 10) || 1,
|
||||
};
|
||||
|
||||
return res.json(result);
|
||||
}
|
||||
|
||||
function postRule(req: Request, res: Response, u: string, b: Request) {
|
||||
let realUrl = u;
|
||||
if (!realUrl || Object.prototype.toString.call(realUrl) !== '[object String]') {
|
||||
realUrl = req.url;
|
||||
}
|
||||
|
||||
const body = (b && b.body) || req.body;
|
||||
const { method, name, desc, key } = body;
|
||||
|
||||
switch (method) {
|
||||
/* eslint no-case-declarations:0 */
|
||||
case 'delete':
|
||||
tableListDataSource = tableListDataSource.filter((item) => key.indexOf(item.key) === -1);
|
||||
break;
|
||||
case 'post':
|
||||
(() => {
|
||||
const i = Math.ceil(Math.random() * 10000);
|
||||
const newRule: API.RuleListItem = {
|
||||
key: tableListDataSource.length,
|
||||
href: 'https://ant.design',
|
||||
avatar: [
|
||||
'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
][i % 2],
|
||||
name,
|
||||
owner: '曲丽丽',
|
||||
desc,
|
||||
callNo: Math.floor(Math.random() * 1000),
|
||||
status: Math.floor(Math.random() * 10) % 2,
|
||||
updatedAt: moment().format('YYYY-MM-DD'),
|
||||
createdAt: moment().format('YYYY-MM-DD'),
|
||||
progress: Math.ceil(Math.random() * 100),
|
||||
};
|
||||
tableListDataSource.unshift(newRule);
|
||||
return res.json(newRule);
|
||||
})();
|
||||
return;
|
||||
|
||||
case 'update':
|
||||
(() => {
|
||||
let newRule = {};
|
||||
tableListDataSource = tableListDataSource.map((item) => {
|
||||
if (item.key === key) {
|
||||
newRule = { ...item, desc, name };
|
||||
return { ...item, desc, name };
|
||||
}
|
||||
return item;
|
||||
});
|
||||
return res.json(newRule);
|
||||
})();
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const result = {
|
||||
list: tableListDataSource,
|
||||
pagination: {
|
||||
total: tableListDataSource.length,
|
||||
},
|
||||
};
|
||||
|
||||
res.json(result);
|
||||
}
|
||||
|
||||
export default {
|
||||
'GET /api/rule': getRule,
|
||||
'POST /api/rule': postRule,
|
||||
};
|
115
mock/notices.ts
115
mock/notices.ts
@@ -1,115 +0,0 @@
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
const getNotices = (req: Request, res: Response) => {
|
||||
res.json({
|
||||
data: [
|
||||
{
|
||||
id: '000000001',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/MSbDR4FR2MUAAAAAAAAAAAAAFl94AQBr',
|
||||
title: '你收到了 14 份新周报',
|
||||
datetime: '2017-08-09',
|
||||
type: 'notification',
|
||||
},
|
||||
{
|
||||
id: '000000002',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/hX-PTavYIq4AAAAAAAAAAAAAFl94AQBr',
|
||||
title: '你推荐的 曲妮妮 已通过第三轮面试',
|
||||
datetime: '2017-08-08',
|
||||
type: 'notification',
|
||||
},
|
||||
{
|
||||
id: '000000003',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/jHX5R5l3QjQAAAAAAAAAAAAAFl94AQBr',
|
||||
title: '这种模板可以区分多种通知类型',
|
||||
datetime: '2017-08-07',
|
||||
read: true,
|
||||
type: 'notification',
|
||||
},
|
||||
{
|
||||
id: '000000004',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/Wr4mQqx6jfwAAAAAAAAAAAAAFl94AQBr',
|
||||
title: '左侧图标用于区分不同的类型',
|
||||
datetime: '2017-08-07',
|
||||
type: 'notification',
|
||||
},
|
||||
{
|
||||
id: '000000005',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/Mzj_TbcWUj4AAAAAAAAAAAAAFl94AQBr',
|
||||
title: '内容不要超过两行字,超出时自动截断',
|
||||
datetime: '2017-08-07',
|
||||
type: 'notification',
|
||||
},
|
||||
{
|
||||
id: '000000006',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/eXLzRbPqQE4AAAAAAAAAAAAAFl94AQBr',
|
||||
title: '曲丽丽 评论了你',
|
||||
description: '描述信息描述信息描述信息',
|
||||
datetime: '2017-08-07',
|
||||
type: 'message',
|
||||
clickClose: true,
|
||||
},
|
||||
{
|
||||
id: '000000007',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/w5mRQY2AmEEAAAAAAAAAAAAAFl94AQBr',
|
||||
title: '朱偏右 回复了你',
|
||||
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
|
||||
datetime: '2017-08-07',
|
||||
type: 'message',
|
||||
clickClose: true,
|
||||
},
|
||||
{
|
||||
id: '000000008',
|
||||
avatar:
|
||||
'https://mdn.alipayobjects.com/yuyan_qk0oxh/afts/img/wPadR5M9918AAAAAAAAAAAAAFl94AQBr',
|
||||
title: '标题',
|
||||
description: '这种模板用于提醒谁与你发生了互动,左侧放『谁』的头像',
|
||||
datetime: '2017-08-07',
|
||||
type: 'message',
|
||||
clickClose: true,
|
||||
},
|
||||
{
|
||||
id: '000000009',
|
||||
title: '任务名称',
|
||||
description: '任务需要在 2017-01-12 20:00 前启动',
|
||||
extra: '未开始',
|
||||
status: 'todo',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
id: '000000010',
|
||||
title: '第三方紧急代码变更',
|
||||
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
|
||||
extra: '马上到期',
|
||||
status: 'urgent',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
id: '000000011',
|
||||
title: '信息安全考试',
|
||||
description: '指派竹尔于 2017-01-09 前完成更新并发布',
|
||||
extra: '已耗时 8 天',
|
||||
status: 'doing',
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
id: '000000012',
|
||||
title: 'ABCD 版本发布',
|
||||
description: '冠霖提交于 2017-01-06,需在 2017-01-07 前完成代码变更任务',
|
||||
extra: '进行中',
|
||||
status: 'processing',
|
||||
type: 'event',
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
'GET /api/notices': getNotices,
|
||||
};
|
@@ -1,324 +0,0 @@
|
||||
module.exports = {
|
||||
'GET /api/currentUser': {
|
||||
data: {
|
||||
name: 'Serati Ma',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png',
|
||||
userid: '00000001',
|
||||
email: 'antdesign@alipay.com',
|
||||
signature: '海纳百川,有容乃大',
|
||||
title: '交互专家',
|
||||
group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
|
||||
tags: [
|
||||
{ key: '0', label: '很有想法的' },
|
||||
{ key: '1', label: '专注设计' },
|
||||
{ key: '2', label: '辣~' },
|
||||
{ key: '3', label: '大长腿' },
|
||||
{ key: '4', label: '川妹子' },
|
||||
{ key: '5', label: '海纳百川' },
|
||||
],
|
||||
notifyCount: 12,
|
||||
unreadCount: 11,
|
||||
country: 'China',
|
||||
geographic: {
|
||||
province: { label: '浙江省', key: '330000' },
|
||||
city: { label: '杭州市', key: '330100' },
|
||||
},
|
||||
address: '西湖区工专路 77 号',
|
||||
phone: '0752-268888888',
|
||||
},
|
||||
},
|
||||
'GET /api/rule': {
|
||||
data: [
|
||||
{
|
||||
key: 99,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 99',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 503,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 81,
|
||||
},
|
||||
{
|
||||
key: 98,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 98',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 164,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 12,
|
||||
},
|
||||
{
|
||||
key: 97,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 97',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 174,
|
||||
status: '1',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 81,
|
||||
},
|
||||
{
|
||||
key: 96,
|
||||
disabled: true,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 96',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 914,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 7,
|
||||
},
|
||||
{
|
||||
key: 95,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 95',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 698,
|
||||
status: '2',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 82,
|
||||
},
|
||||
{
|
||||
key: 94,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 94',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 488,
|
||||
status: '1',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 14,
|
||||
},
|
||||
{
|
||||
key: 93,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 93',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 580,
|
||||
status: '2',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 77,
|
||||
},
|
||||
{
|
||||
key: 92,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 92',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 244,
|
||||
status: '3',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 58,
|
||||
},
|
||||
{
|
||||
key: 91,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 91',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 959,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 66,
|
||||
},
|
||||
{
|
||||
key: 90,
|
||||
disabled: true,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 90',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 958,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 72,
|
||||
},
|
||||
{
|
||||
key: 89,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 89',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 301,
|
||||
status: '2',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 2,
|
||||
},
|
||||
{
|
||||
key: 88,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 88',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 277,
|
||||
status: '1',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 12,
|
||||
},
|
||||
{
|
||||
key: 87,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 87',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 810,
|
||||
status: '1',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 82,
|
||||
},
|
||||
{
|
||||
key: 86,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 86',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 780,
|
||||
status: '3',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 22,
|
||||
},
|
||||
{
|
||||
key: 85,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 85',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 705,
|
||||
status: '3',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 12,
|
||||
},
|
||||
{
|
||||
key: 84,
|
||||
disabled: true,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 84',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 203,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 79,
|
||||
},
|
||||
{
|
||||
key: 83,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 83',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 491,
|
||||
status: '2',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 59,
|
||||
},
|
||||
{
|
||||
key: 82,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 82',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 73,
|
||||
status: '0',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 100,
|
||||
},
|
||||
{
|
||||
key: 81,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png',
|
||||
name: 'TradeCode 81',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 406,
|
||||
status: '3',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 61,
|
||||
},
|
||||
{
|
||||
key: 80,
|
||||
disabled: false,
|
||||
href: 'https://ant.design',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png',
|
||||
name: 'TradeCode 80',
|
||||
owner: '曲丽丽',
|
||||
desc: '这是一段描述',
|
||||
callNo: 112,
|
||||
status: '2',
|
||||
updatedAt: '2022-12-06T05:00:57.040Z',
|
||||
createdAt: '2022-12-06T05:00:57.040Z',
|
||||
progress: 20,
|
||||
},
|
||||
],
|
||||
total: 100,
|
||||
success: true,
|
||||
pageSize: 20,
|
||||
current: 1,
|
||||
},
|
||||
'POST /api/login/outLogin': { data: {}, success: true },
|
||||
'POST /api/login/account': {
|
||||
status: 'ok',
|
||||
type: 'account',
|
||||
currentAuthority: 'admin',
|
||||
},
|
||||
};
|
@@ -1,5 +0,0 @@
|
||||
export default {
|
||||
'/api/auth_routes': {
|
||||
'/form/advanced-form': { authority: ['admin', 'user'] },
|
||||
},
|
||||
};
|
203
mock/user.ts
203
mock/user.ts
@@ -1,203 +0,0 @@
|
||||
import { Request, Response } from 'express';
|
||||
|
||||
const waitTime = (time: number = 100) => {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve(true);
|
||||
}, time);
|
||||
});
|
||||
};
|
||||
|
||||
async function getFakeCaptcha(req: Request, res: Response) {
|
||||
await waitTime(2000);
|
||||
return res.json('captcha-xxx');
|
||||
}
|
||||
|
||||
const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
|
||||
|
||||
/**
|
||||
* 当前用户的权限,如果为空代表没登录
|
||||
* current user access, if is '', user need login
|
||||
* 如果是 pro 的预览,默认是有权限的
|
||||
*/
|
||||
let access = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site' ? 'admin' : '';
|
||||
|
||||
const getAccess = () => {
|
||||
return access;
|
||||
};
|
||||
|
||||
// 代码中会兼容本地 service mock 以及部署站点的静态数据
|
||||
export default {
|
||||
// 支持值为 Object 和 Array
|
||||
'GET /api/currentUser': (req: Request, res: Response) => {
|
||||
if (!getAccess()) {
|
||||
res.status(401).send({
|
||||
data: {
|
||||
isLogin: false,
|
||||
},
|
||||
errorCode: '401',
|
||||
errorMessage: '请先登录!',
|
||||
success: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.send({
|
||||
success: true,
|
||||
data: {
|
||||
name: 'Serati Ma',
|
||||
avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png',
|
||||
userid: '00000001',
|
||||
email: 'antdesign@alipay.com',
|
||||
signature: '海纳百川,有容乃大',
|
||||
title: '交互专家',
|
||||
group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED',
|
||||
tags: [
|
||||
{
|
||||
key: '0',
|
||||
label: '很有想法的',
|
||||
},
|
||||
{
|
||||
key: '1',
|
||||
label: '专注设计',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
label: '辣~',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
label: '大长腿',
|
||||
},
|
||||
{
|
||||
key: '4',
|
||||
label: '川妹子',
|
||||
},
|
||||
{
|
||||
key: '5',
|
||||
label: '海纳百川',
|
||||
},
|
||||
],
|
||||
notifyCount: 12,
|
||||
unreadCount: 11,
|
||||
country: 'China',
|
||||
access: getAccess(),
|
||||
geographic: {
|
||||
province: {
|
||||
label: '浙江省',
|
||||
key: '330000',
|
||||
},
|
||||
city: {
|
||||
label: '杭州市',
|
||||
key: '330100',
|
||||
},
|
||||
},
|
||||
address: '西湖区工专路 77 号',
|
||||
phone: '0752-268888888',
|
||||
},
|
||||
});
|
||||
},
|
||||
// GET POST 可省略
|
||||
'GET /api/users': [
|
||||
{
|
||||
key: '1',
|
||||
name: 'John Brown',
|
||||
age: 32,
|
||||
address: 'New York No. 1 Lake Park',
|
||||
},
|
||||
{
|
||||
key: '2',
|
||||
name: 'Jim Green',
|
||||
age: 42,
|
||||
address: 'London No. 1 Lake Park',
|
||||
},
|
||||
{
|
||||
key: '3',
|
||||
name: 'Joe Black',
|
||||
age: 32,
|
||||
address: 'Sidney No. 1 Lake Park',
|
||||
},
|
||||
],
|
||||
'POST /api/login/account': async (req: Request, res: Response) => {
|
||||
const { password, username, type } = req.body;
|
||||
await waitTime(2000);
|
||||
if (password === 'ant.design' && username === 'admin') {
|
||||
res.send({
|
||||
status: 'ok',
|
||||
type,
|
||||
currentAuthority: 'admin',
|
||||
});
|
||||
access = 'admin';
|
||||
return;
|
||||
}
|
||||
if (password === 'ant.design' && username === 'user') {
|
||||
res.send({
|
||||
status: 'ok',
|
||||
type,
|
||||
currentAuthority: 'user',
|
||||
});
|
||||
access = 'user';
|
||||
return;
|
||||
}
|
||||
if (type === 'mobile') {
|
||||
res.send({
|
||||
status: 'ok',
|
||||
type,
|
||||
currentAuthority: 'admin',
|
||||
});
|
||||
access = 'admin';
|
||||
return;
|
||||
}
|
||||
|
||||
res.send({
|
||||
status: 'error',
|
||||
type,
|
||||
currentAuthority: 'guest',
|
||||
});
|
||||
access = 'guest';
|
||||
},
|
||||
'POST /api/login/outLogin': (req: Request, res: Response) => {
|
||||
access = '';
|
||||
res.send({ data: {}, success: true });
|
||||
},
|
||||
'POST /api/register': (req: Request, res: Response) => {
|
||||
res.send({ status: 'ok', currentAuthority: 'user', success: true });
|
||||
},
|
||||
'GET /api/500': (req: Request, res: Response) => {
|
||||
res.status(500).send({
|
||||
timestamp: 1513932555104,
|
||||
status: 500,
|
||||
error: 'error',
|
||||
message: 'error',
|
||||
path: '/base/category/list',
|
||||
});
|
||||
},
|
||||
'GET /api/404': (req: Request, res: Response) => {
|
||||
res.status(404).send({
|
||||
timestamp: 1513932643431,
|
||||
status: 404,
|
||||
error: 'Not Found',
|
||||
message: 'No message available',
|
||||
path: '/base/category/list/2121212',
|
||||
});
|
||||
},
|
||||
'GET /api/403': (req: Request, res: Response) => {
|
||||
res.status(403).send({
|
||||
timestamp: 1513932555104,
|
||||
status: 403,
|
||||
error: 'Forbidden',
|
||||
message: 'Forbidden',
|
||||
path: '/base/category/list',
|
||||
});
|
||||
},
|
||||
'GET /api/401': (req: Request, res: Response) => {
|
||||
res.status(401).send({
|
||||
timestamp: 1513932555104,
|
||||
status: 401,
|
||||
error: 'Unauthorized',
|
||||
message: 'Unauthorized',
|
||||
path: '/base/category/list',
|
||||
});
|
||||
},
|
||||
|
||||
'GET /api/login/captcha': getFakeCaptcha,
|
||||
};
|
@@ -77,7 +77,7 @@ export const GroupListWidget: React.FC<IProps> = (props) => {
|
||||
}, 300);
|
||||
}}
|
||||
>
|
||||
<span>内部群聊</span>
|
||||
<span>内部群聊({groupObj.inner.length})</span>
|
||||
{visible == 'inner' ? <UpOutlined /> : <DownOutlined />}
|
||||
</div>
|
||||
<div
|
||||
@@ -102,7 +102,7 @@ export const GroupListWidget: React.FC<IProps> = (props) => {
|
||||
}, 300);
|
||||
}}
|
||||
>
|
||||
<span>外部群聊</span>
|
||||
<span>外部群聊({groupObj.outer.length})</span>
|
||||
{visible == 'outer' ? <UpOutlined /> : <DownOutlined />}
|
||||
</div>
|
||||
<div
|
||||
@@ -127,7 +127,7 @@ export const GroupListWidget: React.FC<IProps> = (props) => {
|
||||
}, 300);
|
||||
}}
|
||||
>
|
||||
<span>已解散群聊</span>
|
||||
<span>解散群聊({groupObj.diss.length})</span>
|
||||
{visible == 'diss' ? <UpOutlined /> : <DownOutlined />}
|
||||
</div>
|
||||
<div
|
||||
@@ -139,7 +139,7 @@ export const GroupListWidget: React.FC<IProps> = (props) => {
|
||||
return groupListItem(item);
|
||||
})}
|
||||
<div style={{ lineHeight: '34px', color: '#999', textAlign: 'center' }}>
|
||||
{groupObj.diss.length == 0 ? '暂无已解散群聊' : ''}
|
||||
{groupObj.diss.length == 0 ? '暂无解散群聊' : ''}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -102,7 +102,7 @@ export const ChatBar: React.FC<IChatItem> = (props) => {
|
||||
<div className={styles.chatLeft}>
|
||||
<div
|
||||
className={styles.chatAvatar}
|
||||
style={{ background: props.from?.avatar ? '#fff' : '' }}
|
||||
style={{ background: props.to?.avatar ? '#fff' : '' }}
|
||||
>
|
||||
{props.to?.avatar ? (
|
||||
<img src={props.to?.avatar} alt="" />
|
||||
|
@@ -325,12 +325,13 @@ const ChatLogs: React.FC = () => {
|
||||
};
|
||||
|
||||
const checkCustFollowsIsEmpty = (state: number) => {
|
||||
let count = 0;
|
||||
for (const el of custFollowsList) {
|
||||
if (el.name.includes(searchWord['1']) && el.state == state) {
|
||||
return 1;
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
return count;
|
||||
};
|
||||
|
||||
const checkInnerIsEmpty = () => {
|
||||
@@ -455,7 +456,7 @@ const ChatLogs: React.FC = () => {
|
||||
setDelFollowListShow(!delFollowListShow);
|
||||
}}
|
||||
>
|
||||
<span>已删联系人</span>
|
||||
<span>已删联系人({checkCustFollowsIsEmpty(0)})</span>
|
||||
{delFollowListShow ? <UpOutlined /> : <DownOutlined />}
|
||||
</div>
|
||||
<div
|
||||
|
@@ -1,85 +0,0 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { request } from '@umijs/max';
|
||||
|
||||
/** 获取当前的用户 GET /api/currentUser */
|
||||
export async function currentUser(options?: { [key: string]: any }) {
|
||||
return request<{
|
||||
data: API.CurrentUser;
|
||||
}>('/api/currentUser', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 退出登录接口 POST /api/login/outLogin */
|
||||
export async function outLogin(options?: { [key: string]: any }) {
|
||||
return request<Record<string, any>>('/api/login/outLogin', {
|
||||
method: 'POST',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 登录接口 POST /api/login/account */
|
||||
export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
|
||||
return request<API.LoginResult>('/api/login/account', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
data: body,
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 此处后端没有提供注释 GET /api/notices */
|
||||
export async function getNotices(options?: { [key: string]: any }) {
|
||||
return request<API.NoticeIconList>('/api/notices', {
|
||||
method: 'GET',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取规则列表 GET /api/rule */
|
||||
export async function rule(
|
||||
params: {
|
||||
// query
|
||||
/** 当前的页码 */
|
||||
current?: number;
|
||||
/** 页面的容量 */
|
||||
pageSize?: number;
|
||||
},
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<API.RuleList>('/api/rule', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 新建规则 PUT /api/rule */
|
||||
export async function updateRule(options?: { [key: string]: any }) {
|
||||
return request<API.RuleListItem>('/api/rule', {
|
||||
method: 'PUT',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 新建规则 POST /api/rule */
|
||||
export async function addRule(options?: { [key: string]: any }) {
|
||||
return request<API.RuleListItem>('/api/rule', {
|
||||
method: 'POST',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
||||
|
||||
/** 删除规则 DELETE /api/rule */
|
||||
export async function removeRule(options?: { [key: string]: any }) {
|
||||
return request<Record<string, any>>('/api/rule', {
|
||||
method: 'DELETE',
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
// API 更新时间:
|
||||
// API 唯一标识:
|
||||
import * as api from './api';
|
||||
import * as login from './login';
|
||||
export default {
|
||||
api,
|
||||
login,
|
||||
};
|
@@ -1,21 +0,0 @@
|
||||
// @ts-ignore
|
||||
/* eslint-disable */
|
||||
import { request } from '@umijs/max';
|
||||
|
||||
/** 发送验证码 POST /api/login/captcha */
|
||||
export async function getFakeCaptcha(
|
||||
params: {
|
||||
// query
|
||||
/** 手机号 */
|
||||
phone?: string;
|
||||
},
|
||||
options?: { [key: string]: any },
|
||||
) {
|
||||
return request<API.FakeCaptcha>('/api/login/captcha', {
|
||||
method: 'GET',
|
||||
params: {
|
||||
...params,
|
||||
},
|
||||
...(options || {}),
|
||||
});
|
||||
}
|
63
src/services/ant-design-pro/typings.d.ts
vendored
63
src/services/ant-design-pro/typings.d.ts
vendored
@@ -32,73 +32,10 @@ declare namespace API {
|
||||
currentAuthority?: string;
|
||||
};
|
||||
|
||||
type PageParams = {
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
};
|
||||
|
||||
type RuleListItem = {
|
||||
key?: number;
|
||||
disabled?: boolean;
|
||||
href?: string;
|
||||
avatar?: string;
|
||||
name?: string;
|
||||
owner?: string;
|
||||
desc?: string;
|
||||
callNo?: number;
|
||||
status?: number;
|
||||
updatedAt?: string;
|
||||
createdAt?: string;
|
||||
progress?: number;
|
||||
};
|
||||
|
||||
type RuleList = {
|
||||
data?: RuleListItem[];
|
||||
/** 列表的内容总数 */
|
||||
total?: number;
|
||||
success?: boolean;
|
||||
};
|
||||
|
||||
type FakeCaptcha = {
|
||||
code?: number;
|
||||
status?: string;
|
||||
};
|
||||
|
||||
type LoginParams = {
|
||||
username?: string;
|
||||
password?: string;
|
||||
autoLogin?: boolean;
|
||||
type?: string;
|
||||
};
|
||||
|
||||
type ErrorResponse = {
|
||||
/** 业务约定的错误码 */
|
||||
errorCode: string;
|
||||
/** 业务上的错误信息 */
|
||||
errorMessage?: string;
|
||||
/** 业务上的请求是否成功 */
|
||||
success?: boolean;
|
||||
};
|
||||
|
||||
type NoticeIconList = {
|
||||
data?: NoticeIconItem[];
|
||||
/** 列表的内容总数 */
|
||||
total?: number;
|
||||
success?: boolean;
|
||||
};
|
||||
|
||||
type NoticeIconItemType = 'notification' | 'message' | 'event';
|
||||
|
||||
type NoticeIconItem = {
|
||||
id?: string;
|
||||
extra?: string;
|
||||
key?: string;
|
||||
read?: boolean;
|
||||
avatar?: string;
|
||||
title?: string;
|
||||
status?: string;
|
||||
datetime?: string;
|
||||
description?: string;
|
||||
type?: NoticeIconItemType;
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user