WXSDK.ts
1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import DataService from "./service/DataService";
import SdkData from "./service/entity/SdkData";
import ShareVideoService from "./service/ShareVideoService";
import WxInit from "./wx/WxInit";
import GameService from "./service/GameService";
import LogService from "./service/LogService";
import AdService from "./service/AdService";
import OnlineService from "./service/OnlineService";
import WxInterstitial from "./wx/WxInterstitial";
export default class WXSDK {
public static get isWx(): boolean {
return typeof (wx) != "undefined"
}
public static get data(): SdkData {
return DataService.I.Data;
}
public static get share(): ShareVideoService {
return ShareVideoService.I;
}
public static get game(): GameService {
return GameService.I;
}
public static get ad(): AdService {
return AdService.I;
}
public static get stat(): LogService {
return LogService.I;
}
public static get online(): OnlineService {
return OnlineService.I;
}
public static async init() {
if (this.isWx) {
WxInit.I.init();
//视频预加载 启动预加载视频会闪屏
setTimeout(() => {
WxInterstitial.initInterstitialAd();//插屏预加载
ShareVideoService.I.preloadVideo();
}, 2000);
}
DataService.I.updateTodayOnlineTime();
await this.game.env();
if (this.isWx) {
ShareVideoService.I.init();
}
return Promise.resolve();
}
}