drgame-cc 1.0.54 → 1.0.56
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/drscript/Define.ts
CHANGED
|
@@ -56,16 +56,102 @@ export enum AwardModel {
|
|
|
56
56
|
Video = "video",
|
|
57
57
|
/** 免费 */
|
|
58
58
|
Free = "free",
|
|
59
|
-
/**
|
|
59
|
+
/** 时间限制 */
|
|
60
60
|
TimeLimit = "time_limit",
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/** 渠道类型 */
|
|
64
64
|
export enum EAppItem {
|
|
65
|
-
/**
|
|
66
|
-
|
|
67
|
-
/**
|
|
65
|
+
/** 测试环境 */
|
|
66
|
+
Test = "00",
|
|
67
|
+
/** 道然(原乐窝) */
|
|
68
68
|
LeWo = "29",
|
|
69
69
|
/** 咪咕 */
|
|
70
|
-
Migu = "
|
|
70
|
+
Migu = "my",
|
|
71
|
+
/** 海信 */
|
|
72
|
+
Hisense = "h",
|
|
73
|
+
/** 乐视 */
|
|
74
|
+
LeTV = "le",
|
|
75
|
+
/** 陕西移动 */
|
|
76
|
+
ShanxiMobile = "sy",
|
|
77
|
+
/** 洛神 */
|
|
78
|
+
LuoShen = "lu",
|
|
79
|
+
/** 百视通 */
|
|
80
|
+
BesTV = "33",
|
|
81
|
+
/** 联通中屏 */
|
|
82
|
+
UnicomMedium = "10",
|
|
83
|
+
/** 联通 */
|
|
84
|
+
Unicom = "bt",
|
|
85
|
+
/** 小米TV */
|
|
86
|
+
XiaomiTV = "25",
|
|
87
|
+
/** 雷鸟 */
|
|
88
|
+
Leinao = "47",
|
|
89
|
+
/** 长虹 */
|
|
90
|
+
Changhong = "90",
|
|
91
|
+
/** 极米 */
|
|
92
|
+
Jimi = "37",
|
|
93
|
+
/** 百视通酒店(小帅) */
|
|
94
|
+
BesTVHotelXiaoshuai = "bi",
|
|
95
|
+
/** 华为移动端 */
|
|
96
|
+
HuaweiMobile = "h5",
|
|
97
|
+
/** OPPO移动端 */
|
|
98
|
+
OPPOMobile = "03",
|
|
99
|
+
/** VIVO移动端 */
|
|
100
|
+
VIVOMobile = "v5",
|
|
101
|
+
/** 小米移动端 */
|
|
102
|
+
XiaomiMobile = "x5",
|
|
103
|
+
/** KTC闺蜜机 */
|
|
104
|
+
KTCFriendsMachine = "mc",
|
|
105
|
+
/** 沙发 */
|
|
106
|
+
Sofa = "27",
|
|
107
|
+
/** 长城车载 */
|
|
108
|
+
GreatWallCar = "cc",
|
|
109
|
+
/** 海尔闺蜜机 */
|
|
110
|
+
HaierFriendsMachine = "hg",
|
|
111
|
+
/** 百视通酒店(携旅) */
|
|
112
|
+
BesTVHotelXielv = "bl",
|
|
113
|
+
/** 野草助手 */
|
|
114
|
+
WildGrass = "yc",
|
|
115
|
+
/** 当贝 */
|
|
116
|
+
Dangbei = "07",
|
|
117
|
+
/** 抖音 */
|
|
118
|
+
Douyin = "t",
|
|
119
|
+
/** 应用宝 */
|
|
120
|
+
YingyongBao = "y9",
|
|
121
|
+
/** 欢网 */
|
|
122
|
+
Huanwang = "hw",
|
|
123
|
+
/** 蜂鸟 */
|
|
124
|
+
Fengniao = "fn",
|
|
125
|
+
/** 酷开TV */
|
|
126
|
+
CoocaaTV = "31",
|
|
127
|
+
/** mumu模拟器 */
|
|
128
|
+
MuMu = "mm",
|
|
129
|
+
/** 坚果 */
|
|
130
|
+
Jianguo = "jg",
|
|
131
|
+
/** 欢喜 */
|
|
132
|
+
Huanxi = "hx",
|
|
133
|
+
/** KTC电视 */
|
|
134
|
+
KTCTV = "kc",
|
|
135
|
+
/** 阿里TV */
|
|
136
|
+
AliTV = "26",
|
|
137
|
+
/** 乐家 */
|
|
138
|
+
Lejia = "al",
|
|
139
|
+
/** 视推 */
|
|
140
|
+
Shitui = "st",
|
|
141
|
+
/** 讯码 */
|
|
142
|
+
Xunma = "",
|
|
143
|
+
/** 华数音箱 */
|
|
144
|
+
HuashuSoundBox = "hu",
|
|
145
|
+
/** kook */
|
|
146
|
+
Kook = "bk",
|
|
147
|
+
/** 欢网长虹 */
|
|
148
|
+
HuanwangChanghong = "hh",
|
|
149
|
+
/** 欢网TCL */
|
|
150
|
+
HuanwangTCL = "ht",
|
|
151
|
+
/** 赛的美 */
|
|
152
|
+
Saidemei = "sd",
|
|
153
|
+
/** 华为TV */
|
|
154
|
+
HuaweiTV = "70",
|
|
155
|
+
/** 雷鸟多屏互动 */
|
|
156
|
+
LeinaoMultiScreen = "dp",
|
|
71
157
|
}
|
|
@@ -15,11 +15,12 @@ export class PlatformAdapter {
|
|
|
15
15
|
/** WebBridge */
|
|
16
16
|
public static get webBridge() { return UIAdapter.webBridge; }
|
|
17
17
|
/** 渠道类型 */
|
|
18
|
-
private static appItem: EAppItem = EAppItem.
|
|
18
|
+
private static appItem: EAppItem = EAppItem.Test;
|
|
19
19
|
/** 是否是会员 */
|
|
20
20
|
private static isVIP: boolean = false;
|
|
21
21
|
|
|
22
22
|
private static contentId: string = "";
|
|
23
|
+
private static cpId: string = "";
|
|
23
24
|
|
|
24
25
|
// ========================================================================
|
|
25
26
|
// 初始化
|
|
@@ -32,8 +33,9 @@ export class PlatformAdapter {
|
|
|
32
33
|
*/
|
|
33
34
|
public static async init(cnName: string, minigameID: number, focusIcon: FingerStyle) {
|
|
34
35
|
// ── 初始化渠道类型 ──
|
|
35
|
-
this.appItem = PlatformUtil.getUrlParam('appItem') as EAppItem || EAppItem.
|
|
36
|
+
this.appItem = PlatformUtil.getUrlParam('appItem') as EAppItem || EAppItem.LeWo;
|
|
36
37
|
this.isVIP = PlatformUtil.getUrlParam('isVIP') === '1';
|
|
38
|
+
this.cpId = 'cp_001';
|
|
37
39
|
|
|
38
40
|
// ── UI 初始化 ──
|
|
39
41
|
this.focus.setFocusStyle(focusIcon);
|
|
@@ -43,12 +45,21 @@ export class PlatformAdapter {
|
|
|
43
45
|
this.contentId = minigameID.toString();
|
|
44
46
|
|
|
45
47
|
// ── 初始化广告 SDK ──
|
|
48
|
+
await this.initAdSdk(cnName);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ========================================================================
|
|
52
|
+
// 广告 SDK 初始化
|
|
53
|
+
// ========================================================================
|
|
54
|
+
|
|
55
|
+
/** 初始化广告 SDK(含事件注册) */
|
|
56
|
+
private static async initAdSdk(cnName: string) {
|
|
46
57
|
await AdSdk.init({
|
|
47
58
|
platform: AdPlatform.Xiaomi,
|
|
48
|
-
|
|
59
|
+
cpId: this.cpId,
|
|
49
60
|
reporter: {
|
|
50
|
-
app_item:
|
|
51
|
-
content_type: "游戏",
|
|
61
|
+
app_item: this.appItem,
|
|
62
|
+
content_type: this.appItem === EAppItem.LeWo ? "乐窝" : "游戏",
|
|
52
63
|
content_id: this.contentId,
|
|
53
64
|
content_title: cnName,
|
|
54
65
|
},
|
|
@@ -126,7 +137,7 @@ export class PlatformAdapter {
|
|
|
126
137
|
try {
|
|
127
138
|
const result = await AdSdk.requestAd({
|
|
128
139
|
adType: AdType.RewardVideo,
|
|
129
|
-
cpId: this.
|
|
140
|
+
cpId: this.cpId,
|
|
130
141
|
rewardType: rewardType || "reward",
|
|
131
142
|
triggerScene: scene || "reward",
|
|
132
143
|
extra: {}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { AdPlatform, AdEvent } from './types/enums';
|
|
6
6
|
import {
|
|
7
7
|
IAdSdk,
|
|
8
|
-
|
|
8
|
+
IAdSdkInitConfig,
|
|
9
9
|
IAdRequest,
|
|
10
10
|
IAdRewardResult,
|
|
11
11
|
IDeviceInfo,
|
|
@@ -23,7 +23,7 @@ export { AdPlatform, AdType, AdEvent, AdErrorCode, DevicePlatform, KeyCode, KeyA
|
|
|
23
23
|
// 接口(type-only)
|
|
24
24
|
export type {
|
|
25
25
|
IAdSdk,
|
|
26
|
-
|
|
26
|
+
IAdSdkInitConfig,
|
|
27
27
|
IAdAdapter,
|
|
28
28
|
IAdapterConfig,
|
|
29
29
|
IAdRequest,
|
|
@@ -56,4 +56,4 @@ export type {
|
|
|
56
56
|
IAddPointParams,
|
|
57
57
|
IRankItem,
|
|
58
58
|
IRankResult,
|
|
59
|
-
} from './types/interfaces';
|
|
59
|
+
} from './types/interfaces';
|
|
@@ -48,7 +48,7 @@ class AdSdkImpl {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* 初始化 SDK
|
|
51
|
-
* @param {import('./types/interfaces').
|
|
51
|
+
* @param {import('./types/interfaces').IAdSdkInitConfig} config
|
|
52
52
|
*/
|
|
53
53
|
async init(config) {
|
|
54
54
|
if (this._initialized) {
|
|
@@ -59,7 +59,7 @@ class AdSdkImpl {
|
|
|
59
59
|
this._currentPlatform = config.platform;
|
|
60
60
|
this._globalEventHandler = config.onEvent || null;
|
|
61
61
|
|
|
62
|
-
//
|
|
62
|
+
// 注册自定义适配器(如提供了 customAdapters 兼容旧用法)
|
|
63
63
|
if (config.customAdapters) {
|
|
64
64
|
for (const adapter of config.customAdapters) {
|
|
65
65
|
this._adapters.set(adapter.platform, adapter);
|
|
@@ -80,9 +80,9 @@ class AdSdkImpl {
|
|
|
80
80
|
this._adapters.set(config.platform, instance);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
//
|
|
83
|
+
// 初始化当前平台的适配器(从 config.cpId 构建适配器配置)
|
|
84
84
|
const adapter = this._adapters.get(config.platform);
|
|
85
|
-
const adapterConfig =
|
|
85
|
+
const adapterConfig = { cpId: config.cpId };
|
|
86
86
|
await adapter.init(adapterConfig);
|
|
87
87
|
|
|
88
88
|
// 桥接适配器事件到全局
|
|
@@ -312,16 +312,12 @@ export interface IAdAdapter {
|
|
|
312
312
|
// SDK 配置 & 主接口
|
|
313
313
|
// ────────────────────────────────────────
|
|
314
314
|
|
|
315
|
-
/** SDK
|
|
316
|
-
export interface
|
|
317
|
-
/**
|
|
315
|
+
/** SDK 初始化配置(简化版,直接传入 cpId 即可) */
|
|
316
|
+
export interface IAdSdkInitConfig {
|
|
317
|
+
/** 广告平台 */
|
|
318
318
|
platform: AdPlatform;
|
|
319
|
-
/**
|
|
320
|
-
|
|
321
|
-
/** 自定义适配器实例(优先级高于内置适配器) */
|
|
322
|
-
customAdapters?: IAdAdapter[];
|
|
323
|
-
/** 全局事件监听 */
|
|
324
|
-
onEvent?: (event: AdEvent, data: IAdEventData) => void;
|
|
319
|
+
/** CP 标识 */
|
|
320
|
+
cpId: string;
|
|
325
321
|
/** 数据上报配置(不传则不上报) */
|
|
326
322
|
reporter?: IReporterConfig;
|
|
327
323
|
}
|
|
@@ -332,7 +328,7 @@ export interface IAdSdk {
|
|
|
332
328
|
readonly currentPlatform: AdPlatform;
|
|
333
329
|
|
|
334
330
|
/** 初始化 SDK */
|
|
335
|
-
init(config:
|
|
331
|
+
init(config: IAdSdkInitConfig): Promise<void>;
|
|
336
332
|
|
|
337
333
|
/** 获取设备信息 */
|
|
338
334
|
getDeviceInfo(): Promise<IDeviceInfo>;
|
|
@@ -21,15 +21,11 @@ export default class ExitWin extends cc.Component {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
private async onClickExit() {
|
|
24
|
-
console.log("onClickExit", PlatformAdapter.isXiaomi, PlatformAdapter.isWebBridge);
|
|
25
24
|
if (PlatformAdapter.isXiaomi) {
|
|
26
|
-
console.log("onClickExit Xiaomi");
|
|
27
25
|
await AdSdk.exitGame();
|
|
28
26
|
} else if (PlatformAdapter.isWebBridge) {
|
|
29
|
-
console.log("onClickExit WebBridge");
|
|
30
27
|
PlatformAdapter.webBridge.callHandler("router/navigateBack", {}, (a) => { cc.log(a); });
|
|
31
28
|
} else {
|
|
32
|
-
console.log("onClickExit Other");
|
|
33
29
|
cc.game.end();
|
|
34
30
|
}
|
|
35
31
|
}
|