drgame-cc 1.0.36 → 1.0.38
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/build-templates/web-mobile/jz-jdt-3.png +0 -0
- package/build-templates/web-mobile/jz-jdt-4.png +0 -0
- package/build-templates/web-mobile/logo.png +0 -0
- package/drscript/PlatformAdapter.ts +14 -0
- package/drscript/WebBridge.ts +35 -0
- package/drscript/input/KeyCodeAdapter.ts +6 -6
- package/drscript/interface/ILobbyBridge.ts +5 -0
- package/package.json +1 -1
- package/build-templates/web-mobile/16+.png +0 -0
- package/build-templates/web-mobile/splash.png +0 -0
- package/build-templates/web-mobile/splash_en.png +0 -0
- package/build-templates/web-mobile/src/hls.min.js +0 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,16 +7,19 @@ import { showRewardVideo } from "./Info";
|
|
|
7
7
|
import { Loader } from "./Loader";
|
|
8
8
|
import ToastManager from "./toast/ToastManager";
|
|
9
9
|
import { InternalUitl } from "./InternalUitl";
|
|
10
|
+
import { WebBridge } from "./WebBridge";
|
|
10
11
|
/** 平台适配器,名字有点长防止和Platform,Adapter冲突 */
|
|
11
12
|
export class PlatformAdapter {
|
|
12
13
|
private static readonly version = "1.0.36";
|
|
13
14
|
private static readonly designWidth = 1920;
|
|
14
15
|
private static readonly designHeight = 1080;
|
|
16
|
+
private static webBridge: WebBridge;
|
|
15
17
|
/** 初始化
|
|
16
18
|
* @param cnName 中文名称
|
|
17
19
|
* @param minigameID 小游戏ID,文档地址:https://doc.weixin.qq.com/sheet/e3_AcEAlgaLALsCNiuHzH2NOQGCjVc3a?scode=AOcA0AdfAAoSqmh5BfAQIA6AYEAB4&tab=BB08J2
|
|
18
20
|
*/
|
|
19
21
|
public static async init(cnName: string, minigameID: number) {
|
|
22
|
+
this.webBridge = new WebBridge();
|
|
20
23
|
var platform = GameAnalyticsPlatform.XiaomiTv;//平台由sdk后续处理
|
|
21
24
|
var appItem = GameAnalytics.getAppItem(platform);
|
|
22
25
|
var contentId = minigameID.toString();//InternalUitl.getChineseInitials(cnName);
|
|
@@ -223,4 +226,15 @@ export class PlatformAdapter {
|
|
|
223
226
|
public static get isCocos() {
|
|
224
227
|
return window['cc'] != undefined;
|
|
225
228
|
}
|
|
229
|
+
|
|
230
|
+
/** 退出游戏 */
|
|
231
|
+
public static exitGame() {
|
|
232
|
+
if (this.webBridge.isAvailable()) {
|
|
233
|
+
this.webBridge.callHandler("router/navigateBack", {}, (a) => { cc.log(a); });
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
var GRoot = window['GRoot'];
|
|
237
|
+
let bridge: ILobbyBridge = GRoot && GRoot.inst.node.getComponentInChildren('LobbyBridge');
|
|
238
|
+
bridge && bridge.exitGame();
|
|
239
|
+
}
|
|
226
240
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web 桥接
|
|
3
|
+
* 封装 window.callHandler 的调用逻辑
|
|
4
|
+
* 构造时一次性检测可用性,避免每次调用重复判断
|
|
5
|
+
*/
|
|
6
|
+
export class WebBridge {
|
|
7
|
+
|
|
8
|
+
/** 缓存:callHandler 是否可用 */
|
|
9
|
+
private _available: boolean;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
this._available = cc.sys.isBrowser && typeof (window as any).callHandler === 'function';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** 检测浏览器环境中是否存在 callHandler */
|
|
16
|
+
isAvailable(): boolean {
|
|
17
|
+
return this._available;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
callHandler(message: string, param: any, success?: Function, fail?: Function): void {
|
|
21
|
+
if (this._available) {
|
|
22
|
+
(window as any).callHandler(message, param, success);
|
|
23
|
+
} else {
|
|
24
|
+
fail && fail({ code: -1, message: 'callHandler 未找到,非基座环境' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async getSystemInfo(): Promise<any> {
|
|
29
|
+
return new Promise<any>((resolve, reject) => {
|
|
30
|
+
this.callHandler("system/getSystemInfo", {}, resolve,
|
|
31
|
+
(err: any) => reject(err || new Error('非基座环境:callHandler 不存在'))
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -11,13 +11,13 @@ export enum TvRemoteKey {
|
|
|
11
11
|
|
|
12
12
|
export default class KeyCodeAdapter {
|
|
13
13
|
public static toRemoteKey(keyCode: number): TvRemoteKey {
|
|
14
|
-
if ([0, 4, 8, 27, 10009].indexOf(keyCode) >= 0) return TvRemoteKey.Back;
|
|
15
|
-
if ([13, 23, 66].indexOf(keyCode) >= 0) return TvRemoteKey.Ok;
|
|
14
|
+
if ([0, 4, 6, 8, 27, 10009].indexOf(keyCode) >= 0) return TvRemoteKey.Back;
|
|
15
|
+
if ([13, 23, 66, 1005].indexOf(keyCode) >= 0) return TvRemoteKey.Ok;
|
|
16
16
|
if ([80].indexOf(keyCode) >= 0) return TvRemoteKey.Pause;
|
|
17
|
-
if ([21, 37].indexOf(keyCode) >= 0) return TvRemoteKey.Left;
|
|
18
|
-
if ([19, 38].indexOf(keyCode) >= 0) return TvRemoteKey.Up;
|
|
19
|
-
if ([22, 39].indexOf(keyCode) >= 0) return TvRemoteKey.Right;
|
|
20
|
-
if ([20, 40].indexOf(keyCode) >= 0) return TvRemoteKey.Down;
|
|
17
|
+
if ([21, 37, 1000].indexOf(keyCode) >= 0) return TvRemoteKey.Left;
|
|
18
|
+
if ([19, 38, 1003].indexOf(keyCode) >= 0) return TvRemoteKey.Up;
|
|
19
|
+
if ([22, 39, 1001].indexOf(keyCode) >= 0) return TvRemoteKey.Right;
|
|
20
|
+
if ([20, 40, 1004].indexOf(keyCode) >= 0) return TvRemoteKey.Down;
|
|
21
21
|
return TvRemoteKey.Unknown;
|
|
22
22
|
}
|
|
23
23
|
}
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|