@cc-component/cc-core 1.7.2 → 1.7.3
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.
|
@@ -4,7 +4,7 @@ import { EnvironmentConfig, IConfig } from './IConfig';
|
|
|
4
4
|
import { LayerType } from './LayerType';
|
|
5
5
|
import { Canvas, director } from 'cc';
|
|
6
6
|
import { ResourceManager } from '../home/ResourceManager';
|
|
7
|
-
import { IInitConfig } from './CommonEnum';
|
|
7
|
+
import { IBundleConfig, IInitConfig } from './CommonEnum';
|
|
8
8
|
import { ISceneParam } from '../interface/ISceneParam';
|
|
9
9
|
import { BlockInputEvents } from 'cc';
|
|
10
10
|
import { BaseLaunchComponent } from '../home/BaseLaunchComponent';
|
|
@@ -33,7 +33,7 @@ export class LayerUI {
|
|
|
33
33
|
|
|
34
34
|
loading_call: { open: (finish: () => void) => void, close: () => void }
|
|
35
35
|
progess: { open: (param: ISceneParam, finish: () => void) => void, close: (param: ISceneParam) => void, progess: (param: ISceneParam, progress: number, time?: number) => void }
|
|
36
|
-
|
|
36
|
+
window: { willOpen: (comp: IBundleConfig) => void, open: (comp: IBundleConfig) => void, willClose: (comp: IBundleConfig) => void, close: (comp: IBundleConfig) => void }
|
|
37
37
|
scene: ISceneParam
|
|
38
38
|
launch: BaseLaunchComponent;
|
|
39
39
|
|
|
@@ -137,7 +137,7 @@ export class App {
|
|
|
137
137
|
static OnRequstNet(param: { open: (finish: (isOk: boolean) => void) => void }) { App.http.param = param; }
|
|
138
138
|
static OnLoading(param: { open: (finish: () => void) => void, close: () => void }) { App.gui.loading_call = param; }
|
|
139
139
|
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; }
|
|
140
|
-
|
|
140
|
+
static OnWindow(param: { willOpen: (comp: IBundleConfig) => void, open: (comp: IBundleConfig) => void, willClose: (comp: IBundleConfig) => void, close: (comp: IBundleConfig) => void }) { App.gui.window = param; }
|
|
141
141
|
static async Requst<T>(config: IHttpConfig, params?: any, ext?: IExtData): Promise<{ code: number, data: T, msg: string }> {
|
|
142
142
|
return new Promise<{ code: number, data: T, msg: string }>(async (originalResolve, originalReject) => {
|
|
143
143
|
let retries = 0; // 当前重试次数
|
|
@@ -205,6 +205,7 @@ export class App {
|
|
|
205
205
|
return new Promise<T>(async (resolve, reject) => {
|
|
206
206
|
try {
|
|
207
207
|
const className = config.name ?? config.path.split('/').pop();
|
|
208
|
+
config.name = className;
|
|
208
209
|
if (App.IsWindowOpen(className)) {
|
|
209
210
|
const view = App.GetOpenWindow<Component>(config);
|
|
210
211
|
resolve(view as T);
|
|
@@ -216,6 +217,7 @@ export class App {
|
|
|
216
217
|
Logger.warn("重复打开窗口-请检查", config.path)
|
|
217
218
|
return;
|
|
218
219
|
}
|
|
220
|
+
App.gui.window?.willOpen?.(config)
|
|
219
221
|
//console.error('打开:', Array.from(App.Instance.openedWindows.keys()), config.path);
|
|
220
222
|
App.OpenBlockEvents(LayerType.LayerBlockEventsUI, true)
|
|
221
223
|
if (!param) {
|
|
@@ -256,6 +258,7 @@ export class App {
|
|
|
256
258
|
if (layerUI_list && layerUI_list.length > 0) App.gui.GetLayer(LayerType.LayerGame).active = false;
|
|
257
259
|
Logger.debug('LayerType.LayerUI 打开窗口记录:', className, list);
|
|
258
260
|
App.Emit(SystemMessage.OpenWindow, className)
|
|
261
|
+
App.gui.window?.open?.(config)
|
|
259
262
|
|
|
260
263
|
resolve(view);
|
|
261
264
|
//延迟100毫秒防止连点
|
|
@@ -272,6 +275,8 @@ export class App {
|
|
|
272
275
|
return new Promise<T>(async (resolve, reject) => {
|
|
273
276
|
try {
|
|
274
277
|
const className = config.name ?? config.path.split('/').pop();
|
|
278
|
+
//@ts-ignore
|
|
279
|
+
config.name = className;
|
|
275
280
|
// 记录打开的窗口--先占位
|
|
276
281
|
if (config.is_record === undefined || config.is_record) {//默认记录
|
|
277
282
|
App.Ins.openedWindows.set(className, null);
|
|
@@ -287,8 +292,6 @@ export class App {
|
|
|
287
292
|
App.Ins.openedWindowsConfig.set(className, config);
|
|
288
293
|
}
|
|
289
294
|
//@ts-ignore
|
|
290
|
-
config.name = className;
|
|
291
|
-
//@ts-ignore
|
|
292
295
|
view.config = config;
|
|
293
296
|
//@ts-ignore
|
|
294
297
|
if (param) view.param = param;
|
|
@@ -396,10 +399,11 @@ export class App {
|
|
|
396
399
|
|
|
397
400
|
// 设置窗口关闭监听
|
|
398
401
|
private setupCloseListener(view: Component, className: string) {
|
|
399
|
-
|
|
402
|
+
const config = App.Ins.openedWindowsConfig.get(className);
|
|
403
|
+
const old_destroy = view.node.destroy
|
|
400
404
|
view.node.destroy = () => {
|
|
401
405
|
this.removeWindowRecord(className);
|
|
402
|
-
return view.node
|
|
406
|
+
return old_destroy.call(view.node)
|
|
403
407
|
}
|
|
404
408
|
// 监听节点销毁事件
|
|
405
409
|
// view.node.once(Node.EventType.NODE_DESTROYED, () => {
|
|
@@ -433,6 +437,7 @@ export class App {
|
|
|
433
437
|
this.openedWindows.delete(className);
|
|
434
438
|
this.openedWindowsConfig.delete(className);
|
|
435
439
|
App.Emit(SystemMessage.CloseWindow, className)
|
|
440
|
+
App.gui.window?.close?.(config)
|
|
436
441
|
}
|
|
437
442
|
|
|
438
443
|
// 通过配置关闭窗口
|
|
@@ -56,6 +56,8 @@ declare global {
|
|
|
56
56
|
function OnLoading(param: { open: (finish: () => void) => void, close: () => void })
|
|
57
57
|
/**监听:是否打开网络接口重连窗口 -open 回调方法需要执行 finish() 方法 */
|
|
58
58
|
function OnRequstNet(param: { open: (finish: (isOk: boolean) => void) => void })
|
|
59
|
+
/**监听窗口打开关闭 */
|
|
60
|
+
function OnWindow(param: { willOpen: (comp: IBundleConfig) => void, open: (comp: IBundleConfig) => void, willClose: (comp: IBundleConfig) => void, close: (comp: IBundleConfig) => void });
|
|
59
61
|
/**=====================================✅✅Http请求======================= */
|
|
60
62
|
/**网络接口 */
|
|
61
63
|
function Requst<T>(config: IHttpConfig, params?: any, ext?: { is_show_alert?: boolean }): Promise<{ code: number, data: T, msg: string }>;
|