From 7047fc75d8d33ad7608c05f655e760f4e824808b Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Fri, 13 Jul 2018 10:08:33 +0800 Subject: [PATCH] 提交修改 --- _mock/_api.ts | 271 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 271 insertions(+), 0 deletions(-) diff --git a/_mock/_api.ts b/_mock/_api.ts new file mode 100644 index 0000000..04b577c --- /dev/null +++ b/_mock/_api.ts @@ -0,0 +1,271 @@ +import { MockRequest } from '@delon/mock'; +// region: mock data + +const titles = [ + 'Alipay', + 'Angular', + 'Ant Design', + 'Ant Design Pro', + 'Bootstrap', + 'React', + 'Vue', + 'Webpack' +]; + +const avatars = [ + 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay + 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular + 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design + 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro + 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap + 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React + 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue + 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png' // Webpack +]; +const covers = [ + 'https://gw.alipayobjects.com/zos/rmsportal/HrxcVbrKnCJOZvtzSqjN.png', + 'https://gw.alipayobjects.com/zos/rmsportal/alaPpKWajEbIYEUvvVNf.png', + 'https://gw.alipayobjects.com/zos/rmsportal/RLwlKSYGSXGHuWSojyvp.png', + 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png' +]; +const desc = [ + '������������������������������ ���������������������������������������', + '���������������������������������������������������������������������������', + '������������������������������������������������������', + '������������������������������������������������������������������', + '���������������������������������������������������������������������' +]; + +const user = [ + '������', + 'cipchk', + '���������', + '���������', + '���������', + '���������', + '���������', + '���������', + '������', + '������', + '���������', + '������' +]; + +// endregion + +function getFakeList(count: number = 20): any[] { + const list = []; + for (let i = 0; i < count; i += 1) { + list.push({ + id: `fake-list-${i}`, + owner: user[i % 10], + title: titles[i % 8], + avatar: avatars[i % 8], + cover: parseInt((i / 4).toString(), 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)], + status: ['active', 'exception', 'normal'][i % 3], + percent: Math.ceil(Math.random() * 50) + 50, + logo: avatars[i % 8], + href: 'https://ant.design', + updatedAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)), + createdAt: new Date(new Date().getTime() - (1000 * 60 * 60 * 2 * i)), + subDescription: desc[i % 5], + description: '���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������', + activeUser: Math.ceil(Math.random() * 100000) + 100000, + newUser: Math.ceil(Math.random() * 1000) + 1000, + star: Math.ceil(Math.random() * 100) + 100, + like: Math.ceil(Math.random() * 100) + 100, + message: Math.ceil(Math.random() * 10) + 10, + content: '��������������������������������������� ant.design��������������������������������������������������������������������������������������������������������������������������������������� ant.design���������������������������������������������������������������������������������������������������������������', + members: [ + { + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', + name: '���������', + }, + { + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', + name: '���������', + }, + { + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', + name: '���������', + }, + ] + }); + } + + return list; +} + +function getNotice(): any[] { + return [ + { + id: 'xxx1', + title: titles[0], + logo: avatars[0], + description: '������������������������������ ���������������������������������������', + updatedAt: new Date(), + member: '���������������', + href: '', + memberLink: '', + }, + { + id: 'xxx2', + title: titles[1], + logo: avatars[1], + description: '���������������������������������������������������������������������������', + updatedAt: new Date('2017-07-24'), + member: '���������������������', + href: '', + memberLink: '', + }, + { + id: 'xxx3', + title: titles[2], + logo: avatars[2], + description: '������������������������������������������������������������������', + updatedAt: new Date(), + member: '���������������', + href: '', + memberLink: '', + }, + { + id: 'xxx4', + title: titles[3], + logo: avatars[3], + description: '���������������������������������������������������������������������', + updatedAt: new Date('2017-07-23'), + member: '���������������', + href: '', + memberLink: '', + }, + { + id: 'xxx5', + title: titles[4], + logo: avatars[4], + description: '������������', + updatedAt: new Date('2017-07-23'), + member: '���������������������', + href: '', + memberLink: '', + }, + { + id: 'xxx6', + title: titles[5], + logo: avatars[5], + description: '������������������������������������������������������', + updatedAt: new Date('2017-07-23'), + member: '���������������������', + href: '', + memberLink: '', + }, + ]; +} + +function getActivities(): any[] { + return [ + { + id: 'trend-1', + updatedAt: new Date(), + user: { + name: '���������', + avatar: avatars[0], + }, + group: { + name: '���������������������', + link: 'http://github.com/', + }, + project: { + name: '������������', + link: 'http://github.com/', + }, + template: '��� @{group} ������������ @{project}', + }, + { + id: 'trend-2', + updatedAt: new Date(), + user: { + name: '���������', + avatar: avatars[1], + }, + group: { + name: '���������������������', + link: 'http://github.com/', + }, + project: { + name: '������������', + link: 'http://github.com/', + }, + template: '��� @{group} ������������ @{project}', + }, + { + id: 'trend-3', + updatedAt: new Date(), + user: { + name: '���������', + avatar: avatars[2], + }, + group: { + name: '���������������', + link: 'http://github.com/', + }, + project: { + name: '������������', + link: 'http://github.com/', + }, + template: '��� @{group} ������������ @{project}', + }, + { + id: 'trend-4', + updatedAt: new Date(), + user: { + name: '���������', + avatar: avatars[3], + }, + project: { + name: '5 ���������������', + link: 'http://github.com/', + }, + template: '��� @{project} ������������������������', + }, + { + id: 'trend-5', + updatedAt: new Date(), + user: { + name: '���������', + avatar: avatars[4], + }, + project: { + name: '������������', + link: 'http://github.com/', + }, + comment: { + name: '������', + link: 'http://github.com/', + }, + template: '��� @{project} ��������� @{comment}', + }, + { + id: 'trend-6', + updatedAt: new Date(), + user: { + name: '������', + avatar: avatars[5], + }, + group: { + name: '���������������', + link: 'http://github.com/', + }, + project: { + name: '������������', + link: 'http://github.com/', + }, + template: '��� @{group} ������������ @{project}', + }, + ]; +} + +export const APIS = { + '/api/list': (req: MockRequest) => getFakeList(req.queryString.count), + '/api/notice': () => getNotice(), + '/api/activities': () => getActivities() +}; -- Gitblit v1.8.0