From 78945c61a7d7fa405f038fbe13cdb39e300732f8 Mon Sep 17 00:00:00 2001 From: sin <2943460818@qq.com> Date: Mon, 4 Mar 2019 12:15:44 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A4=84=E7=90=86=E6=9C=AA=20mock=20?= =?UTF-8?q?=E6=83=85=E5=86=B5=E9=9C=80=E8=A6=81=E5=A4=84=E7=90=86=E7=9A=84?= =?UTF-8?q?=20api=20=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=9A=82=E6=97=B6=E5=90=8E?= =?UTF-8?q?=E4=B8=8D=E9=9C=80=E8=A6=81=E6=8F=90=E4=BE=9B=E8=BF=99=E4=BA=9B?= =?UTF-8?q?=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin-web/src/app.js | 28 ++++++----- admin-web/src/mock-data/authRoutesData.js | 6 +++ admin-web/src/mock-data/currentUserData.js | 56 ++++++++++++++++++++++ admin-web/src/models/user.js | 8 ++-- admin-web/src/pages/User/Login.js | 2 + admin-web/src/services/api.js | 6 +-- 6 files changed, 87 insertions(+), 19 deletions(-) create mode 100644 admin-web/src/mock-data/authRoutesData.js create mode 100644 admin-web/src/mock-data/currentUserData.js diff --git a/admin-web/src/app.js b/admin-web/src/app.js index 0f35ff9af..22ba056fb 100644 --- a/admin-web/src/app.js +++ b/admin-web/src/app.js @@ -1,4 +1,5 @@ -import fetch from 'dva/fetch'; +// import fetch from 'dva/fetch'; +import getAuthRoutesData from './mock-data/authRoutesData'; export const dva = { config: { @@ -30,15 +31,18 @@ export function patchRoutes(routes) { } export function render(oldRender) { - fetch('/api/auth_routes') - .then(res => res.json()) - .then( - ret => { - authRoutes = ret; - oldRender(); - }, - () => { - oldRender(); - } - ); + // fetch('/api/auth_routes') + // .then(res => res.json()) + // .then( + // ret => { + // authRoutes = ret; + // oldRender(); + // }, + // () => { + // oldRender(); + // } + // ); + + authRoutes = getAuthRoutesData; + oldRender(); } diff --git a/admin-web/src/mock-data/authRoutesData.js b/admin-web/src/mock-data/authRoutesData.js new file mode 100644 index 000000000..64016f29e --- /dev/null +++ b/admin-web/src/mock-data/authRoutesData.js @@ -0,0 +1,6 @@ +function getAuthRoutesData() { + // return {authority: ['admin', 'user']} + return { authority: ['guest'] }; +} + +export default getAuthRoutesData(); diff --git a/admin-web/src/mock-data/currentUserData.js b/admin-web/src/mock-data/currentUserData.js new file mode 100644 index 000000000..202c7ea2c --- /dev/null +++ b/admin-web/src/mock-data/currentUserData.js @@ -0,0 +1,56 @@ +// TODO 临时使用,后台暂时无接口 + +function getCurrentUser() { + return { + name: 'Serati Ma', + avatar: 'https://gw.alipayobjects.com/zos/antfincdn/XAosXuNZyF/BiazfanxmamNRoxxVxka.png', + userid: '00000001', + email: 'antdesign@alipay.com', + signature: '海纳百川,有容乃大', + title: '交互专家', + group: '蚂蚁金服-某某某事业群-某某平台部-某某技术部-UED', + tags: [ + { + key: '0', + label: '很有想法的', + }, + { + key: '1', + label: '专注设计', + }, + { + key: '2', + label: '辣~', + }, + { + key: '3', + label: '大长腿', + }, + { + key: '4', + label: '川妹子', + }, + { + key: '5', + label: '海纳百川', + }, + ], + notifyCount: 12, + unreadCount: 11, + country: 'China', + geographic: { + province: { + label: '浙江省', + key: '330000', + }, + city: { + label: '杭州市', + key: '330100', + }, + }, + address: '西湖区工专路 77 号', + phone: '0752-268888888', + }; +} + +export default getCurrentUser(); diff --git a/admin-web/src/models/user.js b/admin-web/src/models/user.js index c84ebbcfc..71df44bf9 100644 --- a/admin-web/src/models/user.js +++ b/admin-web/src/models/user.js @@ -1,4 +1,5 @@ -import { query as queryUsers, queryCurrent } from '@/services/user'; +import { query as queryUsers } from '@/services/user'; +import currentUserData from '../mock-data/currentUserData'; export default { namespace: 'user', @@ -16,8 +17,9 @@ export default { payload: response, }); }, - *fetchCurrent(_, { call, put }) { - const response = yield call(queryCurrent); + *fetchCurrent(_, { put }) { + // const response = yield call(queryCurrent); + const response = currentUserData; yield put({ type: 'saveCurrentUser', payload: response, diff --git a/admin-web/src/pages/User/Login.js b/admin-web/src/pages/User/Login.js index 05875861b..12f97a96c 100644 --- a/admin-web/src/pages/User/Login.js +++ b/admin-web/src/pages/User/Login.js @@ -84,6 +84,7 @@ class LoginPage extends Component {