- 处理未 mock 情况需要处理的 api 数据,暂时后不需要提供这些 api

pull/1/head
sin 2019-03-04 12:15:44 +08:00
parent 171cf5b996
commit 78945c61a7
6 changed files with 87 additions and 19 deletions

View File

@ -1,4 +1,5 @@
import fetch from 'dva/fetch'; // import fetch from 'dva/fetch';
import getAuthRoutesData from './mock-data/authRoutesData';
export const dva = { export const dva = {
config: { config: {
@ -30,15 +31,18 @@ export function patchRoutes(routes) {
} }
export function render(oldRender) { export function render(oldRender) {
fetch('/api/auth_routes') // fetch('/api/auth_routes')
.then(res => res.json()) // .then(res => res.json())
.then( // .then(
ret => { // ret => {
authRoutes = ret; // authRoutes = ret;
oldRender(); // oldRender();
}, // },
() => { // () => {
oldRender(); // oldRender();
} // }
); // );
authRoutes = getAuthRoutesData;
oldRender();
} }

View File

@ -0,0 +1,6 @@
function getAuthRoutesData() {
// return {authority: ['admin', 'user']}
return { authority: ['guest'] };
}
export default getAuthRoutesData();

View File

@ -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();

View File

@ -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 { export default {
namespace: 'user', namespace: 'user',
@ -16,8 +17,9 @@ export default {
payload: response, payload: response,
}); });
}, },
*fetchCurrent(_, { call, put }) { *fetchCurrent(_, { put }) {
const response = yield call(queryCurrent); // const response = yield call(queryCurrent);
const response = currentUserData;
yield put({ yield put({
type: 'saveCurrentUser', type: 'saveCurrentUser',
payload: response, payload: response,

View File

@ -84,6 +84,7 @@ class LoginPage extends Component {
<UserName <UserName
name="username" name="username"
placeholder={`${formatMessage({ id: 'app.login.userName' })}: admin or user`} placeholder={`${formatMessage({ id: 'app.login.userName' })}: admin or user`}
defaultValue="admin"
rules={[ rules={[
{ {
required: true, required: true,
@ -94,6 +95,7 @@ class LoginPage extends Component {
<Password <Password
name="password" name="password"
placeholder={`${formatMessage({ id: 'app.login.password' })}: admin`} placeholder={`${formatMessage({ id: 'app.login.password' })}: admin`}
defaultValue="nicai"
rules={[ rules={[
{ {
required: true, required: true,

View File

@ -104,16 +104,14 @@ export async function updateFakeList(params) {
} }
export async function fakeAccountLogin(params) { export async function fakeAccountLogin(params) {
return request(`/admin-api/admin/passport/login/?${stringify(params)}`, { return request(`/admin-api/admin/passport/login?${stringify(params)}`, {
method: 'POST', method: 'POST',
body: params,
}); });
} }
export async function fakeRegister(params) { export async function fakeRegister(params) {
return request(`/admin-api/admin/passport/login/?${stringify(params)}`, { return request(`/admin-api/admin/passport/login?${stringify(params)}`, {
method: 'POST', method: 'POST',
body: params,
}); });
} }