drgame-cc 1.0.41 → 1.0.43
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/drres/prefab/ExitWin.prefab +764 -764
- package/drres/prefab/HelperWin.prefab +128 -4
- package/drres/prefab/HelperWin.prefab.meta +9 -0
- package/drscript/PlatformAdapter.ts +1 -5
- package/drscript/ad-sdk/README.md +344 -344
- package/drscript/ad-sdk/ad-sdk.d.ts +59 -59
- package/drscript/ad-sdk/ad-sdk.js +322 -322
- package/drscript/ad-sdk/adapters/xiaomi-adapter.d.ts +29 -29
- package/drscript/ad-sdk/adapters/xiaomi-adapter.js +449 -449
- package/drscript/ad-sdk/event-emitter.d.ts +12 -12
- package/drscript/ad-sdk/event-emitter.js +65 -65
- package/drscript/ad-sdk/leaderboard/leaderboard.d.ts +23 -23
- package/drscript/ad-sdk/leaderboard/leaderboard.js +193 -193
- package/drscript/ad-sdk/package.json +46 -46
- package/drscript/ad-sdk/reporters/reporter.d.ts +40 -40
- package/drscript/ad-sdk/reporters/reporter.js +217 -217
- package/drscript/ad-sdk/types/enums.d.ts +64 -64
- package/drscript/ad-sdk/types/enums.js +111 -111
- package/drscript/ad-sdk/types/index.d.ts +6 -6
- package/drscript/ad-sdk/types/index.js +15 -15
- package/drscript/ad-sdk/types/interfaces.d.ts +333 -333
- package/drscript/interface/ILobbyBridge.ts +5 -5
- package/package.json +1 -1
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ad-sdk",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "聚合广告 SDK - 电视端 JSBridge 适配,JS 源码 + TS 类型声明",
|
|
5
|
-
"main": "ad-sdk.js",
|
|
6
|
-
"types": "ad-sdk.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"require": "./ad-sdk.js",
|
|
10
|
-
"types": "./ad-sdk.d.ts"
|
|
11
|
-
},
|
|
12
|
-
"./types": {
|
|
13
|
-
"require": "./types/index.js",
|
|
14
|
-
"types": "./types/index.d.ts"
|
|
15
|
-
},
|
|
16
|
-
"./adapters/xiaomi-adapter": {
|
|
17
|
-
"require": "./adapters/xiaomi-adapter.js",
|
|
18
|
-
"types": "./adapters/xiaomi-adapter.d.ts"
|
|
19
|
-
},
|
|
20
|
-
"./event-emitter": {
|
|
21
|
-
"require": "./event-emitter.js",
|
|
22
|
-
"types": "./event-emitter.d.ts"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"files": [
|
|
26
|
-
"ad-sdk.js",
|
|
27
|
-
"ad-sdk.d.ts",
|
|
28
|
-
"event-emitter.js",
|
|
29
|
-
"event-emitter.d.ts",
|
|
30
|
-
"types/",
|
|
31
|
-
"adapters/"
|
|
32
|
-
],
|
|
33
|
-
"keywords": [
|
|
34
|
-
"ad",
|
|
35
|
-
"sdk",
|
|
36
|
-
"jsbridge",
|
|
37
|
-
"tv",
|
|
38
|
-
"xiaomi",
|
|
39
|
-
"cocos"
|
|
40
|
-
],
|
|
41
|
-
"license": "MIT",
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"javascript-obfuscator": "^5.4.3",
|
|
44
|
-
"terser": "^5.48.0"
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ad-sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "聚合广告 SDK - 电视端 JSBridge 适配,JS 源码 + TS 类型声明",
|
|
5
|
+
"main": "ad-sdk.js",
|
|
6
|
+
"types": "ad-sdk.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./ad-sdk.js",
|
|
10
|
+
"types": "./ad-sdk.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./types": {
|
|
13
|
+
"require": "./types/index.js",
|
|
14
|
+
"types": "./types/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./adapters/xiaomi-adapter": {
|
|
17
|
+
"require": "./adapters/xiaomi-adapter.js",
|
|
18
|
+
"types": "./adapters/xiaomi-adapter.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./event-emitter": {
|
|
21
|
+
"require": "./event-emitter.js",
|
|
22
|
+
"types": "./event-emitter.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"ad-sdk.js",
|
|
27
|
+
"ad-sdk.d.ts",
|
|
28
|
+
"event-emitter.js",
|
|
29
|
+
"event-emitter.d.ts",
|
|
30
|
+
"types/",
|
|
31
|
+
"adapters/"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"ad",
|
|
35
|
+
"sdk",
|
|
36
|
+
"jsbridge",
|
|
37
|
+
"tv",
|
|
38
|
+
"xiaomi",
|
|
39
|
+
"cocos"
|
|
40
|
+
],
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"javascript-obfuscator": "^5.4.3",
|
|
44
|
+
"terser": "^5.48.0"
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 数据上报模块 - 类型声明(下划线字段格式)
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { IReporterConfig, IReportItem } from '../types/interfaces';
|
|
6
|
-
|
|
7
|
-
/** 上报动作类型 */
|
|
8
|
-
export declare const ActionType: {
|
|
9
|
-
/** 曝光 */
|
|
10
|
-
Exposure: '曝光';
|
|
11
|
-
/** 点击 */
|
|
12
|
-
Click: '点击';
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/** 数据上报模块(单例) */
|
|
16
|
-
export declare const Reporter: {
|
|
17
|
-
/** 初始化上报模块 */
|
|
18
|
-
init(config: IReporterConfig): void;
|
|
19
|
-
|
|
20
|
-
/** 单次上报 */
|
|
21
|
-
report(data: IReportItem): void;
|
|
22
|
-
|
|
23
|
-
/** 批量上报 */
|
|
24
|
-
reportBatch(dataList: IReportItem[], commonInfo?: IReportItem): void;
|
|
25
|
-
|
|
26
|
-
/** 获取或创建设备唯一ID */
|
|
27
|
-
createDeviceId(): string;
|
|
28
|
-
|
|
29
|
-
/** 重置设备ID */
|
|
30
|
-
resetDeviceId(): void;
|
|
31
|
-
|
|
32
|
-
/** 更新公共字段 */
|
|
33
|
-
setCommonInfo(info: Partial<IReportItem>): void;
|
|
34
|
-
|
|
35
|
-
/** 获取当前公共字段 */
|
|
36
|
-
getCommonInfo(): Partial<IReportItem>;
|
|
37
|
-
|
|
38
|
-
/** 获取底层上报实例(高级用法) */
|
|
39
|
-
readonly instance: any;
|
|
40
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* 数据上报模块 - 类型声明(下划线字段格式)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { IReporterConfig, IReportItem } from '../types/interfaces';
|
|
6
|
+
|
|
7
|
+
/** 上报动作类型 */
|
|
8
|
+
export declare const ActionType: {
|
|
9
|
+
/** 曝光 */
|
|
10
|
+
Exposure: '曝光';
|
|
11
|
+
/** 点击 */
|
|
12
|
+
Click: '点击';
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** 数据上报模块(单例) */
|
|
16
|
+
export declare const Reporter: {
|
|
17
|
+
/** 初始化上报模块 */
|
|
18
|
+
init(config: IReporterConfig): void;
|
|
19
|
+
|
|
20
|
+
/** 单次上报 */
|
|
21
|
+
report(data: IReportItem): void;
|
|
22
|
+
|
|
23
|
+
/** 批量上报 */
|
|
24
|
+
reportBatch(dataList: IReportItem[], commonInfo?: IReportItem): void;
|
|
25
|
+
|
|
26
|
+
/** 获取或创建设备唯一ID */
|
|
27
|
+
createDeviceId(): string;
|
|
28
|
+
|
|
29
|
+
/** 重置设备ID */
|
|
30
|
+
resetDeviceId(): void;
|
|
31
|
+
|
|
32
|
+
/** 更新公共字段 */
|
|
33
|
+
setCommonInfo(info: Partial<IReportItem>): void;
|
|
34
|
+
|
|
35
|
+
/** 获取当前公共字段 */
|
|
36
|
+
getCommonInfo(): Partial<IReportItem>;
|
|
37
|
+
|
|
38
|
+
/** 获取底层上报实例(高级用法) */
|
|
39
|
+
readonly instance: any;
|
|
40
|
+
};
|
|
@@ -1,217 +1,217 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 数据上报模块 - 统一封装层
|
|
3
|
-
*
|
|
4
|
-
* 内部使用 supersetLewo 上报脚本,对外提供简洁的调用接口:
|
|
5
|
-
* Reporter.init(config) — 初始化(设置项目编码、游戏ID等公共字段)
|
|
6
|
-
* Reporter.report(data) — 单次上报
|
|
7
|
-
* Reporter.reportBatch(list) — 批量上报
|
|
8
|
-
* Reporter.createDeviceId() — 获取/生成设备ID
|
|
9
|
-
* Reporter.resetDeviceId() — 重置设备ID
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
var supersetLewo = require('./superset-lewo');
|
|
13
|
-
|
|
14
|
-
// ────────────────────────────────────────
|
|
15
|
-
// 上报动作类型
|
|
16
|
-
// ────────────────────────────────────────
|
|
17
|
-
|
|
18
|
-
var ActionType = {
|
|
19
|
-
/** 曝光 */
|
|
20
|
-
Exposure: '曝光',
|
|
21
|
-
/** 点击 */
|
|
22
|
-
Click: '点击',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
// ────────────────────────────────────────
|
|
26
|
-
// Reporter 实现
|
|
27
|
-
// ────────────────────────────────────────
|
|
28
|
-
|
|
29
|
-
var Reporter = {
|
|
30
|
-
/** 是否已初始化 */
|
|
31
|
-
_initialized: false,
|
|
32
|
-
|
|
33
|
-
/** 公共字段缓存(初始化时设置,每次上报自动合并) */
|
|
34
|
-
_commonInfo: {},
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 初始化上报模块
|
|
38
|
-
* @param {import('../types/interfaces').IReporterConfig} config
|
|
39
|
-
*/
|
|
40
|
-
init: function (config) {
|
|
41
|
-
config = config || {};
|
|
42
|
-
|
|
43
|
-
// 设置上报地址(未传则使用 supersetLewo 默认值)
|
|
44
|
-
if (config.report_url) {
|
|
45
|
-
supersetLewo.config.reportUrl = config.report_url;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// 设置请求头
|
|
49
|
-
if (config.headers && config.headers.length > 0) {
|
|
50
|
-
supersetLewo.config.defaultHeaders = config.headers;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// 设置默认行为类型
|
|
54
|
-
if (config.default_action_type) {
|
|
55
|
-
supersetLewo.config.defaultActionType = config.default_action_type;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// 缓存公共字段
|
|
59
|
-
this._commonInfo = {
|
|
60
|
-
app_item: config.app_item || '',
|
|
61
|
-
content_type: config.content_type || '游戏',
|
|
62
|
-
content_id: config.content_id || '',
|
|
63
|
-
content_title: config.content_title || '',
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// 自动填充 device_id
|
|
67
|
-
if (!this._commonInfo.device_id) {
|
|
68
|
-
this._commonInfo.device_id = supersetLewo.createDeviceId();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
supersetLewo.initUserInfo({
|
|
72
|
-
os_type: "", // 系统类型安卓
|
|
73
|
-
os_version: "", // 安卓版本15
|
|
74
|
-
app_version: "1.0.0", // APP版本号
|
|
75
|
-
app_item: config.app_item, // 渠道编码
|
|
76
|
-
app_name: config.content_title, // APP展示名称
|
|
77
|
-
app_project: config.content_id, // 产品内部编码
|
|
78
|
-
province: "", // 省份编码
|
|
79
|
-
city: "", // 城市编码
|
|
80
|
-
uid: "", // 登录用户UID,未登录填空""
|
|
81
|
-
user_id: "", // 会员/游客ID,无则填空""
|
|
82
|
-
device_id: this._commonInfo.device_id, // 设备唯一ID,没有或不传则自动生成
|
|
83
|
-
device_brand: "", // 手机品牌小写
|
|
84
|
-
device_model: "", // 手机完整型号
|
|
85
|
-
network_type: "", // 蜂窝流量网络
|
|
86
|
-
carrier: "" // 运营商
|
|
87
|
-
// device_id 不传,内部自动生成UUID填充,无需手动传入
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
this._initialized = true;
|
|
91
|
-
console.log('[Reporter] Initialized, reportUrl:', supersetLewo.config.reportUrl);
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* 单次上报
|
|
96
|
-
* @param {import('../types/interfaces').IReportItem} data - 上报数据(下划线格式)
|
|
97
|
-
*/
|
|
98
|
-
report: function (data) {
|
|
99
|
-
if (!this._initialized) {
|
|
100
|
-
console.warn('[Reporter] Not initialized. Call Reporter.init() first.');
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// 合并公共字段 + 传入数据
|
|
105
|
-
var merged = {};
|
|
106
|
-
var key;
|
|
107
|
-
for (key in this._commonInfo) {
|
|
108
|
-
if (this._commonInfo.hasOwnProperty(key)) {
|
|
109
|
-
merged[key] = this._commonInfo[key];
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
for (key in data) {
|
|
113
|
-
if (data.hasOwnProperty(key)) {
|
|
114
|
-
merged[key] = data[key];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 自动填充 device_id
|
|
119
|
-
if (!merged.device_id) {
|
|
120
|
-
merged.device_id = supersetLewo.createDeviceId();
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
supersetLewo.superBatchReport(merged);
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* 批量上报
|
|
128
|
-
* @param {Array<import('../types/interfaces').IReportItem>} dataList - 上报数据列表(下划线格式)
|
|
129
|
-
* @param {import('../types/interfaces').IReportItem} [commonInfo] - 可选公共字段(覆盖初始化的公共字段)
|
|
130
|
-
*/
|
|
131
|
-
reportBatch: function (dataList, commonInfo) {
|
|
132
|
-
if (!this._initialized) {
|
|
133
|
-
console.warn('[Reporter] Not initialized. Call Reporter.init() first.');
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var mergedCommon = {};
|
|
138
|
-
var key;
|
|
139
|
-
|
|
140
|
-
// 合并初始化时的公共字段
|
|
141
|
-
for (key in this._commonInfo) {
|
|
142
|
-
if (this._commonInfo.hasOwnProperty(key)) {
|
|
143
|
-
mergedCommon[key] = this._commonInfo[key];
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// 合并传入的公共字段(优先级更高)
|
|
148
|
-
if (commonInfo) {
|
|
149
|
-
for (key in commonInfo) {
|
|
150
|
-
if (commonInfo.hasOwnProperty(key)) {
|
|
151
|
-
mergedCommon[key] = commonInfo[key];
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// 自动填充 device_id
|
|
157
|
-
if (!mergedCommon.device_id) {
|
|
158
|
-
mergedCommon.device_id = supersetLewo.createDeviceId();
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
supersetLewo.batchReporting(dataList, mergedCommon);
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* 获取或创建设备唯一ID
|
|
166
|
-
* @returns {string}
|
|
167
|
-
*/
|
|
168
|
-
createDeviceId: function () {
|
|
169
|
-
return supersetLewo.createDeviceId();
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* 重置设备ID(清除缓存、localStorage、cookie)
|
|
174
|
-
*/
|
|
175
|
-
resetDeviceId: function () {
|
|
176
|
-
supersetLewo.resetDeviceId();
|
|
177
|
-
if (this._commonInfo) {
|
|
178
|
-
this._commonInfo.device_id = supersetLewo.createDeviceId();
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* 更新公共字段(如用户登录后更新 user_id)
|
|
184
|
-
* @param {Object} info - 要更新的字段(下划线格式)
|
|
185
|
-
*/
|
|
186
|
-
setCommonInfo: function (info) {
|
|
187
|
-
for (var key in info) {
|
|
188
|
-
if (info.hasOwnProperty(key)) {
|
|
189
|
-
this._commonInfo[key] = info[key];
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* 获取当前公共字段
|
|
196
|
-
* @returns {Object}
|
|
197
|
-
*/
|
|
198
|
-
getCommonInfo: function () {
|
|
199
|
-
var copy = {};
|
|
200
|
-
for (var key in this._commonInfo) {
|
|
201
|
-
if (this._commonInfo.hasOwnProperty(key)) {
|
|
202
|
-
copy[key] = this._commonInfo[key];
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return copy;
|
|
206
|
-
},
|
|
207
|
-
|
|
208
|
-
/** 获取底层 supersetLewo 实例(高级用法) */
|
|
209
|
-
get instance() {
|
|
210
|
-
return supersetLewo;
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
module.exports = {
|
|
215
|
-
Reporter: Reporter,
|
|
216
|
-
ActionType: ActionType,
|
|
217
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* 数据上报模块 - 统一封装层
|
|
3
|
+
*
|
|
4
|
+
* 内部使用 supersetLewo 上报脚本,对外提供简洁的调用接口:
|
|
5
|
+
* Reporter.init(config) — 初始化(设置项目编码、游戏ID等公共字段)
|
|
6
|
+
* Reporter.report(data) — 单次上报
|
|
7
|
+
* Reporter.reportBatch(list) — 批量上报
|
|
8
|
+
* Reporter.createDeviceId() — 获取/生成设备ID
|
|
9
|
+
* Reporter.resetDeviceId() — 重置设备ID
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
var supersetLewo = require('./superset-lewo');
|
|
13
|
+
|
|
14
|
+
// ────────────────────────────────────────
|
|
15
|
+
// 上报动作类型
|
|
16
|
+
// ────────────────────────────────────────
|
|
17
|
+
|
|
18
|
+
var ActionType = {
|
|
19
|
+
/** 曝光 */
|
|
20
|
+
Exposure: '曝光',
|
|
21
|
+
/** 点击 */
|
|
22
|
+
Click: '点击',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// ────────────────────────────────────────
|
|
26
|
+
// Reporter 实现
|
|
27
|
+
// ────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
var Reporter = {
|
|
30
|
+
/** 是否已初始化 */
|
|
31
|
+
_initialized: false,
|
|
32
|
+
|
|
33
|
+
/** 公共字段缓存(初始化时设置,每次上报自动合并) */
|
|
34
|
+
_commonInfo: {},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 初始化上报模块
|
|
38
|
+
* @param {import('../types/interfaces').IReporterConfig} config
|
|
39
|
+
*/
|
|
40
|
+
init: function (config) {
|
|
41
|
+
config = config || {};
|
|
42
|
+
|
|
43
|
+
// 设置上报地址(未传则使用 supersetLewo 默认值)
|
|
44
|
+
if (config.report_url) {
|
|
45
|
+
supersetLewo.config.reportUrl = config.report_url;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 设置请求头
|
|
49
|
+
if (config.headers && config.headers.length > 0) {
|
|
50
|
+
supersetLewo.config.defaultHeaders = config.headers;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// 设置默认行为类型
|
|
54
|
+
if (config.default_action_type) {
|
|
55
|
+
supersetLewo.config.defaultActionType = config.default_action_type;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// 缓存公共字段
|
|
59
|
+
this._commonInfo = {
|
|
60
|
+
app_item: config.app_item || '',
|
|
61
|
+
content_type: config.content_type || '游戏',
|
|
62
|
+
content_id: config.content_id || '',
|
|
63
|
+
content_title: config.content_title || '',
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// 自动填充 device_id
|
|
67
|
+
if (!this._commonInfo.device_id) {
|
|
68
|
+
this._commonInfo.device_id = supersetLewo.createDeviceId();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
supersetLewo.initUserInfo({
|
|
72
|
+
os_type: "", // 系统类型安卓
|
|
73
|
+
os_version: "", // 安卓版本15
|
|
74
|
+
app_version: "1.0.0", // APP版本号
|
|
75
|
+
app_item: config.app_item, // 渠道编码
|
|
76
|
+
app_name: config.content_title, // APP展示名称
|
|
77
|
+
app_project: config.content_id, // 产品内部编码
|
|
78
|
+
province: "", // 省份编码
|
|
79
|
+
city: "", // 城市编码
|
|
80
|
+
uid: "", // 登录用户UID,未登录填空""
|
|
81
|
+
user_id: "", // 会员/游客ID,无则填空""
|
|
82
|
+
device_id: this._commonInfo.device_id, // 设备唯一ID,没有或不传则自动生成
|
|
83
|
+
device_brand: "", // 手机品牌小写
|
|
84
|
+
device_model: "", // 手机完整型号
|
|
85
|
+
network_type: "", // 蜂窝流量网络
|
|
86
|
+
carrier: "" // 运营商
|
|
87
|
+
// device_id 不传,内部自动生成UUID填充,无需手动传入
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
this._initialized = true;
|
|
91
|
+
console.log('[Reporter] Initialized, reportUrl:', supersetLewo.config.reportUrl);
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 单次上报
|
|
96
|
+
* @param {import('../types/interfaces').IReportItem} data - 上报数据(下划线格式)
|
|
97
|
+
*/
|
|
98
|
+
report: function (data) {
|
|
99
|
+
if (!this._initialized) {
|
|
100
|
+
console.warn('[Reporter] Not initialized. Call Reporter.init() first.');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// 合并公共字段 + 传入数据
|
|
105
|
+
var merged = {};
|
|
106
|
+
var key;
|
|
107
|
+
for (key in this._commonInfo) {
|
|
108
|
+
if (this._commonInfo.hasOwnProperty(key)) {
|
|
109
|
+
merged[key] = this._commonInfo[key];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
for (key in data) {
|
|
113
|
+
if (data.hasOwnProperty(key)) {
|
|
114
|
+
merged[key] = data[key];
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 自动填充 device_id
|
|
119
|
+
if (!merged.device_id) {
|
|
120
|
+
merged.device_id = supersetLewo.createDeviceId();
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
supersetLewo.superBatchReport(merged);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* 批量上报
|
|
128
|
+
* @param {Array<import('../types/interfaces').IReportItem>} dataList - 上报数据列表(下划线格式)
|
|
129
|
+
* @param {import('../types/interfaces').IReportItem} [commonInfo] - 可选公共字段(覆盖初始化的公共字段)
|
|
130
|
+
*/
|
|
131
|
+
reportBatch: function (dataList, commonInfo) {
|
|
132
|
+
if (!this._initialized) {
|
|
133
|
+
console.warn('[Reporter] Not initialized. Call Reporter.init() first.');
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var mergedCommon = {};
|
|
138
|
+
var key;
|
|
139
|
+
|
|
140
|
+
// 合并初始化时的公共字段
|
|
141
|
+
for (key in this._commonInfo) {
|
|
142
|
+
if (this._commonInfo.hasOwnProperty(key)) {
|
|
143
|
+
mergedCommon[key] = this._commonInfo[key];
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// 合并传入的公共字段(优先级更高)
|
|
148
|
+
if (commonInfo) {
|
|
149
|
+
for (key in commonInfo) {
|
|
150
|
+
if (commonInfo.hasOwnProperty(key)) {
|
|
151
|
+
mergedCommon[key] = commonInfo[key];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 自动填充 device_id
|
|
157
|
+
if (!mergedCommon.device_id) {
|
|
158
|
+
mergedCommon.device_id = supersetLewo.createDeviceId();
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
supersetLewo.batchReporting(dataList, mergedCommon);
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 获取或创建设备唯一ID
|
|
166
|
+
* @returns {string}
|
|
167
|
+
*/
|
|
168
|
+
createDeviceId: function () {
|
|
169
|
+
return supersetLewo.createDeviceId();
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* 重置设备ID(清除缓存、localStorage、cookie)
|
|
174
|
+
*/
|
|
175
|
+
resetDeviceId: function () {
|
|
176
|
+
supersetLewo.resetDeviceId();
|
|
177
|
+
if (this._commonInfo) {
|
|
178
|
+
this._commonInfo.device_id = supersetLewo.createDeviceId();
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 更新公共字段(如用户登录后更新 user_id)
|
|
184
|
+
* @param {Object} info - 要更新的字段(下划线格式)
|
|
185
|
+
*/
|
|
186
|
+
setCommonInfo: function (info) {
|
|
187
|
+
for (var key in info) {
|
|
188
|
+
if (info.hasOwnProperty(key)) {
|
|
189
|
+
this._commonInfo[key] = info[key];
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 获取当前公共字段
|
|
196
|
+
* @returns {Object}
|
|
197
|
+
*/
|
|
198
|
+
getCommonInfo: function () {
|
|
199
|
+
var copy = {};
|
|
200
|
+
for (var key in this._commonInfo) {
|
|
201
|
+
if (this._commonInfo.hasOwnProperty(key)) {
|
|
202
|
+
copy[key] = this._commonInfo[key];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return copy;
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
/** 获取底层 supersetLewo 实例(高级用法) */
|
|
209
|
+
get instance() {
|
|
210
|
+
return supersetLewo;
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
module.exports = {
|
|
215
|
+
Reporter: Reporter,
|
|
216
|
+
ActionType: ActionType,
|
|
217
|
+
};
|