最近发布了很多平台,利用cc.sys.platform来做平台判断,其实有很多问题。所以自己总结了一下 。写了平台判断的代码。以下几个平台都是可以正确判断的。
export class PlatformJudge {
//oppo 小游戏
static get isOppo(): boolean {
return window.qg && window.qg.setLoadingProgress && !window.hbs;
}
//vivo小游戏
static get isVivo(): boolean {
return window.qg && !window.qg.setLoadingProgress && !window.hbs;
}
//qq小游戏
static get isQQ(): boolean {
return window.qq;
}
//微信小游戏
static get isWX(): boolean {
return window.wx && !window.qq && !window.tt;
}
//头条小游戏
static get isTT(): boolean {
return window.tt;
}
//华为小游戏
static get isHW(): boolean {
return window.hbs;
}
}
