Inviter
This commit is contained in:
@@ -22,6 +22,8 @@ export default {
|
||||
'common.copied': '复制成功',
|
||||
'common.prompt': 'Prompt',
|
||||
'common.iknow': 'I know',
|
||||
'common.404': '资源不存在',
|
||||
'common.403': '登录过期,请重新登录',
|
||||
|
||||
'check.login': 'Sign In',
|
||||
'check.register': 'Sign Up',
|
||||
|
||||
@@ -22,6 +22,8 @@ export default {
|
||||
'common.copied': '复制成功',
|
||||
'common.prompt': '提示',
|
||||
'common.iknow': '我知道了',
|
||||
'common.404': '资源不存在',
|
||||
'common.403': '登录过期,请重新登录',
|
||||
|
||||
'check.login': '登录',
|
||||
'check.register': '注册',
|
||||
|
||||
@@ -64,11 +64,22 @@ const model: Model = {
|
||||
pageStep = PageStep.Login;
|
||||
break;
|
||||
}
|
||||
yield put({ type: 'onUpdateState', pageStep });
|
||||
yield put({
|
||||
type: 'onUpdateState',
|
||||
pageStep,
|
||||
password: '',
|
||||
pwdConfirm: '',
|
||||
verifyCode: '',
|
||||
});
|
||||
},
|
||||
|
||||
*load(_, { call, put, all }) {
|
||||
yield put({ type: 'onUpdatePageState', payload: PageState.Pending });
|
||||
*load(_, { call, put, all, select }) {
|
||||
const { location } = yield select((state: any) => state.router);
|
||||
let inviter = '';
|
||||
if (location.query && location.query.inviteCode) {
|
||||
inviter = location.query.inviteCode;
|
||||
}
|
||||
yield put({ type: 'onUpdateState', pageState: PageState.Pending, inviter });
|
||||
|
||||
try {
|
||||
const areacodes = yield call(getAreaCodes);
|
||||
|
||||
@@ -14,9 +14,13 @@ export interface AppResp<T = any> {
|
||||
const successLabel = 'color:white;background-color:green;padding: 1px 2px';
|
||||
const failureLabel = 'color:white;background-color:red;padding: 1px 2px';
|
||||
const originLabel = 'color:unset;background-color:unset;padding:unset';
|
||||
const errorMap = {
|
||||
404: 'common.404',
|
||||
403: 'common.403',
|
||||
};
|
||||
|
||||
// const baseURL = 'https://server.fiv.tacever.org/v1';
|
||||
const baseURL = '//yapi.faronear.org/mock/20/v1';
|
||||
const baseURL = 'https://server.fiv.tacever.org/v1';
|
||||
// const baseURL = '//yapi.faronear.org/mock/20/v1';
|
||||
const instance = axios.create({
|
||||
baseURL,
|
||||
});
|
||||
@@ -55,9 +59,6 @@ async function filter<T>(
|
||||
}
|
||||
const { status, data } = await (instance[method] as (...args: any[]) => Promise<AxiosResponse<AppResp>>)(...args);
|
||||
replaceId(data);
|
||||
if (data && data.code === 401) {
|
||||
dispatch({ type: 'user/logout' });
|
||||
}
|
||||
ret = {
|
||||
ok: status >= 200 && status < 300 && data && data.code === 0,
|
||||
code: data && data.code,
|
||||
@@ -65,10 +66,19 @@ async function filter<T>(
|
||||
data: data && data.data,
|
||||
};
|
||||
} catch (e) {
|
||||
let code = 404;
|
||||
let msg = 'network.error';
|
||||
if (e.response) {
|
||||
code = e.response.status;
|
||||
msg = (errorMap as any)[code] || 'network.error';
|
||||
if (code === 403 || code === 401) {
|
||||
dispatch({ type: 'user/logout' });
|
||||
}
|
||||
}
|
||||
ret = {
|
||||
ok: false,
|
||||
msg: formatMessage({ id: 'network.error' }),
|
||||
code: 404,
|
||||
msg: formatMessage({ id: msg }),
|
||||
code,
|
||||
};
|
||||
}
|
||||
if (isDev) {
|
||||
|
||||
Reference in New Issue
Block a user