@chiyou/minigame-framework 1.0.0
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 +66 -0
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.d.ts +78 -0
- package/dist/Framework/Adapter/AdAdapter/AbsAdAdapter.js +230 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.d.ts +31 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterBilibili.js +224 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.d.ts +34 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterDouYin.js +524 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.d.ts +34 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHonor.js +631 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterHuaWei.js +460 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.d.ts +31 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterJingDong.js +227 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterKuaiShou.js +458 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.d.ts +35 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterOppo.js +770 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterTapTap.js +519 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterVivo.js +492 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterWeiXin.js +695 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.d.ts +34 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterXiaoMi.js +597 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.d.ts +33 -0
- package/dist/Framework/Adapter/AdAdapter/AdAdapterZhiFuBao.js +458 -0
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.d.ts +51 -0
- package/dist/Framework/Adapter/PlatformAdapter/AbsPlatformAdapter.js +17 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.d.ts +45 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterBilibili.js +555 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser.js +148 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.d.ts +48 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterDouYin.js +715 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHonor.js +296 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.d.ts +45 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterHuaWei.js +284 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterJingDong.js +283 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.d.ts +43 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterKuaiShou.js +406 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.d.ts +43 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterOppo.js +248 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterTapTap.js +517 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterVivo.js +295 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.d.ts +55 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterWeiXin.js +964 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterXiaoMi.js +295 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.d.ts +44 -0
- package/dist/Framework/Adapter/PlatformAdapter/PlatformAdapterZhiFuBao.js +393 -0
- package/dist/Framework/Definition/AdDefinition.d.ts +130 -0
- package/dist/Framework/Definition/AdDefinition.js +208 -0
- package/dist/Framework/Definition/FrameworkBase.d.ts +13 -0
- package/dist/Framework/Definition/FrameworkBase.js +23 -0
- package/dist/Framework/Definition/PrivacyDefinition.d.ts +51 -0
- package/dist/Framework/Definition/PrivacyDefinition.js +70 -0
- package/dist/Framework/Definition/SocialDefinition.d.ts +16 -0
- package/dist/Framework/Definition/SocialDefinition.js +2 -0
- package/dist/Framework/Definition/SystemDefinition.d.ts +43 -0
- package/dist/Framework/Definition/SystemDefinition.js +28 -0
- package/dist/Framework/Definition/UIDefinition.d.ts +6 -0
- package/dist/Framework/Definition/UIDefinition.js +7 -0
- package/dist/Framework/Definition/UserDefinition.d.ts +14 -0
- package/dist/Framework/Definition/UserDefinition.js +10 -0
- package/dist/Framework/Manager/AdMgr.d.ts +57 -0
- package/dist/Framework/Manager/AdMgr.js +684 -0
- package/dist/Framework/Manager/AudioMgr.d.ts +28 -0
- package/dist/Framework/Manager/AudioMgr.js +265 -0
- package/dist/Framework/Manager/BaseMgr.d.ts +18 -0
- package/dist/Framework/Manager/BaseMgr.js +114 -0
- package/dist/Framework/Manager/EventMgr.d.ts +18 -0
- package/dist/Framework/Manager/EventMgr.js +90 -0
- package/dist/Framework/Manager/ExcelMgr.d.ts +24 -0
- package/dist/Framework/Manager/ExcelMgr.js +156 -0
- package/dist/Framework/Manager/LifeCycleMgr.d.ts +20 -0
- package/dist/Framework/Manager/LifeCycleMgr.js +110 -0
- package/dist/Framework/Manager/NodePoolMgr.d.ts +53 -0
- package/dist/Framework/Manager/NodePoolMgr.js +279 -0
- package/dist/Framework/Manager/PrivacyMgr.d.ts +15 -0
- package/dist/Framework/Manager/PrivacyMgr.js +176 -0
- package/dist/Framework/Manager/ResMgr.d.ts +49 -0
- package/dist/Framework/Manager/ResMgr.js +337 -0
- package/dist/Framework/Manager/SocialMgr.d.ts +23 -0
- package/dist/Framework/Manager/SocialMgr.js +220 -0
- package/dist/Framework/Manager/SystemMgr.d.ts +24 -0
- package/dist/Framework/Manager/SystemMgr.js +222 -0
- package/dist/Framework/Manager/TimerMgr.d.ts +11 -0
- package/dist/Framework/Manager/TimerMgr.js +63 -0
- package/dist/Framework/Manager/UIMgr.d.ts +33 -0
- package/dist/Framework/Manager/UIMgr.js +223 -0
- package/dist/Framework/Manager/UserMgr.d.ts +15 -0
- package/dist/Framework/Manager/UserMgr.js +148 -0
- package/dist/Framework/Utils/BezierUtils.d.ts +49 -0
- package/dist/Framework/Utils/BezierUtils.js +247 -0
- package/dist/Framework/Utils/CSVUtils.d.ts +35 -0
- package/dist/Framework/Utils/CSVUtils.js +341 -0
- package/dist/Framework/Utils/LogUtils.d.ts +7 -0
- package/dist/Framework/Utils/LogUtils.js +32 -0
- package/dist/Framework/Utils/NumberUtils.d.ts +16 -0
- package/dist/Framework/Utils/NumberUtils.js +44 -0
- package/dist/Framework/Utils/TaskUtils.d.ts +10 -0
- package/dist/Framework/Utils/TaskUtils.js +24 -0
- package/dist/Framework/Utils/TimeUtils.d.ts +19 -0
- package/dist/Framework/Utils/TimeUtils.js +33 -0
- package/dist/Framework/Utils/WXBizDataCryptUtils.d.ts +12 -0
- package/dist/Framework/Utils/WXBizDataCryptUtils.js +37 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +35 -0
- package/package.json +40 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { PlatformID } from "../Definition/SystemDefinition";
|
|
2
|
+
import { LogUtils } from "../Utils/LogUtils";
|
|
3
|
+
import { BaseMgr } from "./BaseMgr";
|
|
4
|
+
export class SocialMgr extends BaseMgr {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
7
|
+
this.shareInfo = null;
|
|
8
|
+
}
|
|
9
|
+
onLoad() {
|
|
10
|
+
super.onLoad();
|
|
11
|
+
if (SocialMgr.Instance === null) {
|
|
12
|
+
SocialMgr.Instance = this;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
this.destroy();
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
init(shareInfo) {
|
|
20
|
+
this.shareInfo = shareInfo;
|
|
21
|
+
LogUtils.Instance.log(SocialMgr.TAG, "init() finished.");
|
|
22
|
+
}
|
|
23
|
+
supportPassiveShare() {
|
|
24
|
+
switch (this.getCurrentPlatformID()) {
|
|
25
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
26
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
27
|
+
case PlatformID.ID_MiniGame_KuaiShou:
|
|
28
|
+
case PlatformID.ID_MiniGame_ZhiFuBao:
|
|
29
|
+
case PlatformID.ID_MiniGame_TapTap:
|
|
30
|
+
case PlatformID.ID_MiniGame_Bilibili:
|
|
31
|
+
case PlatformID.ID_MiniGame_JingDong:
|
|
32
|
+
return true;
|
|
33
|
+
default:
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
supportActiveShare() {
|
|
38
|
+
switch (this.getCurrentPlatformID()) {
|
|
39
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
40
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
41
|
+
case PlatformID.ID_MiniGame_KuaiShou:
|
|
42
|
+
case PlatformID.ID_MiniGame_TapTap:
|
|
43
|
+
case PlatformID.ID_MiniGame_Bilibili:
|
|
44
|
+
case PlatformID.ID_MiniGame_JingDong:
|
|
45
|
+
return true;
|
|
46
|
+
default:
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
configPassiveShare(title, desc, imageUrl, templateId, query) {
|
|
51
|
+
if (!desc || desc.length === 0) {
|
|
52
|
+
desc = this.shareInfo.defaultInfo.desc;
|
|
53
|
+
}
|
|
54
|
+
if (!title || title.length === 0) {
|
|
55
|
+
title = this.shareInfo.defaultInfo.title;
|
|
56
|
+
}
|
|
57
|
+
if (this.getCurrentPlatformID() === PlatformID.ID_MiniGame_WeiXin) {
|
|
58
|
+
title = desc;
|
|
59
|
+
}
|
|
60
|
+
if (!templateId || templateId.length === 0) {
|
|
61
|
+
let currentPlatformID = this.getCurrentPlatformID();
|
|
62
|
+
if (this.shareInfo.templateInfoMap.has(currentPlatformID)) {
|
|
63
|
+
let templateInfo = this.shareInfo.templateInfoMap.get(currentPlatformID);
|
|
64
|
+
if (templateInfo.templateId !== "") {
|
|
65
|
+
templateId = templateInfo.templateId;
|
|
66
|
+
if (this.getCurrentPlatformID() === PlatformID.ID_MiniGame_DouYin) {
|
|
67
|
+
title = "";
|
|
68
|
+
desc = "";
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (templateInfo.imageUrl !== "") {
|
|
72
|
+
imageUrl = templateInfo.imageUrl;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!imageUrl || imageUrl.length === 0) {
|
|
77
|
+
imageUrl = this.shareInfo.defaultInfo.imageUrl;
|
|
78
|
+
}
|
|
79
|
+
if (this.getPlatformAdapter() === null) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.getPlatformAdapter().configPassiveShare(title, desc, imageUrl, templateId, query);
|
|
83
|
+
}
|
|
84
|
+
activeShareToFriend(callback, title, desc, imageUrl, templateId, query) {
|
|
85
|
+
if (!desc || desc.length === 0) {
|
|
86
|
+
desc = this.shareInfo.defaultInfo.desc;
|
|
87
|
+
}
|
|
88
|
+
if (!title || title.length === 0) {
|
|
89
|
+
title = this.shareInfo.defaultInfo.title;
|
|
90
|
+
}
|
|
91
|
+
if (this.getCurrentPlatformID() === PlatformID.ID_MiniGame_WeiXin) {
|
|
92
|
+
title = desc;
|
|
93
|
+
}
|
|
94
|
+
if (!templateId || templateId.length === 0) {
|
|
95
|
+
let currentPlatformID = this.getCurrentPlatformID();
|
|
96
|
+
if (this.shareInfo.templateInfoMap.has(currentPlatformID)) {
|
|
97
|
+
let templateInfo = this.shareInfo.templateInfoMap.get(currentPlatformID);
|
|
98
|
+
if (templateInfo.templateId !== "") {
|
|
99
|
+
templateId = templateInfo.templateId;
|
|
100
|
+
}
|
|
101
|
+
if (templateInfo.imageUrl !== "") {
|
|
102
|
+
imageUrl = templateInfo.imageUrl;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (!imageUrl || imageUrl.length === 0) {
|
|
107
|
+
imageUrl = this.shareInfo.defaultInfo.imageUrl;
|
|
108
|
+
}
|
|
109
|
+
if (this.getPlatformAdapter() === null) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.getPlatformAdapter().activeShareToFriend(callback, title, desc, imageUrl, templateId, query);
|
|
113
|
+
}
|
|
114
|
+
supportRankList() {
|
|
115
|
+
switch (this.getCurrentPlatformID()) {
|
|
116
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
117
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
118
|
+
case PlatformID.ID_MiniGame_TapTap:
|
|
119
|
+
return true;
|
|
120
|
+
default:
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
setRankData(args) {
|
|
125
|
+
if (!this.supportRankList()) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (this.getPlatformAdapter() === null) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.getPlatformAdapter().setRankData(args);
|
|
132
|
+
}
|
|
133
|
+
showRankList(args) {
|
|
134
|
+
if (!this.supportRankList()) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (this.getPlatformAdapter() === null) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
this.getPlatformAdapter().showRankList(args);
|
|
141
|
+
}
|
|
142
|
+
openPortalGame() {
|
|
143
|
+
if (this.getPlatformAdapter() === null) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
this.getPlatformAdapter().openPortalGame();
|
|
147
|
+
}
|
|
148
|
+
supportGameClub() {
|
|
149
|
+
switch (this.getCurrentPlatformID()) {
|
|
150
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
151
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
152
|
+
return true;
|
|
153
|
+
default:
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
openGameClub() {
|
|
158
|
+
if (!this.supportGameClub()) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (this.getPlatformAdapter() === null) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
this.getPlatformAdapter().openGameClub();
|
|
165
|
+
}
|
|
166
|
+
supportRecommendToFriend() {
|
|
167
|
+
switch (this.getCurrentPlatformID()) {
|
|
168
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
169
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
170
|
+
case PlatformID.ID_MiniGame_KuaiShou:
|
|
171
|
+
case PlatformID.ID_MiniGame_TapTap:
|
|
172
|
+
case PlatformID.ID_MiniGame_Bilibili:
|
|
173
|
+
case PlatformID.ID_MiniGame_JingDong:
|
|
174
|
+
return true;
|
|
175
|
+
default:
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
openRecommendToFriend() {
|
|
180
|
+
if (!this.supportRecommendToFriend()) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (this.getPlatformAdapter() === null) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
switch (this.getCurrentPlatformID()) {
|
|
187
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
188
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
189
|
+
this.getPlatformAdapter().openRecommendToFriend();
|
|
190
|
+
break;
|
|
191
|
+
case PlatformID.ID_MiniGame_KuaiShou:
|
|
192
|
+
case PlatformID.ID_MiniGame_Bilibili:
|
|
193
|
+
case PlatformID.ID_MiniGame_TapTap:
|
|
194
|
+
case PlatformID.ID_MiniGame_JingDong:
|
|
195
|
+
this.activeShareToFriend();
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
supportRecommendToGameClub() {
|
|
202
|
+
switch (this.getCurrentPlatformID()) {
|
|
203
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
204
|
+
return true;
|
|
205
|
+
default:
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
openRecommendToGameClub() {
|
|
210
|
+
if (!this.supportRecommendToGameClub()) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (this.getPlatformAdapter() === null) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
this.getPlatformAdapter().openRecommendToGameClub();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
SocialMgr.Instance = null;
|
|
220
|
+
SocialMgr.TAG = "SocialMgr";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AppItem, CopyrightInfo } from "../Definition/SystemDefinition";
|
|
2
|
+
import { BaseMgr } from "./BaseMgr";
|
|
3
|
+
export declare class SystemMgr extends BaseMgr {
|
|
4
|
+
static Instance: SystemMgr;
|
|
5
|
+
static TAG: string;
|
|
6
|
+
private appItem;
|
|
7
|
+
private copyrightInfo;
|
|
8
|
+
private localGame;
|
|
9
|
+
onLoad(): void;
|
|
10
|
+
init(appItem: AppItem, copyrightInfo: CopyrightInfo): void;
|
|
11
|
+
getAppItem(): AppItem;
|
|
12
|
+
isLocalGame(): boolean;
|
|
13
|
+
getScreenBrightness(callback: Function): void;
|
|
14
|
+
setScreenBrightness(value: number): void;
|
|
15
|
+
setKeepScreenOn(keepScreenOn: boolean): void;
|
|
16
|
+
exitGame(): void;
|
|
17
|
+
getSDKVersion(): string;
|
|
18
|
+
navigateToMiniProgram(appid: string, path?: string): void;
|
|
19
|
+
reportEvent(eventId: string, data: JSON): void;
|
|
20
|
+
supportRequest(): boolean;
|
|
21
|
+
requestGet(path: string, requestParams: Map<string, string> | null, success: Function, fail: Function): void;
|
|
22
|
+
requestPost(path: string, data: string, success: Function, fail: Function): void;
|
|
23
|
+
downloadFile(fileUrl: string, success: Function, fail: Function): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { PlatformAdapterBilibili } from "../Adapter/PlatformAdapter/PlatformAdapterBilibili";
|
|
2
|
+
import { PlatformAdapterDesktopBrowser } from "../Adapter/PlatformAdapter/PlatformAdapterDesktopBrowser";
|
|
3
|
+
import { PlatformAdapterDouYin } from "../Adapter/PlatformAdapter/PlatformAdapterDouYin";
|
|
4
|
+
import { PlatformAdapterHonor } from "../Adapter/PlatformAdapter/PlatformAdapterHonor";
|
|
5
|
+
import { PlatformAdapterHuaWei } from "../Adapter/PlatformAdapter/PlatformAdapterHuaWei";
|
|
6
|
+
import { PlatformAdapterJingDong } from "../Adapter/PlatformAdapter/PlatformAdapterJingDong";
|
|
7
|
+
import { PlatformAdapterKuaiShou } from "../Adapter/PlatformAdapter/PlatformAdapterKuaiShou";
|
|
8
|
+
import { PlatformAdapterOppo } from "../Adapter/PlatformAdapter/PlatformAdapterOppo";
|
|
9
|
+
import { PlatformAdapterTapTap } from "../Adapter/PlatformAdapter/PlatformAdapterTapTap";
|
|
10
|
+
import { PlatformAdapterVivo } from "../Adapter/PlatformAdapter/PlatformAdapterVivo";
|
|
11
|
+
import { PlatformAdapterWeiXin } from "../Adapter/PlatformAdapter/PlatformAdapterWeiXin";
|
|
12
|
+
import { PlatformAdapterXiaoMi } from "../Adapter/PlatformAdapter/PlatformAdapterXiaoMi";
|
|
13
|
+
import { PlatformAdapterZhiFuBao } from "../Adapter/PlatformAdapter/PlatformAdapterZhiFuBao";
|
|
14
|
+
import { PlatformID } from "../Definition/SystemDefinition";
|
|
15
|
+
import { LogUtils } from "../Utils/LogUtils";
|
|
16
|
+
import { BaseMgr } from "./BaseMgr";
|
|
17
|
+
export class SystemMgr extends BaseMgr {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.appItem = null;
|
|
21
|
+
this.copyrightInfo = null;
|
|
22
|
+
this.localGame = true;
|
|
23
|
+
}
|
|
24
|
+
onLoad() {
|
|
25
|
+
super.onLoad();
|
|
26
|
+
if (SystemMgr.Instance === null) {
|
|
27
|
+
SystemMgr.Instance = this;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.destroy();
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
init(appItem, copyrightInfo) {
|
|
35
|
+
this.appItem = appItem;
|
|
36
|
+
this.copyrightInfo = copyrightInfo;
|
|
37
|
+
let currPlatformID = BaseMgr.Instance.getCurrentPlatformID();
|
|
38
|
+
if (this.appItem !== null && this.appItem.appIDMap !== null &&
|
|
39
|
+
this.appItem.appIDMap.has(currPlatformID)) {
|
|
40
|
+
LogUtils.Instance.log(SystemMgr.TAG, "appID=" + this.appItem.appIDMap.get(currPlatformID));
|
|
41
|
+
}
|
|
42
|
+
if (this.copyrightInfo && this.copyrightInfo.icpMap &&
|
|
43
|
+
this.copyrightInfo.icpMap.has(currPlatformID)) {
|
|
44
|
+
let icpItem = this.copyrightInfo.icpMap.get(currPlatformID);
|
|
45
|
+
if (icpItem !== null) {
|
|
46
|
+
this.localGame = icpItem.isLocalGame;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
LogUtils.Instance.log(SystemMgr.TAG, "isLocalGame=" + this.localGame);
|
|
50
|
+
let platformAdapterImpl = null;
|
|
51
|
+
switch (currPlatformID) {
|
|
52
|
+
case PlatformID.ID_H5_DesktopBrowser:
|
|
53
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterDesktopBrowser);
|
|
54
|
+
break;
|
|
55
|
+
case PlatformID.ID_MiniGame_WeiXin:
|
|
56
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterWeiXin);
|
|
57
|
+
break;
|
|
58
|
+
case PlatformID.ID_MiniGame_DouYin:
|
|
59
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterDouYin);
|
|
60
|
+
break;
|
|
61
|
+
case PlatformID.ID_MiniGame_KuaiShou:
|
|
62
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterKuaiShou);
|
|
63
|
+
break;
|
|
64
|
+
case PlatformID.ID_MiniGame_ZhiFuBao:
|
|
65
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterZhiFuBao);
|
|
66
|
+
break;
|
|
67
|
+
case PlatformID.ID_MiniGame_Bilibili:
|
|
68
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterBilibili);
|
|
69
|
+
break;
|
|
70
|
+
case PlatformID.ID_MiniGame_TapTap:
|
|
71
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterTapTap);
|
|
72
|
+
break;
|
|
73
|
+
case PlatformID.ID_MiniGame_JingDong:
|
|
74
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterJingDong);
|
|
75
|
+
break;
|
|
76
|
+
case PlatformID.ID_QuickGame_XiaoMi:
|
|
77
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterXiaoMi);
|
|
78
|
+
break;
|
|
79
|
+
case PlatformID.ID_QuickGame_Oppo:
|
|
80
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterOppo);
|
|
81
|
+
break;
|
|
82
|
+
case PlatformID.ID_QuickGame_Honor:
|
|
83
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterHonor);
|
|
84
|
+
break;
|
|
85
|
+
case PlatformID.ID_QuickGame_Vivo:
|
|
86
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterVivo);
|
|
87
|
+
break;
|
|
88
|
+
case PlatformID.ID_QuickGame_HuaWei:
|
|
89
|
+
platformAdapterImpl = this.node.addComponent(PlatformAdapterHuaWei);
|
|
90
|
+
break;
|
|
91
|
+
default:
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (platformAdapterImpl !== null) {
|
|
95
|
+
BaseMgr.Instance.setPlatformAdapter(platformAdapterImpl);
|
|
96
|
+
}
|
|
97
|
+
if (this.getPlatformAdapter() !== null) {
|
|
98
|
+
this.getPlatformAdapter().onInit(this);
|
|
99
|
+
}
|
|
100
|
+
LogUtils.Instance.log(SystemMgr.TAG, "init() finished.");
|
|
101
|
+
}
|
|
102
|
+
getAppItem() {
|
|
103
|
+
return this.appItem;
|
|
104
|
+
}
|
|
105
|
+
isLocalGame() {
|
|
106
|
+
return this.localGame;
|
|
107
|
+
}
|
|
108
|
+
getScreenBrightness(callback) {
|
|
109
|
+
if (this.getPlatformAdapter() === null) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.getPlatformAdapter().getScreenBrightness(callback);
|
|
113
|
+
}
|
|
114
|
+
setScreenBrightness(value) {
|
|
115
|
+
if (value < 0) {
|
|
116
|
+
value = 0;
|
|
117
|
+
}
|
|
118
|
+
if (value > 1) {
|
|
119
|
+
value = 1;
|
|
120
|
+
}
|
|
121
|
+
if (this.getPlatformAdapter() === null) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.getPlatformAdapter().setScreenBrightness(value);
|
|
125
|
+
}
|
|
126
|
+
setKeepScreenOn(keepScreenOn) {
|
|
127
|
+
if (this.getPlatformAdapter() === null) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
this.getPlatformAdapter().setKeepScreenOn(keepScreenOn);
|
|
131
|
+
}
|
|
132
|
+
exitGame() {
|
|
133
|
+
if (this.getPlatformAdapter() === null) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
this.getPlatformAdapter().exitGame();
|
|
137
|
+
}
|
|
138
|
+
getSDKVersion() {
|
|
139
|
+
if (this.getPlatformAdapter() === null) {
|
|
140
|
+
return "";
|
|
141
|
+
}
|
|
142
|
+
return this.getPlatformAdapter().getSDKVersion();
|
|
143
|
+
}
|
|
144
|
+
navigateToMiniProgram(appid, path) {
|
|
145
|
+
if (this.getPlatformAdapter() === null) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
this.getPlatformAdapter().navigateToMiniProgram(appid, path);
|
|
149
|
+
}
|
|
150
|
+
reportEvent(eventId, data) {
|
|
151
|
+
if (this.getPlatformAdapter() === null) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.getPlatformAdapter().reportEvent(eventId, data);
|
|
155
|
+
}
|
|
156
|
+
supportRequest() {
|
|
157
|
+
let platformSupport = false;
|
|
158
|
+
switch (this.getCurrentPlatformID()) {
|
|
159
|
+
case PlatformID.ID_QuickGame_Oppo:
|
|
160
|
+
case PlatformID.ID_QuickGame_Honor:
|
|
161
|
+
case PlatformID.ID_QuickGame_HuaWei:
|
|
162
|
+
platformSupport = false;
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
platformSupport = true;
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
return platformSupport && !this.isLocalGame();
|
|
169
|
+
}
|
|
170
|
+
requestGet(path, requestParams, success, fail) {
|
|
171
|
+
if (this.getPlatformAdapter() === null) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
if (success === null || fail === null) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (!this.supportRequest()) {
|
|
178
|
+
fail();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
let url = path;
|
|
182
|
+
if (requestParams && requestParams.size > 0) {
|
|
183
|
+
let paramIndex = 0;
|
|
184
|
+
for (let entry of requestParams.entries()) {
|
|
185
|
+
paramIndex++;
|
|
186
|
+
url += (paramIndex === 1) ? "?" : "&";
|
|
187
|
+
url += entry[0] + "=" + entry[1];
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
LogUtils.Instance.log(SystemMgr.TAG, "requestGet", url);
|
|
191
|
+
this.getPlatformAdapter().requestGet(url, success, fail);
|
|
192
|
+
}
|
|
193
|
+
requestPost(path, data, success, fail) {
|
|
194
|
+
if (this.getPlatformAdapter() === null) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (success === null || fail === null) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (!this.supportRequest()) {
|
|
201
|
+
fail();
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
LogUtils.Instance.log(SystemMgr.TAG, "requestPost", path, data);
|
|
205
|
+
this.getPlatformAdapter().requestPost(path, data, success, fail);
|
|
206
|
+
}
|
|
207
|
+
downloadFile(fileUrl, success, fail) {
|
|
208
|
+
if (this.getPlatformAdapter() === null) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (success === null || fail === null) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (!this.supportRequest()) {
|
|
215
|
+
fail();
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
this.getPlatformAdapter().downloadFile(fileUrl, success, fail);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
SystemMgr.Instance = null;
|
|
222
|
+
SystemMgr.TAG = "SystemMgr";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseMgr } from "./BaseMgr";
|
|
2
|
+
export declare class TimerMgr extends BaseMgr {
|
|
3
|
+
static Instance: TimerMgr;
|
|
4
|
+
static TAG: string;
|
|
5
|
+
private timers;
|
|
6
|
+
onLoad(): void;
|
|
7
|
+
init(): void;
|
|
8
|
+
addTimer(delay: number, interval: number, repeat: number, func: Function, target: Object): void;
|
|
9
|
+
removeTimer(func: Function, target: Object): void;
|
|
10
|
+
protected update(dt: number): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { LogUtils } from "../Utils/LogUtils";
|
|
2
|
+
import { BaseMgr } from "./BaseMgr";
|
|
3
|
+
export class TimerMgr extends BaseMgr {
|
|
4
|
+
constructor() {
|
|
5
|
+
super(...arguments);
|
|
6
|
+
this.timers = [];
|
|
7
|
+
}
|
|
8
|
+
onLoad() {
|
|
9
|
+
super.onLoad();
|
|
10
|
+
if (TimerMgr.Instance === null) {
|
|
11
|
+
TimerMgr.Instance = this;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
this.destroy();
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
init() {
|
|
19
|
+
this.timers = [];
|
|
20
|
+
LogUtils.Instance.log(TimerMgr.TAG, "init() finished.");
|
|
21
|
+
}
|
|
22
|
+
addTimer(delay, interval, repeat, func, target) {
|
|
23
|
+
if (repeat === 0) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.removeTimer(func, target);
|
|
27
|
+
this.timers.push({
|
|
28
|
+
tick: 0 - delay,
|
|
29
|
+
interval: interval,
|
|
30
|
+
repeat: repeat,
|
|
31
|
+
func: func,
|
|
32
|
+
target: target,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
removeTimer(func, target) {
|
|
36
|
+
for (let index = 0; index < this.timers.length; index++) {
|
|
37
|
+
const item = this.timers[index];
|
|
38
|
+
if (item.func === func && item.target === target) {
|
|
39
|
+
this.timers.splice(index, 1);
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
update(dt) {
|
|
45
|
+
for (let index = 0; index < this.timers.length; index++) {
|
|
46
|
+
const item = this.timers[index];
|
|
47
|
+
item.tick += dt * 1000;
|
|
48
|
+
if (item.tick >= item.interval) {
|
|
49
|
+
item.tick -= item.interval;
|
|
50
|
+
item.func.call(item.target);
|
|
51
|
+
if (item.repeat > 0) {
|
|
52
|
+
item.repeat--;
|
|
53
|
+
if (item.repeat === 0) {
|
|
54
|
+
this.timers.splice(index, 1);
|
|
55
|
+
index--;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
TimerMgr.Instance = null;
|
|
63
|
+
TimerMgr.TAG = "TimerMgr";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Component, Node, Color } from 'cc';
|
|
2
|
+
import { ToastDuration } from '../Definition/UIDefinition';
|
|
3
|
+
import { BaseMgr } from './BaseMgr';
|
|
4
|
+
export declare class UICtrl extends Component {
|
|
5
|
+
protected views: Map<string, Node>;
|
|
6
|
+
onLoad(): void;
|
|
7
|
+
private load_all_object;
|
|
8
|
+
set_button_listener(view_name: string, clickListener: Function, target?: Component): void;
|
|
9
|
+
}
|
|
10
|
+
export declare class UIMgr extends BaseMgr {
|
|
11
|
+
static Instance: UIMgr;
|
|
12
|
+
static TAG: string;
|
|
13
|
+
private canvas;
|
|
14
|
+
private uiMap;
|
|
15
|
+
private windowWidth;
|
|
16
|
+
private windowHeight;
|
|
17
|
+
private node_toastRoot;
|
|
18
|
+
private tween_toast;
|
|
19
|
+
private node_dialogRoot;
|
|
20
|
+
print(): void;
|
|
21
|
+
onLoad(): void;
|
|
22
|
+
init(): void;
|
|
23
|
+
create_ui(ui_name: string, parent?: Node): Node;
|
|
24
|
+
destroy_ui(ui_name: string, node: Node): void;
|
|
25
|
+
destroy_ui_all(ui_name: string): void;
|
|
26
|
+
clear_ui_all(): void;
|
|
27
|
+
adaptScreen(node: Node): void;
|
|
28
|
+
setToastRootNode(node: Node): void;
|
|
29
|
+
showToast(content: string, toastDuration?: ToastDuration): void;
|
|
30
|
+
setDialogRootNode(node: Node): void;
|
|
31
|
+
openDialog(ui_name: string, maskColor?: Color): Node;
|
|
32
|
+
closeDialog(ui_name: string, node: Node): void;
|
|
33
|
+
}
|