@cc-component/cc-core 1.8.9 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -132,6 +132,7 @@ export class App {
|
|
|
132
132
|
static OnProgess(param: { open: (param: ISceneParam, finish: () => void) => void, close: (param: ISceneParam) => void, progess: (param: ISceneParam, progress: number, time?: number) => void }) { App.gui.progess = param; }
|
|
133
133
|
static OnWindow(param: { willOpen: (comp: IBundleConfig) => void, open: (comp: IBundleConfig) => void, willClose: (comp: IBundleConfig) => void, close: (comp: IBundleConfig) => void }) { App.gui.window = param; }
|
|
134
134
|
static async Requst<T>(config: IHttpConfig, params?: any, ext?: IExtData): Promise<{ code: number, data: T, msg: string }> { return App.http.Requst<T>(config, params, ext); }
|
|
135
|
+
static OnReadyState<T>(param: { error: (xhr: XMLHttpRequest, ret: HttpReturn<T>) => void }): void { App.http.OnReadyState<T>(param); }
|
|
135
136
|
/**重置网络配置 */
|
|
136
137
|
static ResetHttpServer(config: EnvironmentConfig) {
|
|
137
138
|
let httpServer = config.httpServer!;
|
|
@@ -62,6 +62,9 @@ declare global {
|
|
|
62
62
|
/**=====================================✅✅Http请求======================= */
|
|
63
63
|
/**网络接口 */
|
|
64
64
|
function Requst<T>(config: IHttpConfig, params?: any, ext?: { is_show_alert?: boolean }): Promise<{ code: number, data: T, msg: string }>;
|
|
65
|
+
/**监听网络失败时数据处理 */
|
|
66
|
+
function OnReadyState(param: { error: (xhr: XMLHttpRequest, ret: HttpReturn<any>) => void }): void;
|
|
67
|
+
|
|
65
68
|
/**重置网络配置 */
|
|
66
69
|
function ResetHttpServer(config: EnvironmentConfig)
|
|
67
70
|
/**=====================================✅✅消息发送======================= */
|
|
@@ -253,6 +253,11 @@ export class HttpManager {
|
|
|
253
253
|
|
|
254
254
|
ret.isSucc = true;
|
|
255
255
|
resolve(ret);
|
|
256
|
+
} else {
|
|
257
|
+
// ret.res = { code: xhr.status, msg: xhr.statusText, data: xhr.response } as any
|
|
258
|
+
// ret.isSucc = true;
|
|
259
|
+
this.paramReady.error?.(xhr, ret)
|
|
260
|
+
resolve(ret);
|
|
256
261
|
}
|
|
257
262
|
};
|
|
258
263
|
|
|
@@ -261,6 +266,7 @@ export class HttpManager {
|
|
|
261
266
|
xhr.send();
|
|
262
267
|
}
|
|
263
268
|
else {
|
|
269
|
+
|
|
264
270
|
xhr.send(pss);
|
|
265
271
|
}
|
|
266
272
|
});
|
|
@@ -383,4 +389,8 @@ export class HttpManager {
|
|
|
383
389
|
});
|
|
384
390
|
}
|
|
385
391
|
|
|
392
|
+
paramReady: { error: (xhr: XMLHttpRequest, ret: HttpReturn<any>) => void }
|
|
393
|
+
OnReadyState<T>(param: { error: (xhr: XMLHttpRequest, ret: HttpReturn<any>) => void }): void {
|
|
394
|
+
this.paramReady = param;
|
|
395
|
+
}
|
|
386
396
|
}
|