|
6 | 6 | * @Company: |
7 | 7 | * @Date: 2019-08-16 16:57:42 |
8 | 8 | * @LastEditors: 水痕 |
9 | | - * @LastEditTime: 2019-08-21 10:21:16 |
| 9 | + * @LastEditTime: 2019-08-21 10:37:01 |
10 | 10 | */ |
11 | 11 |
|
12 | 12 | import axios from 'axios'; |
@@ -35,9 +35,9 @@ export const axiosConfig = (): void => { |
35 | 35 | /********************************封装请求的 start********************************/ |
36 | 36 | function request(config: { [propsName: string]: any }) { |
37 | 37 | // 配置请求头 |
38 | | - config.headers['X-Origin'] = 'admin-web'; |
39 | | - config.headers[authToken] = storage.getItem(authToken); |
40 | | - config.headers[authMobile] = storage.getItem(authMobile); |
| 38 | + // config.headers['X-Origin'] = 'admin-web'; |
| 39 | + // config.headers[authToken] = storage.getItem(authToken); |
| 40 | + // config.headers[authMobile] = storage.getItem(authMobile); |
41 | 41 |
|
42 | 42 | // 处理请求地址 |
43 | 43 | const input = config.url; |
@@ -71,62 +71,3 @@ export const axiosConfig = (): void => { |
71 | 71 | // 拦截响应 |
72 | 72 | axios.interceptors.response.use(response, responseError); |
73 | 73 | }; |
74 | | - |
75 | | -// class AxiosRequest { |
76 | | -// private baseUrl: string; |
77 | | -// private timeout: number; |
78 | | -// constructor(baseUrl: string = prefix, timeout: number = 60 * 1000) { |
79 | | -// this.baseUrl = baseUrl; |
80 | | -// this.timeout = timeout; |
81 | | -// } |
82 | | - |
83 | | -// public request(config: { [propsName: string]: any }) { |
84 | | -// const instance = axios.create({ |
85 | | -// baseURL: this.baseUrl, |
86 | | -// timeout: this.timeout, |
87 | | -// }); |
88 | | -// /********************************设置请求拦截 start********************************/ |
89 | | -// instance.interceptors.request.use(this.requestSuccess, this.requestError); |
90 | | -// /********************************设置请求拦截 end********************************/ |
91 | | -// /********************************设置响应拦截 start********************************/ |
92 | | -// instance.interceptors.response.use( |
93 | | -// this.responseSuccess, |
94 | | -// this.responseError, |
95 | | -// ); |
96 | | -// /********************************设置响应拦截 end********************************/ |
97 | | -// return instance(config); |
98 | | -// } |
99 | | - |
100 | | -// private requestSuccess(config: { [propsName: string]: any }) { |
101 | | -// config.headers['X-Origin'] = 'admin-web'; |
102 | | -// config.headers[authToken] = storage.getItem(authToken); |
103 | | -// config.headers[authMobile] = storage.getItem(authMobile); |
104 | | -// return config; |
105 | | -// } |
106 | | - |
107 | | -// private requestError(rejection: { data: any }) { |
108 | | -// return this.useOrigin(rejection) |
109 | | -// ? Promise.reject(rejection) |
110 | | -// : Promise.reject(rejection.data); |
111 | | -// } |
112 | | - |
113 | | -// private responseSuccess(res: any): any { |
114 | | -// return this.isPlainRequest(res.config.url) || this.useOrigin(res) |
115 | | -// ? res |
116 | | -// : res.data; |
117 | | -// } |
118 | | - |
119 | | -// private responseError(error: any) { |
120 | | -// return Promise.reject(error); |
121 | | -// } |
122 | | - |
123 | | -// private useOrigin(res: any) { |
124 | | -// return res.config.useOrigin; |
125 | | -// } |
126 | | - |
127 | | -// private isPlainRequest(input: string) { |
128 | | -// return /\.(html?|xml|txt)$/.test(input); |
129 | | -// } |
130 | | -// } |
131 | | - |
132 | | -// export const axiosConfig = new AxiosRequest(); |
0 commit comments