diff --git a/mock/api.js b/mock/api.js index a1ffa76ed843cff9f0f447602c3d89a780c6bbbc..f1173bba91a8194731444a05d015f3bfdf00ee23 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 64e430cebbe01516b7f037227756a7a17b7aa0c3..e7772e8d32d5a580a696889de9c769a1a336a4e8 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 bc06938096d8548b907fd8914553c067394703bc..681b10a1cb3b1f1d06a8d26661b6f34714104202 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 eaa2bede531715c91aa02180efe57afc1e308d97..35d36c3b4fb80b12ab15964a158f63f0ff0789ec 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 f1f021699970b199f7133a8d300720c22ae2bb40..3f6c2a0725e19dea14d8a982b2d73469abbfd120 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 => {