平台判断辅助工具类:PlatformHelper.ts

This commit is contained in:
chen wei bo
2025-09-25 11:24:56 +08:00
parent b5de68d76b
commit 7896dbacb2
4 changed files with 107 additions and 5 deletions
+5 -4
View File
@@ -8,6 +8,7 @@ import AudioManager from "../Manager/AudioManager";
import GlobalValue, { VideoRoleType } from "../Common/GlobalValue";
import { luffaSDK } from "./luffaSDK";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
import { PlatformHelper } from "./PlatformHelper";
const { ccclass, property } = _decorator;
@@ -91,13 +92,13 @@ export class SDKManager { //extends Component
logger.log("平台值 ks:",window["ks"], typeof window["ks"])
logger.log("平台值 tt:",window["tt"], typeof window["tt"])
if (typeof window["ks"] !== 'undefined') {
if (PlatformHelper.isKuaishou()) {
this.sdk_channel = E_SDK_Channel.KS
this.sdk = new KSSDK() //快手
}else if (sys.platform === sys.Platform.WECHAT_GAME && typeof window["wx"] !== 'undefined') {
}else if (PlatformHelper.isWechat()) {
this.sdk_channel = E_SDK_Channel.WX
this.sdk = new luffaSDK() //微信
} else if (sys.platform === sys.Platform.BYTEDANCE_MINI_GAME && typeof window["tt"] !== 'undefined') {
} else if (PlatformHelper.isByteDance()) {
this.sdk_channel = E_SDK_Channel.BD
this.sdk = new ByteDanceSDK() //抖音(头条)
} else {
@@ -105,7 +106,7 @@ export class SDKManager { //extends Component
this.sdk = new WebSDK()
}
logger.log("当前平台:",sys.platform, this.sdk_channel)
logger.log("当前平台:", PlatformHelper.getPlatformName(), this.sdk_channel)
if (GlobalValue.NpcVideoMod) {
GlobalValue.NpcVideoMod = this.sdk_channel === E_SDK_Channel.WX || this.sdk_channel === E_SDK_Channel.WEB
}