| | |
| | | |
| | | const notRequireInterceptorErrorUrl = [ |
| | | '/otp/verify', |
| | | // '/otp/sendOtp', |
| | | '/eService/authenticate', |
| | | '/login/validate/get_img_code', |
| | | '/login/validate/verify_img_code', |
| | |
| | | withCredentials: true |
| | | }); |
| | | |
| | | let apiNumber = 0; |
| | | |
| | | http.interceptors.request.use( |
| | | (config: AxiosRequestConfig) => { |
| | | apiNumber += 1; |
| | | loadingStart(); |
| | | addHttpHeader(config); |
| | | return config; |
| | |
| | | |
| | | http.interceptors.response.use( |
| | | (response: AxiosResponse) => { |
| | | loadingFinish(); |
| | | apiNumber -= 1; |
| | | if (apiNumber === 0) { |
| | | loadingFinish(); |
| | | } |
| | | return response; |
| | | }, |
| | | (error: AxiosError) => { |
| | | loadingFinish(); |
| | | apiNumber -= 1; |
| | | if (apiNumber === 0) { |
| | | loadingFinish(); |
| | | } |
| | | showErrorMessageBox(error) |
| | | return Promise.reject(error); |
| | | } |
| | |
| | | }; |
| | | |
| | | function showErrorMessageBox(error: any): void { |
| | | // console.log('error', error, error.response); |
| | | setTimeout(() => { |
| | | // NOTE: 此為 HOT FIX 顧問登入失敗後,會出現逾時的 dialog [Tomas, 2022/7/20 14:21] |
| | | if(error.config.url.includes('/eService/authenticate')) return; |
| | | if (error.config.url.includes('/otp/sendOtp')) { |
| | | messageBoxService.showErrorMessage('', error); |
| | | return |
| | | } |
| | | if (!_.includes(notRequireInterceptorErrorUrl, error.config.url)) { |
| | | switch (error.response.status) { |
| | | case 401: |