diff --git a/templates/harmonyos-next/entry/src/main/cpp/types/libcocos/index.d.ts b/templates/harmonyos-next/entry/src/main/cpp/types/libcocos/index.d.ts index 4b57978db5a..d04073c59bb 100644 --- a/templates/harmonyos-next/entry/src/main/cpp/types/libcocos/index.d.ts +++ b/templates/harmonyos-next/entry/src/main/cpp/types/libcocos/index.d.ts @@ -1,6 +1,7 @@ import { ContextType } from '../../../ets/common/Constants'; +import resourceManager from '@ohos.resourceManager'; -interface context { +export interface context { onPageShow: () => void; onPageHide: () => void; workerInit: () => void; @@ -21,11 +22,10 @@ interface context { onDestroy: () => void; onShow: () => void; onHide: () => void; - resourceManagerInit: (resourceManager: any) => void; + resourceManagerInit: (resourceManager: resourceManager.ResourceManager) => void; writablePathInit: (cacheDir: string) => void; onVideoEvent: (param: string) => void; registerFunction: (name:string ,fun:Function) => void; } export const getContext: (type: ContextType) => context; -export const evalString: (value: string) => any; diff --git a/templates/harmonyos-next/entry/src/main/ets/entryability/EntryAbility.ets b/templates/harmonyos-next/entry/src/main/ets/entryability/EntryAbility.ets index 7a93777b7b8..c5fbeeabc3c 100644 --- a/templates/harmonyos-next/entry/src/main/ets/entryability/EntryAbility.ets +++ b/templates/harmonyos-next/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,12 +1,12 @@ import UIAbility from '@ohos.app.ability.UIAbility'; -import cocos from 'libcocos.so'; +import cocos, { context } from 'libcocos.so'; import { ContextType } from '../common/Constants'; import window from '@ohos.window'; import { BusinessError } from '@kit.BasicServicesKit'; import { AbilityConstant, Want } from '@kit.AbilityKit'; -const nativeContext = cocos.getContext(ContextType.ENGINE_UTILS); -const nativeAppLifecycle = cocos.getContext(ContextType.APP_LIFECYCLE); +const nativeContext: context = cocos.getContext(ContextType.ENGINE_UTILS); +const nativeAppLifecycle: context = cocos.getContext(ContextType.APP_LIFECYCLE); enum windowStageType { hide, show