From ae2a58d0310bf5ef956d6f9bd447ecb737547bf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=84=9A=E9=81=93?= Date: Wed, 29 Aug 2018 16:57:00 +0800 Subject: [PATCH] rebase and fix review issue --- mock/api.js | 6 +++--- mock/geographic.js | 4 ++-- mock/notices.js | 3 +-- mock/rule.js | 4 ++-- src/models/setting.js | 36 ++++++++++++++++++------------------ 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/mock/api.js b/mock/api.js index a1ffa76e..f1173bba 100644 --- a/mock/api.js +++ b/mock/api.js @@ -118,7 +118,7 @@ function getFakeList(req, res) { const result = fakeList(count); sourceData = result; - res.json(result); + return res.json(result); } function postFakeList(req, res) { @@ -150,7 +150,7 @@ function postFakeList(req, res) { break; } - res.json(result); + return res.json(result); } const getNotice = [ @@ -318,7 +318,7 @@ const getActivities = [ ]; function getFakeCaptcha(req, res) { - res.json('captcha-xxx'); + return res.json('captcha-xxx'); } export default { diff --git a/mock/geographic.js b/mock/geographic.js index 64e430ce..e7772e8d 100644 --- a/mock/geographic.js +++ b/mock/geographic.js @@ -2,11 +2,11 @@ import city from './geographic/city.json'; import province from './geographic/province.json'; function getProvince(req, res) { - res.json(province); + return res.json(province); } function getCity(req, res) { - res.json(city[req.params.province]); + return res.json(city[req.params.province]); } export default { diff --git a/mock/notices.js b/mock/notices.js index bc069380..681b10a1 100644 --- a/mock/notices.js +++ b/mock/notices.js @@ -1,4 +1,4 @@ -const getNotices = (req, res) => { +const getNotices = (req, res) => res.json([ { id: '000000001', @@ -93,7 +93,6 @@ const getNotices = (req, res) => { type: '待办', }, ]); -}; export default { 'GET /api/notices': getNotices, diff --git a/mock/rule.js b/mock/rule.js index eaa2bede..35d36c3b 100644 --- a/mock/rule.js +++ b/mock/rule.js @@ -72,7 +72,7 @@ function getRule(req, res, u) { }, }; - res.json(result); + return res.json(result); } function postRule(req, res, u, b) { @@ -129,7 +129,7 @@ function postRule(req, res, u, b) { }, }; - res.json(result); + return res.json(result); } export default { diff --git a/src/models/setting.js b/src/models/setting.js index f1f02169..3f6c2a07 100644 --- a/src/models/setting.js +++ b/src/models/setting.js @@ -12,6 +12,24 @@ const updateTheme = primaryColor => { return; } const hideMessage = message.loading('正在编译主题!', 0); + function buildIt() { + if (!window.less) { + return; + } + setTimeout(() => { + window.less + .modifyVars({ + '@primary-color': primaryColor, + }) + .then(() => { + hideMessage(); + }) + .catch(() => { + message.error('Failed to update theme'); + hideMessage(); + }); + }, 200); + } if (!lessNodesAppended) { const lessStyleNode = document.createElement('link'); const lessConfigNode = document.createElement('script'); @@ -38,24 +56,6 @@ const updateTheme = primaryColor => { } else { buildIt(); } - function buildIt() { - if (!window.less) { - return; - } - setTimeout(() => { - window.less - .modifyVars({ - '@primary-color': primaryColor, - }) - .then(() => { - hideMessage(); - }) - .catch(() => { - message.error('Failed to update theme'); - hideMessage(); - }); - }, 200); - } }; const updateColorWeak = colorWeak => { -- GitLab