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

afc163's avatar
afc163 committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
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 = [
  '那是一种内在的东西, 他们到达不了,也无法触及的',
  '希望是一个好东西,也许是最好的,好东西是不会消亡的',
  '生命就像一盒巧克力,结果往往出人意料',
  '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆',
  '那时候我只会想自己想要什么,从不想自己拥有什么',
];
niko's avatar
niko committed
36

afc163's avatar
afc163 committed
37 38 39 40 41 42 43 44 45 46 47 48
const user = [
  '付小小',
  '曲丽丽',
  '林东东',
  '周星星',
  '吴加好',
  '朱偏右',
  '鱼酱',
  '乐哥',
  '谭小仪',
  '仲尼',
];
49

afc163's avatar
afc163 committed
50
export function fakeList(count) {
51 52 53 54
  const list = [];
  for (let i = 0; i < count; i += 1) {
    list.push({
      id: `fake-list-${i}`,
niko's avatar
niko committed
55
      owner: user[i % 10],
56
      title: titles[i % 8],
afc163's avatar
afc163 committed
57 58
      avatar: avatars[i % 8],
      cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)],
59 60
      status: ['active', 'exception', 'normal'][i % 3],
      percent: Math.ceil(Math.random() * 50) + 50,
afc163's avatar
afc163 committed
61
      logo: avatars[i % 8],
62 63 64
      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
65
      subDescription: desc[i % 5],
66 67 68 69 70 71 72 73 74
      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
75 76
          avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png',
          name: '曲丽丽',
77 78
        },
        {
nikogu's avatar
nikogu committed
79
          avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png',
80 81 82
          name: '王昭君',
        },
        {
nikogu's avatar
nikogu committed
83 84
          avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png',
          name: '董娜娜',
85 86 87 88 89 90 91 92 93 94 95
        },
      ],
    });
  }

  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
96
    url = req.url; // eslint-disable-line
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
  }

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

export const getActivities = [
  {
    id: 'trend-1',
    updatedAt: new Date(),
    user: {
      name: '林东东',
      avatar: imgMap.a,
    },
afc163's avatar
afc163 committed
183 184 185 186 187 188 189 190 191
    group: {
      name: '高逼格设计天团',
      link: 'http://github.com/',
    },
    project: {
      name: '六月迭代',
      link: 'http://github.com/',
    },
    template: '在 @{group} 新建项目 @{project}',
192 193 194 195 196
  },
  {
    id: 'trend-2',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
197
      name: '付小小',
198 199
      avatar: imgMap.c,
    },
afc163's avatar
afc163 committed
200 201 202 203 204 205 206 207 208
    group: {
      name: '高逼格设计天团',
      link: 'http://github.com/',
    },
    project: {
      name: '六月迭代',
      link: 'http://github.com/',
    },
    template: '在 @{group} 新建项目 @{project}',
209 210 211 212 213
  },
  {
    id: 'trend-3',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
214
      name: '曲丽丽',
215 216
      avatar: imgMap.b,
    },
afc163's avatar
afc163 committed
217 218 219 220 221 222 223 224 225
    group: {
      name: '中二少女团',
      link: 'http://github.com/',
    },
    project: {
      name: '六月迭代',
      link: 'http://github.com/',
    },
    template: '在 @{group} 新建项目 @{project}',
226 227 228 229 230
  },
  {
    id: 'trend-4',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
231
      name: '周星星',
232 233
      avatar: imgMap.c,
    },
afc163's avatar
afc163 committed
234 235 236 237 238
    project: {
      name: '5 月日常迭代',
      link: 'http://github.com/',
    },
    template: '将 @{project} 更新至已发布状态',
239 240 241 242 243
  },
  {
    id: 'trend-5',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
244
      name: '朱偏右',
245 246
      avatar: imgMap.a,
    },
afc163's avatar
afc163 committed
247 248 249 250 251 252 253 254 255
    project: {
      name: '工程效能',
      link: 'http://github.com/',
    },
    comment: {
      name: '留言',
      link: 'http://github.com/',
    },
    template: '在 @{project} 发布了 @{comment}',
256 257 258 259 260
  },
  {
    id: 'trend-6',
    updatedAt: new Date(),
    user: {
niko's avatar
niko committed
261
      name: '乐哥',
afc163's avatar
afc163 committed
262
      avatar: imgMap.b,
263
    },
afc163's avatar
afc163 committed
264 265 266 267 268 269 270 271 272
    group: {
      name: '程序员日常',
      link: 'http://github.com/',
    },
    project: {
      name: '品牌迭代',
      link: 'http://github.com/',
    },
    template: '在 @{group} 新建项目 @{project}',
273 274 275 276 277 278 279 280 281
  },
];


export default {
  getNotice,
  getActivities,
  getFakeList,
};