mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 01:14:50 +08:00
初始化项目
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
export default {
|
||||
siteName: '京东羊毛脚本控制面板',
|
||||
apiPrefix: '/api/',
|
||||
authKey: 'whyour',
|
||||
|
||||
/* Layout configuration, specify which layout to use for route. */
|
||||
layouts: [
|
||||
{
|
||||
name: 'primary',
|
||||
include: [/.*/],
|
||||
exclude: [/(\/(en|zh))*\/login/],
|
||||
},
|
||||
],
|
||||
|
||||
/* I18n configuration, `languages` and `defaultLanguage` are required currently. */
|
||||
i18n: {
|
||||
/* Countrys flags: https://www.flaticon.com/packs/countrys-flags */
|
||||
languages: [
|
||||
{
|
||||
key: 'pt-br',
|
||||
title: 'Português',
|
||||
flag: '/portugal.svg',
|
||||
},
|
||||
{
|
||||
key: 'en',
|
||||
title: 'English',
|
||||
flag: '/america.svg',
|
||||
},
|
||||
{
|
||||
key: 'zh',
|
||||
title: '中文',
|
||||
flag: '/china.svg',
|
||||
},
|
||||
],
|
||||
defaultLanguage: 'en',
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,29 @@
|
||||
import { extend } from 'umi-request';
|
||||
import { history } from 'umi';
|
||||
|
||||
const time = Date.now();
|
||||
const errorHandler = function (error: any) {
|
||||
if (error.response) {
|
||||
console.log(error.response)
|
||||
} else {
|
||||
console.log(error.message);
|
||||
}
|
||||
|
||||
throw error; // 如果throw. 错误将继续抛出.
|
||||
// return {some: 'data'};
|
||||
};
|
||||
|
||||
const _request = extend({ timeout: 5000, params: { t: time }, errorHandler });
|
||||
|
||||
_request.interceptors.response.use(async response => {
|
||||
const res = await response.clone().text()
|
||||
if (res === '请先登录!') {
|
||||
setTimeout(() => {
|
||||
localStorage.removeItem('whyour');
|
||||
history.push('/login');
|
||||
});
|
||||
}
|
||||
return response;
|
||||
})
|
||||
|
||||
export const request = _request;
|
||||
Reference in New Issue
Block a user