api.js 6.79 KB
Newer Older
1 2 3 4
import { imgMap, getUrlParams } from './utils';

export function fakeList(count) {
  const titles = [
nikogu's avatar
nikogu committed
5
    'Vue',
niko's avatar
niko committed
6 7
    'Ant Design Pro',
    'Bootstrap',
nikogu's avatar
nikogu committed
8
    'Angular',
niko's avatar
niko committed
9
    'Ant Design',
nikogu's avatar
nikogu committed
10 11
    'React',
    'Alipay',
niko's avatar
niko committed
12
    'Ant Design Mobile',
13 14 15 16 17 18 19 20
  ];
  const avatars = [
    'https://gw.alipayobjects.com/zos/rmsportal/hYjIZrUoBfNxOAYBVDfc.png', // 凤蝶
    'https://gw.alipayobjects.com/zos/rmsportal/HHWPIzPLCLYmVuPivyiA.png', // 云雀
    'https://gw.alipayobjects.com/zos/rmsportal/irqByKtOdKfDojxIWTXF.png', // Basement
    'https://gw.alipayobjects.com/zos/rmsportal/VcmdbCBcwPTGYgbYeMzX.png', // DesignLab
  ];
  const covers = [
niko's avatar
niko committed
21 22 23 24
    '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',
25
  ];
niko's avatar
niko committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
  const desc = [
    '那是一种内在的东西, 他们到达不了,也无法触及的',
    '希望是一个好东西,也许是最好的,好东西是不会消亡的',
    '生命就像一盒巧克力,结果往往出人意料',
    '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
    '那时候我只会想自己想要什么,从不想自己拥有什么',
  ];

  const user = [
    '付小小',
    '曲丽丽',
    '林东东',
    '周星星',
    '吴加好',
    '朱偏右',
    '鱼酱',
    '乐哥',
    '谭小仪',
    '仲尼',
  ];
46 47 48 49 50

  const list = [];
  for (let i = 0; i < count; i += 1) {
    list.push({
      id: `fake-list-${i}`,
niko's avatar
niko committed
51
      owner: user[i % 10],
52 53
      title: titles[i % 8],
      avatar: avatars[i % 4],
niko's avatar
niko committed
54
      cover: (i / 4) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)],
55 56 57 58 59 60
      status: ['active', 'exception', 'normal'][i % 3],
      percent: Math.ceil(Math.random() * 50) + 50,
      logo: ['https://gw.alipayobjects.com/zos/rmsportal/KoJjkdbuTFxzJmmjuDVR.png', 'https://gw.alipayobjects.com/zos/rmsportal/UxGORCvEXJEsxOfEKZiA.png'][i % 2],
      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)),
niko's avatar
niko committed
61
      subDescription: desc[i % 5],
62 63 64 65 66 67 68 69 70
      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: '段落示意:蚂蚁金服设计平台 design.alipay.com,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 design.alipay.com,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。',
      members: [
        {
nikogu's avatar
nikogu committed
71 72
          avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
          name: '曲丽丽',
73 74
        },
        {
nikogu's avatar
nikogu committed
75
          avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
76 77 78
          name: '王昭君',
        },
        {
nikogu's avatar
nikogu committed
79 80
          avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
          name: '董娜娜',
81 82 83 84 85 86 87 88 89 90 91
        },
      ],
    });
  }

  return list;
}

export function getFakeList(req, res, u) {
  let url = u;
  if (!url || Object.prototype.toString.call(url) !== '[object String]') {
afc163's avatar
afc163 committed
92
    url = req.url; // eslint-disable-line
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
  }

  const params = getUrlParams(url);

  const count = (params.count * 1) || 20;

  const result = fakeList(count);

  if (res && res.json) {
    res.json(result);
  } else {
    return result;
  }
}

export const getNotice = [
  {
    id: 'xxx1',
niko's avatar
niko committed
111
    title: 'Vue',
112
    logo: imgMap.b,
niko's avatar
niko committed
113
    description: '那是一种内在的东西, 他们到达不了,也无法触及的',
114
    updatedAt: new Date(),
niko's avatar
niko committed
115
    member: '科学搬砖组',
ddcat1115's avatar
ddcat1115 committed
116 117
    href: '',
    memberLink: '',
118 119 120
  },
  {
    id: 'xxx2',
niko's avatar
niko committed
121
    title: 'Angular',
122
    logo: imgMap.c,
niko's avatar
niko committed
123
    description: '希望是一个好东西,也许是最好的,好东西是不会消亡的',
124
    updatedAt: new Date('2017-07-24 11:00:00'),
niko's avatar
niko committed
125
    member: '全组都是吴彦祖',
ddcat1115's avatar
ddcat1115 committed
126 127
    href: '',
    memberLink: '',
128 129 130
  },
  {
    id: 'xxx3',
niko's avatar
niko committed
131
    title: 'React',
132
    logo: imgMap.a,
niko's avatar
niko committed
133
    description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
134
    updatedAt: new Date(),
niko's avatar
niko committed
135
    member: '中二少女团',
ddcat1115's avatar
ddcat1115 committed
136 137
    href: '',
    memberLink: '',
138 139 140
  },
  {
    id: 'xxx4',
niko's avatar
niko committed
141
    title: 'Ant Design',
142
    logo: imgMap.a,
niko's avatar
niko committed
143
    description: '那时候我只会想自己想要什么,从不想自己拥有什么',
144
    updatedAt: new Date('2017-07-23 06:23:00'),
niko's avatar
niko committed
145
    member: '程序员日常',
ddcat1115's avatar
ddcat1115 committed
146 147
    href: '',
    memberLink: '',
148 149 150
  },
  {
    id: 'xxx5',
niko's avatar
niko committed
151
    title: 'Ant Design Mobile',
152
    logo: imgMap.b,
niko's avatar
niko committed
153
    description: '凛冬将至',
154
    updatedAt: new Date('2017-07-23 06:23:00'),
niko's avatar
niko committed
155
    member: '高逼格设计天团',
ddcat1115's avatar
ddcat1115 committed
156 157
    href: '',
    memberLink: '',
158 159 160
  },
  {
    id: 'xxx6',
niko's avatar
niko committed
161
    title: 'Ant Motion',
162
    logo: imgMap.c,
niko's avatar
niko committed
163
    description: '生命就像一盒巧克力,结果往往出人意料',
164
    updatedAt: new Date('2017-07-23 06:23:00'),
niko's avatar
niko committed
165
    member: '骗你来学计算机',
ddcat1115's avatar
ddcat1115 committed
166 167
    href: '',
    memberLink: '',
168 169 170 171 172 173 174 175 176 177 178
  },
];

export const getActivities = [
  {
    id: 'trend-1',
    updatedAt: new Date(),
    user: {
      name: '林东东',
      avatar: imgMap.a,
    },
niko's avatar
niko committed
179
    action: '在 [高逼格设计天团](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
180 181 182 183 184
  },
  {
    id: 'trend-2',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
185
      name: '付小小',
186 187
      avatar: imgMap.c,
    },
niko's avatar
niko committed
188
    action: '在 [高逼格设计天团](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
189 190 191 192 193
  },
  {
    id: 'trend-3',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
194
      name: '曲丽丽',
195 196
      avatar: imgMap.b,
    },
niko's avatar
niko committed
197
    action: '在 [中二少女团](http://github.com/) 新建项目 [六月迭代](http://github.com/)',
198 199 200 201 202
  },
  {
    id: 'trend-4',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
203
      name: '周星星',
204 205 206 207 208 209 210 211
      avatar: imgMap.c,
    },
    action: '在 [5 月日常迭代](http://github.com/) 更新至已发布状态',
  },
  {
    id: 'trend-5',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
212
      name: '朱偏右',
213 214 215 216 217 218 219 220
      avatar: imgMap.a,
    },
    action: '在 [工程效能](http://github.com/) 发布了 [留言](http://github.com/)',
  },
  {
    id: 'trend-6',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
221
      name: '乐哥',
222 223
      avatar: imgMap.d,
    },
niko's avatar
niko committed
224
    action: '在 [程序员日常](http://github.com/) 新建项目 [品牌迭代](http://github.com/)',
225 226 227 228 229 230 231 232 233
  },
];


export default {
  getNotice,
  getActivities,
  getFakeList,
};