From ce13387864114a1c83640a1a5127abe52fc7e302 Mon Sep 17 00:00:00 2001 From: chen wei bo <1025839511@qq.com> Date: Thu, 25 Sep 2025 11:33:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=88=A4=E6=96=AD=E8=BE=85?= =?UTF-8?q?=E5=8A=A9=E5=B7=A5=E5=85=B7=E7=B1=BB=EF=BC=9APlatformHelper.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../foundation/identity/MachineInfoService.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts b/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts index 423e7d45..c810d1b2 100644 --- a/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts +++ b/assets/Scripts/chat18x/foundation/identity/MachineInfoService.ts @@ -1,5 +1,6 @@ import { sys, native } from "cc"; import { EDITOR, PREVIEW } from "cc/env"; +import { PlatformHelper } from "../../../Main/Channel/PlatformHelper"; function isWeChatMiniGame(): boolean { const g: any = globalThis as any; @@ -30,7 +31,7 @@ function tryMiniGameModel(): string | null { function tryNativeModel(): string | null { // if (!sys.isNative) return null; // try { -// if (sys.platform === sys.Platform.ANDROID) { +// if (PlatformHelper.isAndroid()) { // const s = native.reflection.callStaticMethod( // "org/cocos2dx/javascript/AppActivity", // "getDeviceModel", @@ -38,7 +39,7 @@ function tryNativeModel(): string | null { // ); // return (s && String(s).trim()) || null; // } -// if (sys.platform === sys.Platform.IOS) { +// if (PlatformHelper.isIOS()) { // const s = native.reflection.callStaticMethod("AppController", "getHardwareModel"); // return (s && String(s).trim()) || null; // } @@ -67,8 +68,8 @@ export class MachineInfoService { public runtimeTag(): string { if (EDITOR) return PREVIEW ? "editor-preview" : "editor"; if (sys.isNative) { - if (sys.platform === sys.Platform.ANDROID) return "native-android"; - if (sys.platform === sys.Platform.IOS) return "native-ios"; + if (PlatformHelper.isAndroid()) return "native-android"; + if (PlatformHelper.isIOS()) return "native-ios"; return "native"; } if (isWeChatMiniGame()) return "minigame-wechat"; @@ -115,13 +116,13 @@ export class MachineInfoService { return 3; // 在 Cocos Creator 编辑器里运行 } - if (sys.platform === sys.Platform.ANDROID) { + if (PlatformHelper.isAndroid()) { return 1; } - if (sys.platform === sys.Platform.IOS) { + if (PlatformHelper.isIOS()) { return 2; } - if (sys.platform === sys.Platform.WIN32) { + if (PlatformHelper.isWinDesktop()) { return 3; } return 3;