From 0bf638028b23e5723681148c3ed9ef07fb30cda6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Fri, 8 Jun 2018 19:54:51 +0800 Subject: [PATCH] Remove hardcoded --- mock/api.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/mock/api.js b/mock/api.js index 654aba9b..49450556 100644 --- a/mock/api.js +++ b/mock/api.js @@ -1,5 +1,3 @@ -import { parse } from 'url'; - const titles = [ 'Alipay', 'Angular', @@ -69,7 +67,7 @@ export function fakeList(count) { owner: user[i % 10], title: titles[i % 8], avatar: avatars[i % 8], - cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - i % 4], + cover: parseInt(i / 4, 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], @@ -111,13 +109,8 @@ export function fakeList(count) { let sourceData; -export function getFakeList(req, res, u) { - let url = u; - if (!url || Object.prototype.toString.call(url) !== '[object String]') { - url = req.url; // eslint-disable-line - } - - const params = parse(url, true).query; +export function getFakeList(req, res) { + const params = req.query; const count = params.count * 1 || 20; -- GitLab