|
@@ -2,7 +2,6 @@ import axios from 'axios';
|
|
|
// import store from '@/store';
|
|
|
|
|
|
import { Message } from 'element-ui';
|
|
|
-import { getToken } from '@/utils/auth';
|
|
|
import store from '@/store';
|
|
|
|
|
|
const service = axios.create({
|
|
@@ -12,18 +11,18 @@ const service = axios.create({
|
|
|
|
|
|
// 请求拦截器
|
|
|
service.interceptors.request.use(
|
|
|
- config => {
|
|
|
+ (config) => {
|
|
|
config.headers['Content-Type'] = 'application/json';
|
|
|
return config;
|
|
|
},
|
|
|
- error => {
|
|
|
+ (error) => {
|
|
|
return Promise.reject(error);
|
|
|
},
|
|
|
);
|
|
|
|
|
|
// 响应拦截器
|
|
|
service.interceptors.response.use(
|
|
|
- response => {
|
|
|
+ (response) => {
|
|
|
const res = response.data;
|
|
|
const { code, status, message, error } = res;
|
|
|
if (code === 404) {
|
|
@@ -54,24 +53,13 @@ service.interceptors.response.use(
|
|
|
type: 'error',
|
|
|
duration: 3 * 1000,
|
|
|
});
|
|
|
- // store.dispatch('user/signOut');
|
|
|
- const match = /#\/(.*?)\?/.exec(window.location.hash); // 使用 exec 方法进行匹配
|
|
|
|
|
|
- // 答题跳转链接
|
|
|
- let extractedString = '';
|
|
|
- if (match && match.length > 1) {
|
|
|
- extractedString = match[1];
|
|
|
- }
|
|
|
- // 答题链接特殊处理
|
|
|
- if (extractedString === 'open/share/exercise') {
|
|
|
- return Promise.reject(new Error(`${error}` || 'Error'));
|
|
|
- }
|
|
|
- // window.location.href = '/';
|
|
|
+ return Promise.reject(new Error(`${error}` || 'Error'));
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
},
|
|
|
- error => {
|
|
|
+ (error) => {
|
|
|
if (error.code === 'ERR_CANCELED') {
|
|
|
return Message.success('取消上传成功');
|
|
|
}
|