antd-admin icon indicating copy to clipboard operation
antd-admin copied to clipboard

对request.js里面的ajax 做统一返回码处理 怎么跳到登录页呢?

Open encorehe opened this issue 9 years ago • 3 comments

export default function request (url, options) { if (options.cross) { return Ajax.getJSON('http://query.yahooapis.com/v1/public/yql', { q: "select * from json where url='" + url + '?' + Ajax.param(options.data) + "'", format: 'json' }) } else { return Ajax.ajax({ url: url, method: options.method ? options.method:'get', data: options.data ? options.data:{}, //processData: options.method === 'get', dataType: 'JSON' }).done((data) => { if(data.state === 0){ return data
}else{ let msg = (data.state).toString().codeText(); message.error(msg); //返回登录页 然后就不知道怎么回到登录页了.😓 }

})

} }

encorehe avatar Feb 04 '17 02:02 encorehe

@encorehe 可以用下浏览器提供的接口进行跳转:

window.location.href = '/';

xiaosansiji avatar Feb 04 '17 06:02 xiaosansiji

从别人的代码中看到的,居然能够传过来,dispatch const app = dva({ history: browserHistory, onError(e, dispatch) { // dispatch({type: 'app/logout'}); console.log(e); if (e.message === 'Unauthorized') { message.info('Please Login :)', 5); } else { message.error(e.message, 5); } } })

feiZhang avatar Mar 18 '17 14:03 feiZhang

import { routerRedux } from 'dva/router'

zuiidea avatar Apr 14 '17 12:04 zuiidea