/* * @Author: mojunshou 1637302775@qq.com * @Date: 2025-04-07 17:49:55 * @LastEditors: mojunshou 1637302775@qq.com * @LastEditTime: 2025-04-11 11:13:59 * @Description: */ // CocosHandler.ts // 封装对外模块调度(统一入口) import { native } from 'cc'; import { DeviceUtil } from 'db://oops-framework/core/utils/DeviceUtil'; export type CocosHandlerType = { method: string; param?: string; }; export class CocosHandler { private static _inst: CocosHandler; public static get inst(): CocosHandler { if (!this._inst) { this._inst = new CocosHandler(); } return this._inst; } public async sendMessageToAndroid(data: CocosHandlerType, logTag: string = '') { if (DeviceUtil.isAndroid && DeviceUtil.isNative) { const result = await native.reflection.callStaticMethod( 'com/cocos/game/AtmobCocosCaller', 'call', '(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;', data.method, data.param ); if (logTag) { console.log(`[${logTag}] Android 返回:`, result); } return result; } return null; } }