Showing
3 changed files
with
17 additions
and
6 deletions
| @@ -53,28 +53,36 @@ export class HttpRequest { | @@ -53,28 +53,36 @@ export class HttpRequest { | ||
| 53 | 53 | ||
| 54 | static get<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> { | 54 | static get<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> { |
| 55 | let config: AxiosRequestConfig = { | 55 | let config: AxiosRequestConfig = { |
| 56 | - headers: HttpRequest.buildHeaderWithGlobalHeader(headers) | 56 | + headers: HttpRequest.buildHeaderWithGlobalHeader(headers), |
| 57 | + timeout:10000, | ||
| 58 | + timeoutErrorMessage:"当前无网络,请重试" | ||
| 57 | } | 59 | } |
| 58 | return service.get(url, config) | 60 | return service.get(url, config) |
| 59 | } | 61 | } |
| 60 | 62 | ||
| 61 | static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { | 63 | static post<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { |
| 62 | let config: AxiosRequestConfig = { | 64 | let config: AxiosRequestConfig = { |
| 63 | - headers: HttpRequest.buildHeaderWithGlobalHeader(headers) | 65 | + headers: HttpRequest.buildHeaderWithGlobalHeader(headers), |
| 66 | + timeout:10000, | ||
| 67 | + timeoutErrorMessage:"当前无网络,请重试" | ||
| 64 | } | 68 | } |
| 65 | return service.post(url, data, config) | 69 | return service.post(url, data, config) |
| 66 | } | 70 | } |
| 67 | 71 | ||
| 68 | static put<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { | 72 | static put<T = ResponseDTO<string>>(url: string, data?: object, headers?: HashMap<string, string>): Promise<T> { |
| 69 | let config: AxiosRequestConfig = { | 73 | let config: AxiosRequestConfig = { |
| 70 | - headers: HttpRequest.buildHeaderWithGlobalHeader(headers) | 74 | + headers: HttpRequest.buildHeaderWithGlobalHeader(headers), |
| 75 | + timeout:10000, | ||
| 76 | + timeoutErrorMessage:"当前无网络,请重试" | ||
| 71 | } | 77 | } |
| 72 | return service.put(url, data, config) | 78 | return service.put(url, data, config) |
| 73 | } | 79 | } |
| 74 | 80 | ||
| 75 | static delete<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> { | 81 | static delete<T = ResponseDTO<string>>(url: string, headers?: HashMap<string, string>): Promise<T> { |
| 76 | let config: AxiosRequestConfig = { | 82 | let config: AxiosRequestConfig = { |
| 77 | - headers: HttpRequest.buildHeaderWithGlobalHeader(headers) | 83 | + headers: HttpRequest.buildHeaderWithGlobalHeader(headers), |
| 84 | + timeout:10000, | ||
| 85 | + timeoutErrorMessage:"当前无网络,请重试" | ||
| 78 | } | 86 | } |
| 79 | return service.delete(url, config) | 87 | return service.delete(url, config) |
| 80 | } | 88 | } |
| @@ -154,7 +154,7 @@ export class PageHelper { | @@ -154,7 +154,7 @@ export class PageHelper { | ||
| 154 | } | 154 | } |
| 155 | // Logger.debug(TAG, 'getPageInfo go on') | 155 | // Logger.debug(TAG, 'getPageInfo go on') |
| 156 | this.parseGroup(pageModel, cacheIsSame) | 156 | this.parseGroup(pageModel, cacheIsSame) |
| 157 | - }).catch(() => { | 157 | + }).catch((err:Error) => { |
| 158 | this.refreshUIEnd(pageModel, false) | 158 | this.refreshUIEnd(pageModel, false) |
| 159 | if (this.isPageLoaded(pageModel)) { | 159 | if (this.isPageLoaded(pageModel)) { |
| 160 | return | 160 | return |
| @@ -15,7 +15,7 @@ import { | @@ -15,7 +15,7 @@ import { | ||
| 15 | } from 'wdBean'; | 15 | } from 'wdBean'; |
| 16 | import { CompStyle } from 'wdConstant/Index'; | 16 | import { CompStyle } from 'wdConstant/Index'; |
| 17 | 17 | ||
| 18 | -import { CollectionUtils, Logger, ResourcesUtils, StringUtils } from 'wdKit'; | 18 | +import { CollectionUtils, Logger, ResourcesUtils, StringUtils, ToastUtils } from 'wdKit'; |
| 19 | import { CacheData, ResponseDTO, } from 'wdNetwork'; | 19 | import { CacheData, ResponseDTO, } from 'wdNetwork'; |
| 20 | import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; | 20 | import { PageUIReqBean } from '../components/page/bean/PageUIReqBean'; |
| 21 | import { PageRepository } from '../repository/PageRepository'; | 21 | import { PageRepository } from '../repository/PageRepository'; |
| @@ -240,6 +240,9 @@ export class PageViewModel extends BaseViewModel { | @@ -240,6 +240,9 @@ export class PageViewModel extends BaseViewModel { | ||
| 240 | }).catch((err: Error) => { | 240 | }).catch((err: Error) => { |
| 241 | Logger.error(TAG, `getPageInfo then,error.name : ${err.name}, error.message:${err.message}`); | 241 | Logger.error(TAG, `getPageInfo then,error.name : ${err.name}, error.message:${err.message}`); |
| 242 | error(err); | 242 | error(err); |
| 243 | + if(err.message == "网络出小差了,请检查网络后重试"){ | ||
| 244 | + ToastUtils.shortToast(err.message) | ||
| 245 | + } | ||
| 243 | }); | 246 | }); |
| 244 | }); | 247 | }); |
| 245 | } | 248 | } |
-
Please register or login to post a comment