@cc-component/cc-core 1.7.2 → 1.7.4

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.
@@ -96,6 +96,6 @@ export interface IInitConfig {
96
96
 
97
97
 
98
98
  export interface IWindowParam {
99
- callBack?: Function;
99
+ close?: Function;
100
100
  [key: string]: any;
101
101
  }
@@ -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, param: any) => 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,18 +217,10 @@ export class App {
216
217
  Logger.warn("重复打开窗口-请检查", config.path)
217
218
  return;
218
219
  }
220
+ if (!param) { param = {} }
221
+ App.gui.window?.willOpen?.(config, param)
219
222
  //console.error('打开:', Array.from(App.Instance.openedWindows.keys()), config.path);
220
223
  App.OpenBlockEvents(LayerType.LayerBlockEventsUI, true)
221
- if (!param) {
222
- param = {}
223
- }
224
- //界面回调方法
225
- const call = param?.callBack;
226
- const backCallback = (arg1: any, arg2: any) => {
227
- call?.(arg1, arg2)
228
- }
229
- if (param instanceof Object)
230
- param.callBack = backCallback;
231
224
 
232
225
  const view = await App.LoadWindow<T>(config, param);
233
226
 
@@ -256,6 +249,7 @@ export class App {
256
249
  if (layerUI_list && layerUI_list.length > 0) App.gui.GetLayer(LayerType.LayerGame).active = false;
257
250
  Logger.debug('LayerType.LayerUI 打开窗口记录:', className, list);
258
251
  App.Emit(SystemMessage.OpenWindow, className)
252
+ App.gui.window?.open?.(config)
259
253
 
260
254
  resolve(view);
261
255
  //延迟100毫秒防止连点
@@ -272,6 +266,8 @@ export class App {
272
266
  return new Promise<T>(async (resolve, reject) => {
273
267
  try {
274
268
  const className = config.name ?? config.path.split('/').pop();
269
+ //@ts-ignore
270
+ config.name = className;
275
271
  // 记录打开的窗口--先占位
276
272
  if (config.is_record === undefined || config.is_record) {//默认记录
277
273
  App.Ins.openedWindows.set(className, null);
@@ -287,8 +283,6 @@ export class App {
287
283
  App.Ins.openedWindowsConfig.set(className, config);
288
284
  }
289
285
  //@ts-ignore
290
- config.name = className;
291
- //@ts-ignore
292
286
  view.config = config;
293
287
  //@ts-ignore
294
288
  if (param) view.param = param;
@@ -396,10 +390,11 @@ export class App {
396
390
 
397
391
  // 设置窗口关闭监听
398
392
  private setupCloseListener(view: Component, className: string) {
399
- view.node["old_destroy"] = view.node.destroy
393
+ const config = App.Ins.openedWindowsConfig.get(className);
394
+ const old_destroy = view.node.destroy
400
395
  view.node.destroy = () => {
401
396
  this.removeWindowRecord(className);
402
- return view.node["old_destroy"]()
397
+ return old_destroy.call(view.node)
403
398
  }
404
399
  // 监听节点销毁事件
405
400
  // view.node.once(Node.EventType.NODE_DESTROYED, () => {
@@ -433,6 +428,7 @@ export class App {
433
428
  this.openedWindows.delete(className);
434
429
  this.openedWindowsConfig.delete(className);
435
430
  App.Emit(SystemMessage.CloseWindow, className)
431
+ App.gui.window?.close?.(config)
436
432
  }
437
433
 
438
434
  // 通过配置关闭窗口
@@ -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, param: any) => 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 }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cc-component/cc-core",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "engine": ">=3.8.6",
5
5
  "description": "系统组件添加常用扩展方法",
6
6
  "main": "index.ts",