@chiyou/minigame-framework 1.3.0 → 1.3.2

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.
Files changed (27) hide show
  1. package/package.json +1 -1
  2. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.ts +28 -2
  3. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.ts +8 -1
  4. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.ts +28 -2
  5. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.ts +31 -5
  6. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.ts +34 -1
  7. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.ts +28 -2
  8. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.ts +17 -2
  9. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.ts +31 -5
  10. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.ts +32 -4
  11. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.ts +28 -2
  12. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.ts +31 -5
  13. package/src/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.ts +31 -5
  14. package/src/Framework/Definition/AnalyticsDefinition.ts +107 -0
  15. package/src/Framework/Definition/FwkErrorDefinition.ts +18 -2
  16. package/src/Framework/Definition/SystemDefinition.ts +12 -1
  17. package/src/Framework/Definition/UIDefinition.ts +6 -0
  18. package/src/Framework/Manager/AnalyticsMgr.ts +351 -0
  19. package/src/Framework/Manager/AudioMgr.ts +56 -7
  20. package/src/Framework/Manager/InputMgr.ts +61 -0
  21. package/src/Framework/Manager/NodePoolMgr.ts +59 -1
  22. package/src/Framework/Manager/TimerMgr.ts +49 -0
  23. package/src/Framework/Manager/UIMgr.ts +75 -9
  24. package/src/Framework/SDK/Umeng/umtrack-wx-game.ts +107 -0
  25. package/src/Framework/Utils/LogUtils.ts +27 -0
  26. package/src/Framework/Utils/ObjectUtils.ts +111 -0
  27. package/src/index.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chiyou/minigame-framework",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "基于 Cocos Creator 3.x 的小游戏开发框架,支持多平台发布",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -265,12 +265,38 @@ export class PlatformAdapterBilibili extends AbsPlatformAdapter {
265
265
  }
266
266
 
267
267
  public getScreenInfo(): ScreenInfo {
268
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
268
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
269
+ left: 0, right: 0, top: 0,bottom: 0,
270
+ width: 0, height: 0
271
+ });
269
272
 
270
273
  if (window["bl"] && window["bl"].getSystemInfoSync) {
271
274
  let systemInfo: any = window["bl"].getSystemInfoSync();
272
275
  if (systemInfo !== null) {
273
- screenInfo = new ScreenInfo(screenInfo.windowWidth, screenInfo.windowHeight, systemInfo.screenWidth, systemInfo.screenHeight);
276
+ screenInfo.screenWidth = systemInfo.screenWidth;
277
+ screenInfo.screenHeight = systemInfo.screenHeight;
278
+ screenInfo.windowWidth = systemInfo.windowWidth;
279
+ screenInfo.windowHeight = systemInfo.windowHeight;
280
+
281
+ if (systemInfo.safeArea !== null) {
282
+ screenInfo.safeArea = {
283
+ left: systemInfo.safeArea.left,
284
+ right: systemInfo.safeArea.right,
285
+ top: systemInfo.safeArea.top,
286
+ bottom: systemInfo.safeArea.bottom,
287
+ width: systemInfo.safeArea.width,
288
+ height: systemInfo.safeArea.height,
289
+ }
290
+ } else {
291
+ screenInfo.safeArea = {
292
+ left: 0,
293
+ right: systemInfo.screenWidth,
294
+ top: 0,
295
+ bottom: systemInfo.screenHeight,
296
+ width: systemInfo.screenWidth,
297
+ height: systemInfo.screenHeight,
298
+ }
299
+ }
274
300
  }
275
301
  }
276
302
 
@@ -113,7 +113,14 @@ export class PlatformAdapterDesktopBrowser extends AbsPlatformAdapter {
113
113
  }
114
114
 
115
115
  public getScreenInfo(): ScreenInfo {
116
- let screenInfo: ScreenInfo = new ScreenInfo(screen.width, screen.height, screen.width, screen.height);
116
+ let screenWidth = screen.width;
117
+ let screenHeight = screen.height;
118
+
119
+ let screenInfo: ScreenInfo = new ScreenInfo(
120
+ screenWidth, screenHeight, screenWidth, screenHeight, {
121
+ left: 0, right: screenWidth, top: 0,bottom: screenHeight,
122
+ width: screenWidth, height: screenHeight
123
+ });
117
124
 
118
125
  LogUtils.Instance.info(PlatformAdapterDesktopBrowser.TAG, "获取屏幕信息", {
119
126
  operation: "getScreenInfo",
@@ -281,12 +281,38 @@ export class PlatformAdapterDouYin extends AbsPlatformAdapter {
281
281
  }
282
282
 
283
283
  public getScreenInfo(): ScreenInfo {
284
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
284
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
285
+ left: 0, right: 0, top: 0,bottom: 0,
286
+ width: 0, height: 0
287
+ });
285
288
 
286
289
  if (window["tt"] && window["tt"].getSystemInfoSync) {
287
290
  let systemInfo: any = window["tt"].getSystemInfoSync();
288
291
  if (systemInfo !== null) {
289
- screenInfo = new ScreenInfo(systemInfo.windowWidth, systemInfo.windowHeight, systemInfo.screenWidth, systemInfo.screenHeight);
292
+ screenInfo.screenWidth = systemInfo.screenWidth;
293
+ screenInfo.screenHeight = systemInfo.screenHeight;
294
+ screenInfo.windowWidth = systemInfo.windowWidth;
295
+ screenInfo.windowHeight = systemInfo.windowHeight;
296
+
297
+ if (systemInfo.safeArea !== null) {
298
+ screenInfo.safeArea = {
299
+ left: systemInfo.safeArea.left,
300
+ right: systemInfo.safeArea.right,
301
+ top: systemInfo.safeArea.top,
302
+ bottom: systemInfo.safeArea.bottom,
303
+ width: systemInfo.safeArea.width,
304
+ height: systemInfo.safeArea.height,
305
+ }
306
+ } else {
307
+ screenInfo.safeArea = {
308
+ left: 0,
309
+ right: systemInfo.screenWidth,
310
+ top: 0,
311
+ bottom: systemInfo.screenHeight,
312
+ width: systemInfo.screenWidth,
313
+ height: systemInfo.screenHeight,
314
+ }
315
+ }
290
316
  }
291
317
  }
292
318
 
@@ -187,12 +187,38 @@ export class PlatformAdapterHonor extends AbsPlatformAdapter {
187
187
  }
188
188
 
189
189
  public getScreenInfo(): ScreenInfo {
190
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
190
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
191
+ left: 0, right: 0, top: 0,bottom: 0,
192
+ width: 0, height: 0
193
+ });
191
194
 
192
- if (window["qg"] && window["qg"].getWindowInfo) {
193
- let windowInfo: any = window["qg"].getWindowInfo();
194
- if (windowInfo !== null) {
195
- screenInfo = new ScreenInfo(windowInfo.windowWidth, windowInfo.windowHeight, windowInfo.screenWidth, windowInfo.screenHeight);
195
+ if (window["qg"] && window["qg"].getSystemInfoSync) {
196
+ let systemInfo: any = window["qg"].getSystemInfoSync();
197
+ if (systemInfo !== null) {
198
+ screenInfo.screenWidth = systemInfo.screenWidth;
199
+ screenInfo.screenHeight = systemInfo.screenHeight;
200
+ screenInfo.windowWidth = systemInfo.windowWidth;
201
+ screenInfo.windowHeight = systemInfo.windowHeight;
202
+
203
+ if (systemInfo.safeArea !== null) {
204
+ screenInfo.safeArea = {
205
+ left: systemInfo.safeArea.left,
206
+ right: systemInfo.safeArea.right,
207
+ top: systemInfo.safeArea.top,
208
+ bottom: systemInfo.safeArea.bottom,
209
+ width: systemInfo.safeArea.width,
210
+ height: systemInfo.safeArea.height,
211
+ }
212
+ } else {
213
+ screenInfo.safeArea = {
214
+ left: 0,
215
+ right: systemInfo.screenWidth,
216
+ top: 0,
217
+ bottom: systemInfo.screenHeight,
218
+ width: systemInfo.screenWidth,
219
+ height: systemInfo.screenHeight,
220
+ }
221
+ }
196
222
  }
197
223
  }
198
224
 
@@ -184,7 +184,40 @@ export class PlatformAdapterHuaWei extends AbsPlatformAdapter {
184
184
  }
185
185
 
186
186
  public getScreenInfo(): ScreenInfo {
187
- let screenInfo: ScreenInfo = new ScreenInfo(screen.availWidth, screen.availHeight, screen.width, screen.height);
187
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
188
+ left: 0, right: 0, top: 0,bottom: 0,
189
+ width: 0, height: 0
190
+ });
191
+
192
+ if (window["qg"] && window["qg"].getSystemInfoSync) {
193
+ let systemInfo: any = window["qg"].getSystemInfoSync();
194
+ if (systemInfo !== null) {
195
+ screenInfo.screenWidth = systemInfo.screenWidth;
196
+ screenInfo.screenHeight = systemInfo.screenHeight;
197
+ screenInfo.windowWidth = systemInfo.windowWidth;
198
+ screenInfo.windowHeight = systemInfo.windowHeight;
199
+
200
+ if (systemInfo.safeArea !== null) {
201
+ screenInfo.safeArea = {
202
+ left: systemInfo.safeArea.left,
203
+ right: systemInfo.safeArea.right,
204
+ top: systemInfo.safeArea.top,
205
+ bottom: systemInfo.safeArea.bottom,
206
+ width: systemInfo.safeArea.width,
207
+ height: systemInfo.safeArea.height,
208
+ }
209
+ } else {
210
+ screenInfo.safeArea = {
211
+ left: 0,
212
+ right: systemInfo.screenWidth,
213
+ top: 0,
214
+ bottom: systemInfo.screenHeight,
215
+ width: systemInfo.screenWidth,
216
+ height: systemInfo.screenHeight,
217
+ }
218
+ }
219
+ }
220
+ }
188
221
 
189
222
  LogUtils.Instance.info(PlatformAdapterHuaWei.TAG, "获取屏幕信息", {
190
223
  operation: "getScreenInfo",
@@ -222,12 +222,38 @@ export class PlatformAdapterKuaiShou extends AbsPlatformAdapter {
222
222
  }
223
223
 
224
224
  public getScreenInfo(): ScreenInfo {
225
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
225
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
226
+ left: 0, right: 0, top: 0,bottom: 0,
227
+ width: 0, height: 0
228
+ });
226
229
 
227
230
  if (window["ks"] && window["ks"].getSystemInfoSync) {
228
231
  let systemInfo: any = window["ks"].getSystemInfoSync();
229
232
  if (systemInfo !== null) {
230
- screenInfo = new ScreenInfo(systemInfo.windowWidth, systemInfo.windowHeight, systemInfo.screenWidth, systemInfo.screenHeight);
233
+ screenInfo.screenWidth = systemInfo.screenWidth;
234
+ screenInfo.screenHeight = systemInfo.screenHeight;
235
+ screenInfo.windowWidth = systemInfo.windowWidth;
236
+ screenInfo.windowHeight = systemInfo.windowHeight;
237
+
238
+ if (systemInfo.safeArea !== null) {
239
+ screenInfo.safeArea = {
240
+ left: systemInfo.safeArea.left,
241
+ right: systemInfo.safeArea.right,
242
+ top: systemInfo.safeArea.top,
243
+ bottom: systemInfo.safeArea.bottom,
244
+ width: systemInfo.safeArea.width,
245
+ height: systemInfo.safeArea.height,
246
+ }
247
+ } else {
248
+ screenInfo.safeArea = {
249
+ left: 0,
250
+ right: systemInfo.screenWidth,
251
+ top: 0,
252
+ bottom: systemInfo.screenHeight,
253
+ width: systemInfo.screenWidth,
254
+ height: systemInfo.screenHeight,
255
+ }
256
+ }
231
257
  }
232
258
  }
233
259
 
@@ -187,12 +187,27 @@ export class PlatformAdapterOppo extends AbsPlatformAdapter {
187
187
  }
188
188
 
189
189
  public getScreenInfo(): ScreenInfo {
190
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
190
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
191
+ left: 0, right: 0, top: 0,bottom: 0,
192
+ width: 0, height: 0
193
+ });
191
194
 
192
195
  if (window["qg"] && window["qg"].getSystemInfoSync) {
193
196
  let systemInfo: any = window["qg"].getSystemInfoSync();
194
197
  if (systemInfo !== null) {
195
- screenInfo = new ScreenInfo(systemInfo.windowWidth, systemInfo.windowHeight, systemInfo.screenWidth, systemInfo.screenHeight);
198
+ screenInfo.screenWidth = systemInfo.screenWidth;
199
+ screenInfo.screenHeight = systemInfo.screenHeight;
200
+ screenInfo.windowWidth = systemInfo.windowWidth;
201
+ screenInfo.windowHeight = systemInfo.windowHeight;
202
+
203
+ screenInfo.safeArea = {
204
+ left: 0,
205
+ right: systemInfo.screenWidth,
206
+ top: 0,
207
+ bottom: systemInfo.screenHeight,
208
+ width: systemInfo.screenWidth,
209
+ height: systemInfo.screenHeight,
210
+ }
196
211
  }
197
212
  }
198
213
 
@@ -202,12 +202,38 @@ export class PlatformAdapterTapTap extends AbsPlatformAdapter {
202
202
  }
203
203
 
204
204
  public getScreenInfo(): ScreenInfo {
205
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
205
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
206
+ left: 0, right: 0, top: 0,bottom: 0,
207
+ width: 0, height: 0
208
+ });
206
209
 
207
- if (window["tap"] && window["tap"].getSystemInfoSync) {
208
- let systemInfo: any = window["tap"].getSystemInfoSync();
209
- if (systemInfo !== null) {
210
- screenInfo = new ScreenInfo(systemInfo.windowWidth, systemInfo.windowHeight, systemInfo.screenWidth, systemInfo.screenHeight);
210
+ if (window["tap"] && window["tap"].getWindowInfo) {
211
+ let windowInfo: any = window["tap"].getWindowInfo();
212
+ if (windowInfo !== null) {
213
+ screenInfo.screenWidth = windowInfo.screenWidth;
214
+ screenInfo.screenHeight = windowInfo.screenHeight;
215
+ screenInfo.windowWidth = windowInfo.windowWidth;
216
+ screenInfo.windowHeight = windowInfo.windowHeight;
217
+
218
+ if (windowInfo.safeArea !== null) {
219
+ screenInfo.safeArea = {
220
+ left: windowInfo.safeArea.left,
221
+ right: windowInfo.safeArea.right,
222
+ top: windowInfo.safeArea.top,
223
+ bottom: windowInfo.safeArea.bottom,
224
+ width: windowInfo.safeArea.width,
225
+ height: windowInfo.safeArea.height,
226
+ }
227
+ } else {
228
+ screenInfo.safeArea = {
229
+ left: 0,
230
+ right: windowInfo.screenWidth,
231
+ top: 0,
232
+ bottom: windowInfo.screenHeight,
233
+ width: windowInfo.screenWidth,
234
+ height: windowInfo.screenHeight,
235
+ }
236
+ }
211
237
  }
212
238
  }
213
239
 
@@ -175,12 +175,40 @@ export class PlatformAdapterVivo extends AbsPlatformAdapter {
175
175
  }
176
176
 
177
177
  public getScreenInfo(): ScreenInfo {
178
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
178
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
179
+ left: 0, right: 0, top: 0,bottom: 0,
180
+ width: 0, height: 0
181
+ });
179
182
 
180
- if (window["qg"] && window["qg"].getWindowInfo) {
183
+ if (window["qg"] && window["qg"].getWindowInfo && window["qg"].getSystemInfoSync) {
184
+ let systemInfo: any = window["qg"].getSystemInfoSync();
181
185
  let windowInfo: any = window["qg"].getWindowInfo();
182
- if (windowInfo !== null) {
183
- screenInfo = new ScreenInfo(windowInfo.windowWidth, windowInfo.windowHeight, windowInfo.windowWidth, windowInfo.windowHeight);
186
+
187
+ if (windowInfo !== null && systemInfo !== null) {
188
+ screenInfo.screenWidth = systemInfo.screenWidth;
189
+ screenInfo.screenHeight = systemInfo.screenHeight;
190
+ screenInfo.windowWidth = windowInfo.windowWidth;
191
+ screenInfo.windowHeight = windowInfo.windowHeight;
192
+
193
+ if (windowInfo.safeArea !== null) {
194
+ screenInfo.safeArea = {
195
+ left: windowInfo.safeArea.left,
196
+ right: windowInfo.safeArea.right,
197
+ top: windowInfo.safeArea.top,
198
+ bottom: windowInfo.safeArea.bottom,
199
+ width: windowInfo.safeArea.width,
200
+ height: windowInfo.safeArea.height,
201
+ }
202
+ } else {
203
+ screenInfo.safeArea = {
204
+ left: 0,
205
+ right: systemInfo.screenWidth,
206
+ top: 0,
207
+ bottom: systemInfo.screenHeight,
208
+ width: systemInfo.screenWidth,
209
+ height: systemInfo.screenHeight,
210
+ }
211
+ }
184
212
  }
185
213
  }
186
214
 
@@ -342,12 +342,38 @@ export class PlatformAdapterWeiXin extends AbsPlatformAdapter {
342
342
  }
343
343
 
344
344
  public getScreenInfo(): ScreenInfo {
345
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
345
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
346
+ left: 0, right: 0, top: 0,bottom: 0,
347
+ width: 0, height: 0
348
+ });
346
349
 
347
350
  if (window["wx"] && window["wx"].getWindowInfo) {
348
351
  let windowInfo: any = window["wx"].getWindowInfo();
349
352
  if (windowInfo !== null) {
350
- screenInfo = new ScreenInfo(windowInfo.windowWidth, windowInfo.windowHeight, windowInfo.screenWidth, windowInfo.screenHeight);
353
+ screenInfo.screenWidth = windowInfo.screenWidth;
354
+ screenInfo.screenHeight = windowInfo.screenHeight;
355
+ screenInfo.windowWidth = windowInfo.windowWidth;
356
+ screenInfo.windowHeight = windowInfo.windowHeight;
357
+
358
+ if (windowInfo.safeArea !== null) {
359
+ screenInfo.safeArea = {
360
+ left: windowInfo.safeArea.left,
361
+ right: windowInfo.safeArea.right,
362
+ top: windowInfo.safeArea.top,
363
+ bottom: windowInfo.safeArea.bottom,
364
+ width: windowInfo.safeArea.width,
365
+ height: windowInfo.safeArea.height,
366
+ }
367
+ } else {
368
+ screenInfo.safeArea = {
369
+ left: 0,
370
+ right: windowInfo.screenWidth,
371
+ top: 0,
372
+ bottom: windowInfo.screenHeight,
373
+ width: windowInfo.screenWidth,
374
+ height: windowInfo.screenHeight,
375
+ }
376
+ }
351
377
  }
352
378
  }
353
379
 
@@ -182,12 +182,38 @@ export class PlatformAdapterXiaoMi extends AbsPlatformAdapter {
182
182
  }
183
183
 
184
184
  public getScreenInfo(): ScreenInfo {
185
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
185
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
186
+ left: 0, right: 0, top: 0,bottom: 0,
187
+ width: 0, height: 0
188
+ });
186
189
 
187
- if (window["qg"] && window["qg"].getWindowInfo) {
188
- let windowInfo: any = window["qg"].getWindowInfo();
189
- if (windowInfo !== null) {
190
- screenInfo = new ScreenInfo(windowInfo.windowWidth, windowInfo.windowHeight, windowInfo.windowWidth, windowInfo.windowHeight);
190
+ if (window["qg"] && window["qg"].getSystemInfoSync) {
191
+ let systemInfo: any = window["qg"].getSystemInfoSync();
192
+ if (systemInfo !== null) {
193
+ screenInfo.screenWidth = systemInfo.screenWidth;
194
+ screenInfo.screenHeight = systemInfo.screenHeight;
195
+ screenInfo.windowWidth = systemInfo.windowWidth;
196
+ screenInfo.windowHeight = systemInfo.windowHeight;
197
+
198
+ if (systemInfo.safeArea !== null) {
199
+ screenInfo.safeArea = {
200
+ left: systemInfo.safeArea.left,
201
+ right: systemInfo.safeArea.right,
202
+ top: systemInfo.safeArea.top,
203
+ bottom: systemInfo.safeArea.bottom,
204
+ width: systemInfo.safeArea.width,
205
+ height: systemInfo.safeArea.height,
206
+ }
207
+ } else {
208
+ screenInfo.safeArea = {
209
+ left: 0,
210
+ right: systemInfo.screenWidth,
211
+ top: 0,
212
+ bottom: systemInfo.screenHeight,
213
+ width: systemInfo.screenWidth,
214
+ height: systemInfo.screenHeight,
215
+ }
216
+ }
191
217
  }
192
218
  }
193
219
 
@@ -179,12 +179,38 @@ export class PlatformAdapterZhiFuBao extends AbsPlatformAdapter {
179
179
  }
180
180
 
181
181
  public getScreenInfo(): ScreenInfo {
182
- let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0);
182
+ let screenInfo: ScreenInfo = new ScreenInfo(0, 0, 0, 0, {
183
+ left: 0, right: 0, top: 0,bottom: 0,
184
+ width: 0, height: 0
185
+ });
183
186
 
184
- if (window["my"] && window["my"].getSystemInfoSync) {
185
- let systemInfo: any = window["my"].getSystemInfoSync();
186
- if (systemInfo !== null) {
187
- screenInfo = new ScreenInfo(systemInfo.windowWidth, systemInfo.windowHeight, systemInfo.screenWidth, systemInfo.screenHeight);
187
+ if (window["my"] && window["my"].getWindowInfo) {
188
+ let windowInfo: any = window["my"].getWindowInfo();
189
+ if (windowInfo !== null) {
190
+ screenInfo.screenWidth = windowInfo.screenWidth;
191
+ screenInfo.screenHeight = windowInfo.screenHeight;
192
+ screenInfo.windowWidth = windowInfo.windowWidth;
193
+ screenInfo.windowHeight = windowInfo.windowHeight;
194
+
195
+ if (windowInfo.safeArea !== null) {
196
+ screenInfo.safeArea = {
197
+ left: windowInfo.safeArea.left,
198
+ right: windowInfo.safeArea.right,
199
+ top: windowInfo.safeArea.top,
200
+ bottom: windowInfo.safeArea.bottom,
201
+ width: windowInfo.safeArea.width,
202
+ height: windowInfo.safeArea.height,
203
+ }
204
+ } else {
205
+ screenInfo.safeArea = {
206
+ left: 0,
207
+ right: windowInfo.screenWidth,
208
+ top: 0,
209
+ bottom: windowInfo.screenHeight,
210
+ width: windowInfo.screenWidth,
211
+ height: windowInfo.screenHeight,
212
+ }
213
+ }
188
214
  }
189
215
  }
190
216
 
@@ -0,0 +1,107 @@
1
+ /**
2
+ * AnalyticsDefinition.ts
3
+ * 统计分析模块类型定义
4
+ */
5
+
6
+ import { PlatformID } from "./SystemDefinition";
7
+
8
+ // ==================== 基础类型 ====================
9
+
10
+ /** 事件参数类型 */
11
+ export type EventParams = Record<string, string | number | boolean> | string;
12
+
13
+ // ==================== 配置接口 ====================
14
+
15
+ /** 友盟 SDK 配置 */
16
+ export interface UmengConfig {
17
+ /** 各平台 appKey 映射(必填) */
18
+ appKeyMap: Map<PlatformID, string>;
19
+ /** 是否使用 openid 进行统计 @default false */
20
+ useOpenid?: boolean;
21
+ /** 是否自动获取 openid @default false */
22
+ autoGetOpenid?: boolean;
23
+ /** 是否开启调试模式 @default false */
24
+ debug?: boolean;
25
+ }
26
+
27
+ /** 统计分析总配置 */
28
+ export interface AnalyticsConfig {
29
+ /** 是否启用统计功能 */
30
+ enable: boolean;
31
+ /** 友盟配置 */
32
+ umeng?: UmengConfig;
33
+ }
34
+
35
+ // ==================== 用户相关 ====================
36
+
37
+ /** 用户属性 */
38
+ export interface UserProperties {
39
+ userId?: string;
40
+ provider?: string;
41
+ nickName?: string;
42
+ avatarUrl?: string;
43
+ gender?: number;
44
+ country?: string;
45
+ province?: string;
46
+ city?: string;
47
+ [key: string]: any;
48
+ }
49
+
50
+ // ==================== 友盟 SDK 接口 ====================
51
+
52
+ /** 友盟 SDK 实例方法 */
53
+ export interface UmengSDK {
54
+ init(config: UmengConfig): void;
55
+ resume(options?: any): void;
56
+ pause(): void;
57
+ trackEvent(eventName: string, params?: object | string): void;
58
+ trackShare(shareOptions: object): object;
59
+ trackPageStart(pageName: string): void;
60
+ trackPageEnd(pageName: string): void;
61
+ setOpenid(openid: string): void;
62
+ setUnionid(unionid: string): void;
63
+ setUserid(userid: string, provider?: string): void;
64
+ removeUserid(): void;
65
+ setUserInfo(userInfo: object): void;
66
+ setAnonymousid(anonymousid: string): void;
67
+ setAppVersion(version: string): void;
68
+ setSuperProperty(property: string): void;
69
+ onShareAppMessage(callback: () => object): void;
70
+ shareAppMessage(options: object): void;
71
+ }
72
+
73
+ // ==================== 预定义事件 ID ====================
74
+
75
+ /** 预定义事件 ID */
76
+ export enum AnalyticsEventId {
77
+ LevelStart = 'level_start',
78
+ LevelComplete = 'level_complete',
79
+ LevelFail = 'level_fail',
80
+ AdShow = 'ad_show',
81
+ AdClick = 'ad_click',
82
+ AdComplete = 'ad_complete',
83
+ AdSkip = 'ad_skip',
84
+ AdError = 'ad_error',
85
+ Purchase = 'purchase',
86
+ Share = 'share',
87
+ Login = 'login',
88
+ GameLaunch = 'game_launch',
89
+ GameError = 'game_error',
90
+ }
91
+
92
+ /** 事件参数键名 */
93
+ export enum AnalyticsParamKey {
94
+ Level = 'level',
95
+ Score = 'score',
96
+ Duration = 'duration',
97
+ Reason = 'reason',
98
+ AdType = 'ad_type',
99
+ AdId = 'ad_id',
100
+ ItemId = 'item_id',
101
+ ItemName = 'item_name',
102
+ Price = 'price',
103
+ Currency = 'currency',
104
+ ShareType = 'share_type',
105
+ ErrorCode = 'error_code',
106
+ ErrorMsg = 'error_msg',
107
+ }
@@ -110,7 +110,16 @@ export namespace FwkErrorCode {
110
110
  export const ComponentNotFound = 13001; // 13001 - 节点缺少必要组件
111
111
  }
112
112
 
113
- // 14-50预留给Mgr使用
113
+ // 统计分析模块错误码(14xxx)
114
+ export namespace Analytics {
115
+ export const NotInit = 14001; // 14001 - 统计模块未初始化
116
+ export const ConfigError = 14002; // 14002 - 统计配置错误
117
+ export const SDKInitFailed = 14003; // 14003 - SDK初始化失败
118
+ export const SDKCallFailed = 14004; // 14004 - SDK接口调用失败
119
+ export const PlatformNotSupported = 14005; // 14005 - 平台不支持统计
120
+ }
121
+
122
+ // 15-50预留给Mgr使用
114
123
 
115
124
  // DesktopBrowser平台错误码
116
125
  export namespace DesktopBrowser_Pt {
@@ -329,7 +338,14 @@ export const ErrorDescription: Record<number, string> = {
329
338
  // 输入模块(13xxx)
330
339
  [FwkErrorCode.Input.ComponentNotFound]: "节点缺少必要组件",
331
340
 
332
- // 14-50预留给Mgr使用
341
+ // 统计分析模块(14xxx)
342
+ [FwkErrorCode.Analytics.NotInit]: "统计模块未初始化",
343
+ [FwkErrorCode.Analytics.ConfigError]: "统计配置错误",
344
+ [FwkErrorCode.Analytics.SDKInitFailed]: "SDK初始化失败",
345
+ [FwkErrorCode.Analytics.SDKCallFailed]: "SDK接口调用失败",
346
+ [FwkErrorCode.Analytics.PlatformNotSupported]: "平台不支持统计",
347
+
348
+ // 15-50预留给Mgr使用
333
349
 
334
350
  // DesktopBrowser平台
335
351
  // 51xxx: DesktopBrowser_Pt
@@ -25,17 +25,28 @@ export type AppItem = {
25
25
  appIDMap: Map<PlatformID, string>;
26
26
  }
27
27
 
28
+ export interface ISafeArea {
29
+ left: number; // 安全区左边界 X
30
+ right: number; // 安全区右边界 X
31
+ top: number; // 安全区上边界 Y(刘海高度)
32
+ bottom: number; // 安全区下边界 Y
33
+ width: number; // 安全区宽度,单位逻辑像素
34
+ height: number; // 安全区高度,单位逻辑像素
35
+ }
36
+
28
37
  export class ScreenInfo {
29
38
  windowWidth: number;
30
39
  windowHeight: number;
31
40
  screenWidth: number;
32
41
  screenHeight: number;
42
+ safeArea: ISafeArea;
33
43
 
34
- constructor(windowWidth: number, windowHeight: number, screenWidth: number, screenHeight: number) {
44
+ constructor(windowWidth: number, windowHeight: number, screenWidth: number, screenHeight: number, safeArea: ISafeArea) {
35
45
  this.windowWidth = windowWidth;
36
46
  this.windowHeight = windowHeight;
37
47
  this.screenWidth = screenWidth;
38
48
  this.screenHeight = screenHeight;
49
+ this.safeArea = safeArea;
39
50
  }
40
51
  }
41
52