dzkcc-mflow 0.0.21 → 0.0.23
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.
- package/README.md +1583 -575
- package/dist/App.d.ts +2 -1
- package/dist/App.js +3 -0
- package/dist/_virtual/_tslib.js +12 -1
- package/dist/core/Api.d.ts +145 -27
- package/dist/core/Core.d.ts +7 -11
- package/dist/core/Core.js +20 -54
- package/dist/core/Decorators.d.ts +115 -5
- package/dist/core/Decorators.js +197 -89
- package/dist/core/index.js +1 -1
- package/dist/libs/BaseView.d.ts +2 -2
- package/dist/libs/BaseView.js +4 -4
- package/dist/libs/CocosCore.js +2 -0
- package/dist/libs/UIManager.d.ts +9 -9
- package/dist/libs/UIManager.js +37 -29
- package/dist/libs/index.d.ts +3 -0
- package/dist/libs/index.js +3 -0
- package/dist/libs/indicator/RedDotManager.d.ts +58 -0
- package/dist/libs/indicator/RedDotManager.js +124 -0
- package/dist/libs/indicator/RedDotNode.d.ts +69 -0
- package/dist/libs/indicator/RedDotNode.js +135 -0
- package/dist/libs/indicator/UIRedDot.d.ts +28 -0
- package/dist/libs/indicator/UIRedDot.js +101 -0
- package/dist/mflow-tools.zip +0 -0
- package/package.json +1 -1
package/dist/App.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ICore, IUIManager, IEventManager, ICocosResManager, IHttpManager, IWebSocketManager } from "./core";
|
|
1
|
+
import { ICore, IUIManager, IEventManager, ICocosResManager, IHttpManager, IWebSocketManager, IRedDotManager } from "./core";
|
|
2
2
|
/**
|
|
3
3
|
* 对外暴露的全局app对像,用于访问基础能力,为上层业务提供了简洁的访问方式
|
|
4
4
|
*
|
|
@@ -13,6 +13,7 @@ export declare class App {
|
|
|
13
13
|
static get socket(): IWebSocketManager;
|
|
14
14
|
static get res(): ICocosResManager;
|
|
15
15
|
static get event(): IEventManager;
|
|
16
|
+
static get reddot(): IRedDotManager;
|
|
16
17
|
static readonly storage: any;
|
|
17
18
|
static readonly audio: any;
|
|
18
19
|
static readonly timer: any;
|
package/dist/App.js
CHANGED
package/dist/_virtual/_tslib.js
CHANGED
|
@@ -15,6 +15,17 @@ PERFORMANCE OF THIS SOFTWARE.
|
|
|
15
15
|
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
|
16
16
|
|
|
17
17
|
|
|
18
|
+
function __decorate(decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function __metadata(metadataKey, metadataValue) {
|
|
26
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
27
|
+
}
|
|
28
|
+
|
|
18
29
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
19
30
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
20
31
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -30,4 +41,4 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
30
41
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
31
42
|
};
|
|
32
43
|
|
|
33
|
-
export { __awaiter };
|
|
44
|
+
export { __awaiter, __decorate, __metadata };
|
package/dist/core/Api.d.ts
CHANGED
|
@@ -1,88 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 核心接口 - 管理 Model 和 Manager 的生命周期
|
|
3
|
+
*/
|
|
1
4
|
export interface ICore {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** 注册 Model - 通过 Symbol 自动实例化 */
|
|
6
|
+
regModel<T extends IModel>(modelSymbol: symbol): void;
|
|
7
|
+
/** 获取 Model */
|
|
8
|
+
getModel<T extends IModel>(modelSymbol: symbol): T;
|
|
9
|
+
/** 注册 Manager - 通过 Symbol 自动实例化 */
|
|
10
|
+
regManager<T extends IManager>(managerSymbol: symbol): void;
|
|
11
|
+
/** 获取 Manager */
|
|
12
|
+
getManager<T extends IManager>(managerSymbol: symbol): T;
|
|
7
13
|
}
|
|
8
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Model 基接口 - 数据模型
|
|
16
|
+
*/
|
|
17
|
+
export interface IModel {
|
|
18
|
+
/** 初始化 */
|
|
9
19
|
initialize(): void;
|
|
10
|
-
dispose(): void;
|
|
11
20
|
}
|
|
12
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Manager 基接口 - 业务逻辑管理器
|
|
23
|
+
*/
|
|
24
|
+
export interface IManager {
|
|
25
|
+
/** 初始化 */
|
|
13
26
|
initialize(): void;
|
|
27
|
+
/** 销毁 */
|
|
28
|
+
dispose(): void;
|
|
14
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* View 基接口 - 视图生命周期
|
|
32
|
+
*/
|
|
15
33
|
export interface IView {
|
|
34
|
+
/** 进入视图 */
|
|
16
35
|
onEnter(args?: any): void;
|
|
36
|
+
/** 退出视图 */
|
|
17
37
|
onExit(): void;
|
|
38
|
+
/** 暂停视图(被其他视图覆盖) */
|
|
18
39
|
onPause(): void;
|
|
40
|
+
/** 恢复视图(从暂停状态恢复) */
|
|
19
41
|
onResume(): void;
|
|
20
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* UI 管理器接口 - 管理视图的打开、关闭和栈操作
|
|
45
|
+
*/
|
|
21
46
|
export interface IUIManager {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
47
|
+
/** 打开视图 */
|
|
48
|
+
open<T extends IView>(viewSymbol: symbol, args?: any): Promise<T>;
|
|
49
|
+
/** 关闭视图 */
|
|
50
|
+
close(viewSymbol: symbol | IView, destory?: boolean): void;
|
|
51
|
+
/** 打开视图并入栈 */
|
|
52
|
+
openAndPush<T extends IView>(viewSymbol: symbol, group: string, args?: any): Promise<T>;
|
|
53
|
+
/** 关闭栈顶视图并弹出 */
|
|
25
54
|
closeAndPop(group: string, destroy?: boolean): void;
|
|
55
|
+
/** 获取栈顶视图 */
|
|
26
56
|
getTopView(): IView | undefined;
|
|
57
|
+
/** 清空视图栈 */
|
|
27
58
|
clearStack(group: string, destroy?: boolean): void;
|
|
28
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* 资源管理器接口
|
|
62
|
+
*/
|
|
29
63
|
export interface IResManager {
|
|
30
64
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
put<T = any>(url: string, data?: any, headers?: Record<string, string>): Promise<T>;
|
|
35
|
-
delete<T = any>(url: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
|
|
36
|
-
request<T = any>(options: HttpRequestOptions): Promise<T>;
|
|
37
|
-
}
|
|
65
|
+
/**
|
|
66
|
+
* HTTP 请求配置
|
|
67
|
+
*/
|
|
38
68
|
export interface HttpRequestOptions {
|
|
69
|
+
/** 请求 URL */
|
|
39
70
|
url: string;
|
|
71
|
+
/** HTTP 方法 */
|
|
40
72
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
|
|
73
|
+
/** 请求头 */
|
|
41
74
|
headers?: Record<string, string>;
|
|
75
|
+
/** URL 参数 */
|
|
42
76
|
params?: Record<string, any>;
|
|
77
|
+
/** 请求体数据 */
|
|
43
78
|
data?: any;
|
|
79
|
+
/** 超时时间(毫秒) */
|
|
44
80
|
timeout?: number;
|
|
45
81
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
82
|
+
/**
|
|
83
|
+
* HTTP 管理器接口 - 处理 HTTP 请求
|
|
84
|
+
*/
|
|
85
|
+
export interface IHttpManager extends IManager {
|
|
86
|
+
/** GET 请求 */
|
|
87
|
+
get<T = any>(url: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
|
|
88
|
+
/** POST 请求 */
|
|
89
|
+
post<T = any>(url: string, data?: any, headers?: Record<string, string>): Promise<T>;
|
|
90
|
+
/** PUT 请求 */
|
|
91
|
+
put<T = any>(url: string, data?: any, headers?: Record<string, string>): Promise<T>;
|
|
92
|
+
/** DELETE 请求 */
|
|
93
|
+
delete<T = any>(url: string, params?: Record<string, any>, headers?: Record<string, string>): Promise<T>;
|
|
94
|
+
/** 通用请求 */
|
|
95
|
+
request<T = any>(options: HttpRequestOptions): Promise<T>;
|
|
55
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* WebSocket 配置
|
|
99
|
+
*/
|
|
56
100
|
export interface WebSocketConfig {
|
|
101
|
+
/** WebSocket URL */
|
|
57
102
|
url: string;
|
|
103
|
+
/** 协议 */
|
|
58
104
|
protocols?: string | string[];
|
|
105
|
+
/** 是否自动重连 */
|
|
59
106
|
reconnect?: boolean;
|
|
107
|
+
/** 重连间隔(毫秒) */
|
|
60
108
|
reconnectInterval?: number;
|
|
109
|
+
/** 重连尝试次数 */
|
|
61
110
|
reconnectAttempts?: number;
|
|
111
|
+
/** 是否启用心跳 */
|
|
62
112
|
heartbeat?: boolean;
|
|
113
|
+
/** 心跳间隔(毫秒) */
|
|
63
114
|
heartbeatInterval?: number;
|
|
115
|
+
/** 心跳消息 */
|
|
64
116
|
heartbeatMessage?: string;
|
|
65
117
|
}
|
|
118
|
+
/**
|
|
119
|
+
* WebSocket 管理器接口 - 管理 WebSocket 连接
|
|
120
|
+
*/
|
|
121
|
+
export interface IWebSocketManager extends IManager {
|
|
122
|
+
/** 连接 WebSocket */
|
|
123
|
+
connect(url: string, protocols?: string | string[]): void;
|
|
124
|
+
/** 断开连接 */
|
|
125
|
+
disconnect(code?: number, reason?: string): void;
|
|
126
|
+
/** 发送数据 */
|
|
127
|
+
send(data: string | ArrayBuffer | Blob | object): void;
|
|
128
|
+
/** 是否已连接 */
|
|
129
|
+
isConnected(): boolean;
|
|
130
|
+
/** 监听事件 */
|
|
131
|
+
on(event: 'open' | 'message' | 'error' | 'close', handler: Function): void;
|
|
132
|
+
/** 移除事件监听 */
|
|
133
|
+
off(event: 'open' | 'message' | 'error' | 'close', handler?: Function): void;
|
|
134
|
+
/** 获取连接状态 */
|
|
135
|
+
getReadyState(): number;
|
|
136
|
+
/** 配置 WebSocket */
|
|
137
|
+
configure(config: Partial<WebSocketConfig>): void;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 事件消息键类型(由业务层扩展)
|
|
141
|
+
*/
|
|
66
142
|
export interface IEventMsgKey {
|
|
67
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* 将索引类型转换为任意类型的索引类型
|
|
146
|
+
*/
|
|
68
147
|
export type ToAnyIndexKey<IndexKey, AnyType> = IndexKey extends keyof AnyType ? IndexKey : keyof AnyType;
|
|
148
|
+
/**
|
|
149
|
+
* 监听器结果回调
|
|
150
|
+
*/
|
|
69
151
|
export type OnListenerResult<T = any> = (data?: T, callBack?: any) => void;
|
|
152
|
+
/**
|
|
153
|
+
* 监听器函数
|
|
154
|
+
*/
|
|
70
155
|
export type OnListener<T = any, K = any> = (value?: T, callBack?: OnListenerResult<K>, ...args: any[]) => void;
|
|
156
|
+
/**
|
|
157
|
+
* 监听器处理器配置
|
|
158
|
+
*/
|
|
71
159
|
export type ListenerHandler<keyType extends keyof any = any, ValueType = any, ResultType = any> = {
|
|
160
|
+
/** 事件键 */
|
|
72
161
|
key: keyType;
|
|
162
|
+
/** 监听函数 */
|
|
73
163
|
listener: OnListener<ValueType[ToAnyIndexKey<keyType, ValueType>], ResultType[ToAnyIndexKey<keyType, ResultType>]>;
|
|
164
|
+
/** 上下文 */
|
|
74
165
|
context?: any;
|
|
166
|
+
/** 额外参数 */
|
|
75
167
|
args?: any[];
|
|
76
168
|
};
|
|
169
|
+
/**
|
|
170
|
+
* 事件管理器接口 - 事件的发布订阅
|
|
171
|
+
*/
|
|
77
172
|
export interface IEventManager<MsgKeyType extends IEventMsgKey = IEventMsgKey, ValueType = any, ResultType = any> {
|
|
173
|
+
/** 监听事件 */
|
|
78
174
|
on<keyType extends keyof MsgKeyType>(keyOrHandler: keyType | ListenerHandler<keyType, ValueType, ResultType> | ListenerHandler<keyType, ValueType, ResultType>[], listener?: OnListener<ValueType[ToAnyIndexKey<keyType, ValueType>], ResultType[ToAnyIndexKey<keyType, ResultType>]>, context?: any, args?: any[]): void;
|
|
175
|
+
/** 监听一次事件 */
|
|
79
176
|
once<keyType extends keyof MsgKeyType>(keyOrHandler: keyType | ListenerHandler<keyType, ValueType, ResultType> | ListenerHandler<keyType, ValueType, ResultType>[], listener?: OnListener<ValueType[ToAnyIndexKey<keyType, ValueType>], ResultType[ToAnyIndexKey<keyType, ResultType>]>, context?: any, args?: any[]): void;
|
|
177
|
+
/** 移除事件监听 */
|
|
80
178
|
off<keyType extends keyof MsgKeyType>(key: keyType, listener: OnListener<ValueType[ToAnyIndexKey<keyType, ValueType>], ResultType[ToAnyIndexKey<keyType, ResultType>]>): void;
|
|
179
|
+
/** 移除所有事件监听 */
|
|
81
180
|
offAll<keyType extends keyof MsgKeyType>(key?: keyType, context?: any): void;
|
|
181
|
+
/** 派发事件 */
|
|
82
182
|
dispatch<keyType extends keyof MsgKeyType>(key: keyType, data?: ValueType[ToAnyIndexKey<keyType, ValueType>], callback?: OnListenerResult<ResultType[ToAnyIndexKey<keyType, ResultType>]>, persistence?: boolean): void;
|
|
183
|
+
/** 派发粘性事件(自动保存) */
|
|
83
184
|
dispatchSticky<keyType extends keyof MsgKeyType>(key: keyType, data?: ValueType[ToAnyIndexKey<keyType, ValueType>], callback?: OnListenerResult<ResultType[ToAnyIndexKey<keyType, ResultType>]>, persistence?: boolean): void;
|
|
185
|
+
/** 移除粘性广播 */
|
|
84
186
|
removeStickyBroadcast(key: keyof MsgKeyType): void;
|
|
187
|
+
/** 检查事件是否已注册 */
|
|
85
188
|
isRegistered(key: keyof MsgKeyType): boolean;
|
|
189
|
+
/** 获取持久化的值 */
|
|
86
190
|
getPersistentValue<keyType extends keyof MsgKeyType>(key: keyType): ValueType[ToAnyIndexKey<keyType, ValueType>] | undefined;
|
|
191
|
+
/** 销毁 */
|
|
87
192
|
dispose(): void;
|
|
88
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* 红点管理器接口 - 管理 UI 红点提示
|
|
196
|
+
*/
|
|
197
|
+
export interface IRedDotManager extends IManager {
|
|
198
|
+
/** 设置红点数量 */
|
|
199
|
+
setCount(nodeId: string, count: number): void;
|
|
200
|
+
/** 获取红点数量 */
|
|
201
|
+
getCount(nodeId: string): number;
|
|
202
|
+
/** 监听红点变化 */
|
|
203
|
+
on(path: string, listener: Function): void;
|
|
204
|
+
/** 移除红点监听 */
|
|
205
|
+
off(path: string, listener: Function): void;
|
|
206
|
+
}
|
package/dist/core/Core.d.ts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import { ICore,
|
|
1
|
+
import { ICore, IManager, IModel } from "./Api";
|
|
2
2
|
export declare abstract class AbstractCore<T extends AbstractCore<T>> implements ICore {
|
|
3
3
|
private readonly container;
|
|
4
4
|
constructor();
|
|
5
5
|
protected abstract initialize(): void;
|
|
6
|
-
regModel<T extends IModel>(
|
|
7
|
-
getModel<T extends IModel>(
|
|
8
|
-
regManager<T extends IManager>(
|
|
9
|
-
getManager<T extends IManager>(
|
|
6
|
+
regModel<T extends IModel>(modelSymbol: symbol): void;
|
|
7
|
+
getModel<T extends IModel>(modelSymbol: symbol): T;
|
|
8
|
+
regManager<T extends IManager>(managerSymbol: symbol): void;
|
|
9
|
+
getManager<T extends IManager>(managerSymbol: symbol): T;
|
|
10
10
|
}
|
|
11
11
|
export declare abstract class AbstractManager implements IManager {
|
|
12
|
-
private eventManager?;
|
|
13
12
|
abstract initialize(): void;
|
|
14
13
|
dispose(): void;
|
|
15
|
-
protected getModel<T extends IModel>(
|
|
16
|
-
protected
|
|
17
|
-
protected getHttpManager(): IHttpManager;
|
|
18
|
-
protected getWebSocketManager(): IWebSocketManager;
|
|
19
|
-
private releaseEventManager;
|
|
14
|
+
protected getModel<T extends IModel>(modelSymbol: symbol): T;
|
|
15
|
+
protected getManager<T extends IManager>(managerSymbol: symbol): T;
|
|
20
16
|
}
|
package/dist/core/Core.js
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
import { ServiceLocator } from './ServiceLocator.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getModelClass, getManagerClass } from './Decorators.js';
|
|
3
3
|
|
|
4
4
|
class Container {
|
|
5
5
|
constructor() {
|
|
6
|
-
this.ctor2ins = new Map(); // 使用构造函数作为键
|
|
7
6
|
this.symbol2ins = new Map();
|
|
8
7
|
}
|
|
9
|
-
|
|
10
|
-
this.ctor2ins.set(type, ins);
|
|
11
|
-
}
|
|
12
|
-
getByCtor(type) {
|
|
13
|
-
const ins = this.ctor2ins.get(type);
|
|
14
|
-
if (!ins)
|
|
15
|
-
throw new Error(`${type.name} not registered!`);
|
|
16
|
-
return ins;
|
|
17
|
-
}
|
|
18
|
-
regBySymbol(ctor, ins) {
|
|
19
|
-
const sym = getInterface(ctor);
|
|
8
|
+
reg(sym, ins) {
|
|
20
9
|
this.symbol2ins.set(sym, ins);
|
|
21
10
|
}
|
|
22
|
-
|
|
11
|
+
get(sym) {
|
|
23
12
|
const ins = this.symbol2ins.get(sym);
|
|
24
13
|
if (!ins)
|
|
25
14
|
throw new Error(`${sym.toString()} not registered!`);
|
|
@@ -32,60 +21,37 @@ class AbstractCore {
|
|
|
32
21
|
this.initialize();
|
|
33
22
|
}
|
|
34
23
|
// 注册与获取模型
|
|
35
|
-
regModel(
|
|
36
|
-
|
|
24
|
+
regModel(modelSymbol) {
|
|
25
|
+
const ModelClass = getModelClass(modelSymbol);
|
|
26
|
+
const model = new ModelClass();
|
|
27
|
+
this.container.reg(modelSymbol, model);
|
|
37
28
|
model.initialize();
|
|
38
29
|
}
|
|
39
|
-
getModel(
|
|
40
|
-
return this.container.
|
|
30
|
+
getModel(modelSymbol) {
|
|
31
|
+
return this.container.get(modelSymbol);
|
|
41
32
|
}
|
|
42
33
|
// 注册与获取管理器
|
|
43
|
-
regManager(
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
this.container.
|
|
34
|
+
regManager(managerSymbol) {
|
|
35
|
+
const ManagerClass = getManagerClass(managerSymbol);
|
|
36
|
+
const manager = new ManagerClass();
|
|
37
|
+
this.container.reg(managerSymbol, manager);
|
|
47
38
|
manager.initialize();
|
|
48
39
|
}
|
|
49
|
-
getManager(
|
|
50
|
-
|
|
51
|
-
return this.container.getBySymbol(indent);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
return this.container.getByCtor(indent);
|
|
55
|
-
}
|
|
40
|
+
getManager(managerSymbol) {
|
|
41
|
+
return this.container.get(managerSymbol);
|
|
56
42
|
}
|
|
57
43
|
}
|
|
58
44
|
class AbstractManager {
|
|
59
45
|
dispose() {
|
|
60
|
-
this.releaseEventManager();
|
|
61
46
|
}
|
|
62
|
-
getModel(
|
|
47
|
+
getModel(modelSymbol) {
|
|
63
48
|
// 保持框架独立性,不与具体应用入口(app类)耦合
|
|
64
49
|
// 框架高内聚,使用ServiceLocator获取core
|
|
65
|
-
return ServiceLocator.getService('core').getModel(
|
|
66
|
-
}
|
|
67
|
-
// 事件管理器获取(通过服务定位器解耦)
|
|
68
|
-
getEventManager() {
|
|
69
|
-
if (!this.eventManager) {
|
|
70
|
-
this.eventManager = ServiceLocator.getService('EventManager');
|
|
71
|
-
}
|
|
72
|
-
return this.eventManager;
|
|
73
|
-
}
|
|
74
|
-
// HTTP 管理器获取
|
|
75
|
-
getHttpManager() {
|
|
76
|
-
return ServiceLocator.getService('HttpManager');
|
|
77
|
-
}
|
|
78
|
-
// WebSocket 管理器获取
|
|
79
|
-
getWebSocketManager() {
|
|
80
|
-
return ServiceLocator.getService('WebSocketManager');
|
|
50
|
+
return ServiceLocator.getService('core').getModel(modelSymbol);
|
|
81
51
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// 假设 IEventManager 有销毁逻辑(如第三方库)
|
|
86
|
-
(_b = (_a = this.eventManager) === null || _a === void 0 ? void 0 : _a.dispose) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
87
|
-
this.eventManager = undefined;
|
|
88
|
-
}
|
|
52
|
+
// 业务模块的事件管理器获取(通过服务定位器解耦)
|
|
53
|
+
getManager(managerSymbol) {
|
|
54
|
+
return ServiceLocator.getService('core').getManager(managerSymbol);
|
|
89
55
|
}
|
|
90
56
|
}
|
|
91
57
|
|
|
@@ -1,7 +1,117 @@
|
|
|
1
|
-
import { ICore
|
|
1
|
+
import { ICore } from "./Api";
|
|
2
2
|
import 'reflect-metadata';
|
|
3
|
-
|
|
4
|
-
export declare
|
|
3
|
+
/** Model 名称到 Symbol 的映射,用于代码补全 */
|
|
4
|
+
export declare const ModelNames: Record<string, symbol>;
|
|
5
|
+
/** Manager 名称到 Symbol 的映射,用于代码补全 */
|
|
6
|
+
export declare const ManagerNames: Record<string, symbol>;
|
|
7
|
+
/** View 名称到 Symbol 的映射,用于代码补全 */
|
|
8
|
+
export declare const ViewNames: Record<string, symbol>;
|
|
9
|
+
/**
|
|
10
|
+
* Model 装饰器,用于注册 Model 到全局注册表
|
|
11
|
+
* @param name 可选的 Model 名称,如果不提供则使用类名
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* @model('User')
|
|
15
|
+
* export class UserModel implements IModel {
|
|
16
|
+
* initialize(): void { }
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // 使用
|
|
20
|
+
* const user = mf.core.getModel(ModelNames.User);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function model(name?: string): (ctor: Function) => void;
|
|
24
|
+
/**
|
|
25
|
+
* 获取所有已注册的 Model 名称
|
|
26
|
+
* @returns Model 名称数组
|
|
27
|
+
*/
|
|
28
|
+
export declare function getRegisteredModelNames(): string[];
|
|
29
|
+
/**
|
|
30
|
+
* 通过 Symbol 获取 Model 类构造函数
|
|
31
|
+
* @param modelSymbol Model 的 Symbol 标识
|
|
32
|
+
* @returns Model 类构造函数
|
|
33
|
+
* @throws 如果 Model 未注册则抛出错误
|
|
34
|
+
*/
|
|
35
|
+
export declare function getModelClass<T>(modelSymbol: symbol): new () => T;
|
|
36
|
+
/**
|
|
37
|
+
* 通过类构造函数获取 Model 的 Symbol
|
|
38
|
+
* @param ctor Model 类构造函数
|
|
39
|
+
* @returns Model 的 Symbol
|
|
40
|
+
* @internal 内部使用
|
|
41
|
+
*/
|
|
42
|
+
export declare function getModelSymbol(ctor: Function): symbol | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Manager 装饰器,用于注册 Manager 到全局注册表
|
|
45
|
+
* @param name 可选的 Manager 名称,如果不提供则使用类名
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* @manager('Game')
|
|
49
|
+
* export class GameManager extends AbstractManager {
|
|
50
|
+
* initialize(): void { }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function manager(name?: string): (ctor: Function) => void;
|
|
55
|
+
/**
|
|
56
|
+
* 获取所有已注册的 Manager 名称
|
|
57
|
+
* @returns Manager 名称数组
|
|
58
|
+
*/
|
|
59
|
+
export declare function getRegisteredManagerNames(): string[];
|
|
60
|
+
/**
|
|
61
|
+
* 通过 Symbol 获取 Manager 类构造函数
|
|
62
|
+
* @param managerSymbol Manager 的 Symbol 标识
|
|
63
|
+
* @returns Manager 类构造函数
|
|
64
|
+
* @throws 如果 Manager 未注册则抛出错误
|
|
65
|
+
*/
|
|
66
|
+
export declare function getManagerClass<T>(managerSymbol: symbol): new () => T;
|
|
67
|
+
/**
|
|
68
|
+
* 通过类构造函数获取 Manager 的 Symbol
|
|
69
|
+
* @param ctor Manager 类构造函数
|
|
70
|
+
* @returns Manager 的 Symbol
|
|
71
|
+
* @internal 内部使用
|
|
72
|
+
*/
|
|
73
|
+
export declare function getManagerSymbol(ctor: Function): symbol | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* View 装饰器,用于注册 View 到全局注册表
|
|
76
|
+
* @param name 可选的 View 名称,如果不提供则使用类名
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* @view('Home')
|
|
80
|
+
* @ccclass('HomeView')
|
|
81
|
+
* export class HomeView extends BaseView {
|
|
82
|
+
* onEnter(): void { }
|
|
83
|
+
* onPause(): void { }
|
|
84
|
+
* onResume(): void { }
|
|
85
|
+
* }
|
|
86
|
+
*
|
|
87
|
+
* // 使用
|
|
88
|
+
* await mf.ui.open(ViewNames.Home);
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
export declare function view(name?: string): (ctor: Function) => void;
|
|
92
|
+
/**
|
|
93
|
+
* 获取所有已注册的 View 名称
|
|
94
|
+
* @returns View 名称数组
|
|
95
|
+
*/
|
|
96
|
+
export declare function getRegisteredViewNames(): string[];
|
|
97
|
+
/**
|
|
98
|
+
* 通过 Symbol 获取 View 类构造函数
|
|
99
|
+
* @param viewSymbol View 的 Symbol 标识
|
|
100
|
+
* @returns View 类构造函数
|
|
101
|
+
* @throws 如果 View 未注册则抛出错误
|
|
102
|
+
*/
|
|
103
|
+
export declare function getViewClass<T>(viewSymbol: symbol): new () => T;
|
|
104
|
+
/**
|
|
105
|
+
* 自动注册所有使用装饰器标记的 Model 和 Manager
|
|
106
|
+
* @param core Core 实例
|
|
107
|
+
* @example
|
|
108
|
+
* ```typescript
|
|
109
|
+
* // 导入所有 Model 和 Manager
|
|
110
|
+
* import '@/models/UserModel';
|
|
111
|
+
* import '@/managers/GameManager';
|
|
112
|
+
*
|
|
113
|
+
* // 自动注册
|
|
114
|
+
* autoRegister(mf.core);
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
5
117
|
export declare function autoRegister(core: ICore): void;
|
|
6
|
-
export declare function managedWithClean(): (ctor: Function) => any;
|
|
7
|
-
export declare function injectManager(sym: symbol): (target: IManager, prop: string) => void;
|