@cc-component/cc-core 1.8.6 → 1.8.8
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.
|
@@ -121,7 +121,9 @@ export class LayerUI {
|
|
|
121
121
|
/**获取指定ui层 */
|
|
122
122
|
public GetLayer(type: LayerType) { return this.ui_map.get(type); }
|
|
123
123
|
/**重置网络配置 */
|
|
124
|
-
public ResetHttpServer(config: EnvironmentConfig) {
|
|
124
|
+
public ResetHttpServer(config: EnvironmentConfig) {
|
|
125
|
+
Object.assign(this.config.config[this.config.type], config);
|
|
126
|
+
}
|
|
125
127
|
|
|
126
128
|
|
|
127
129
|
|
|
@@ -133,7 +133,14 @@ export class App {
|
|
|
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
135
|
/**重置网络配置 */
|
|
136
|
-
static ResetHttpServer(config: EnvironmentConfig) {
|
|
136
|
+
static ResetHttpServer(config: EnvironmentConfig) {
|
|
137
|
+
let httpServer = config.httpServer!;
|
|
138
|
+
if (!httpServer.endsWith('/')) { httpServer += '/'; }
|
|
139
|
+
App.gui.ResetHttpServer(config);
|
|
140
|
+
|
|
141
|
+
if (config.httpServer) this.instance._http.server = httpServer;
|
|
142
|
+
if (config.httpTimeout) this.instance._http.timeout = config.httpTimeout;
|
|
143
|
+
}
|
|
137
144
|
|
|
138
145
|
//#region 常用
|
|
139
146
|
static Debug(isDebug: boolean) { this.instance.isDebug = isDebug }
|
|
@@ -177,8 +177,10 @@ export class HttpManager {
|
|
|
177
177
|
// 防重复请求功能
|
|
178
178
|
urls.set(key, { xhr, pss });
|
|
179
179
|
//console.warn(ext && ext.query ? key : url)
|
|
180
|
-
if (method == HttpMethod.POST)
|
|
180
|
+
if (method == HttpMethod.POST) {
|
|
181
181
|
xhr.open(HttpMethod.POST, ext && ext.query ? key : url);
|
|
182
|
+
pss = JSON.stringify(params)
|
|
183
|
+
}
|
|
182
184
|
else
|
|
183
185
|
xhr.open(HttpMethod.GET, key);
|
|
184
186
|
|
|
@@ -316,10 +318,12 @@ export class HttpManager {
|
|
|
316
318
|
const maxRetries = 5; // 最大重试次数
|
|
317
319
|
// 内部辅助函数,用于执行请求逻辑
|
|
318
320
|
const attemptRequest = async () => {
|
|
321
|
+
let httpServer = App.gui.current_config.httpServer;
|
|
322
|
+
if (!httpServer.endsWith('/')) { httpServer += '/'; }
|
|
323
|
+
const url = httpServer + config.url
|
|
319
324
|
try {
|
|
320
325
|
App.gui.OpenBlockEvents(LayerType.LayerBlockEventsNet, true);
|
|
321
326
|
|
|
322
|
-
const url = App.gui.current_config.httpServer + config.url
|
|
323
327
|
if (App.GetDebug()) Logger.debug(`${config.type === HttpType.GET ? "GET请求" : "POST请求"} url:${url} `, `\n 参数:`, params);
|
|
324
328
|
let ret: HttpReturn<any>;
|
|
325
329
|
if (config.type === HttpType.GET) {
|
|
@@ -339,7 +343,7 @@ export class HttpManager {
|
|
|
339
343
|
throw new Error(ret.err); // 请求失败,抛出错误以触发重试逻辑
|
|
340
344
|
}
|
|
341
345
|
} catch (error) {
|
|
342
|
-
console.error(`请求失败: ${error.message}`);
|
|
346
|
+
console.error(`请求失败: ${url} ${error.message}`);
|
|
343
347
|
retries++;
|
|
344
348
|
|
|
345
349
|
if (retries > maxRetries) {
|