diff --git a/README_ZH.md b/README_ZH.md index 8a9dcd2..d8e838a 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -144,8 +144,8 @@ wallpaper.setWallpaper(pixelmap, WALLPAPER_SYSTEM).then((data) => { js 应用接口使用说明 ``` -import Extension from '@ohos.application.WallpaperExtension' -import wallPaper from '@ohos.app.wallpaperability' +import Extension from '@ohos.wallpaperextension' +import wallPaper from '@ohos.wallpaper' export default class WallpaperExtAbility extends Extension { onCreated(want) { diff --git a/bundle.json b/bundle.json index 27fddff..4f4faa4 100644 --- a/bundle.json +++ b/bundle.json @@ -51,7 +51,7 @@ "//base/miscservices/wallpaper/frameworks/kits/extension:wallpaper_extension_module", "//base/miscservices/wallpaper/interfaces/kits/napi/wallpaperextension:wallpaperextension_napi", "//base/miscservices/wallpaper/interfaces/kits/napi/wallpaper_extension_context:wallpaperextensioncontext_napi", - "//base/miscservices/wallpaper/interfaces/kits/napi:wallpaperability", + "//base/miscservices/wallpaper/interfaces/kits/napi:wallpaper", "//base/miscservices/wallpaper/utils:wallpaper_utils", "//base/miscservices/wallpaper/frameworks/innerkitsimpl/wallpaper_manager:wallpaperdefault.jpeg", "//base/miscservices/wallpaper/frameworks/innerkitsimpl/wallpaper_manager:wallpaperlockdefault.jpeg" diff --git a/interfaces/kits/napi/BUILD.gn b/interfaces/kits/napi/BUILD.gn index 478051b..304a6e4 100644 --- a/interfaces/kits/napi/BUILD.gn +++ b/interfaces/kits/napi/BUILD.gn @@ -14,7 +14,7 @@ import("//base/miscservices/wallpaper/wallpaper.gni") import("//build/ohos.gni") -ohos_shared_library("wallpaperability") { +ohos_shared_library("wallpaper") { include_dirs = [ "//foundation/arkui/napi/interfaces/kits", "//third_party/node/src", @@ -53,7 +53,7 @@ ohos_shared_library("wallpaperability") { "ipc:ipc_core", ] - relative_install_dir = "module/app" + relative_install_dir = "module" subsystem_name = "miscservices" part_name = "wallpaper_native" } diff --git a/interfaces/kits/napi/native_module.cpp b/interfaces/kits/napi/native_module.cpp index dc446f1..184507b 100644 --- a/interfaces/kits/napi/native_module.cpp +++ b/interfaces/kits/napi/native_module.cpp @@ -37,10 +37,14 @@ EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { HILOG_INFO("napi_moudule Init start..."); + napi_value WallpaperType = nullptr; napi_value wpType_system = nullptr; napi_value wpType_lockscreen = nullptr; - napi_create_int32(env, static_cast(WALLPAPER_SYSTEM), &wpType_system); - napi_create_int32(env, static_cast(WALLPAPER_LOCKSCREEN), &wpType_lockscreen); + NAPI_CALL(env, napi_create_int32(env, static_cast(WALLPAPER_SYSTEM), &wpType_system)); + NAPI_CALL(env, napi_create_int32(env, static_cast(WALLPAPER_LOCKSCREEN), &wpType_lockscreen)); + NAPI_CALL(env, napi_create_object(env, &WallpaperType)); + NAPI_CALL(env, napi_set_named_property(env, WallpaperType, "WALLPAPER_SYSTEM", wpType_system)); + NAPI_CALL(env, napi_set_named_property(env, WallpaperType, "WALLPAPER_LOCKSCREEN", wpType_lockscreen)); napi_property_descriptor desc[] = { DECLARE_NAPI_FUNCTION("getColors", NAPI_GetColors), DECLARE_NAPI_FUNCTION("getId", NAPI_GetId), @@ -54,8 +58,7 @@ static napi_value Init(napi_env env, napi_value exports) DECLARE_NAPI_FUNCTION("screenshotLiveWallpaper", NAPI_ScreenshotLiveWallpaper), DECLARE_NAPI_FUNCTION("on", NAPI_On), DECLARE_NAPI_FUNCTION("off", NAPI_Off), - DECLARE_NAPI_STATIC_PROPERTY("WALLPAPER_SYSTEM", wpType_system), - DECLARE_NAPI_STATIC_PROPERTY("WALLPAPER_LOCKSCREEN", wpType_lockscreen), + DECLARE_NAPI_STATIC_PROPERTY("WallpaperType", WallpaperType), }; NAPI_CALL(env, napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc)); diff --git a/interfaces/kits/napi/wallpaperextension/BUILD.gn b/interfaces/kits/napi/wallpaperextension/BUILD.gn index a102086..9484f9c 100644 --- a/interfaces/kits/napi/wallpaperextension/BUILD.gn +++ b/interfaces/kits/napi/wallpaperextension/BUILD.gn @@ -44,7 +44,7 @@ ohos_shared_library("wallpaperextension_napi") { external_deps = [ "napi:ace_napi" ] - relative_install_dir = "module/application" + relative_install_dir = "module" subsystem_name = "miscservices" part_name = "wallpaper_native" } diff --git a/interfaces/kits/napi/wallpaperextension/wallpaper_extension_module.cpp b/interfaces/kits/napi/wallpaperextension/wallpaper_extension_module.cpp index ec46f94..1112e05 100644 --- a/interfaces/kits/napi/wallpaperextension/wallpaper_extension_module.cpp +++ b/interfaces/kits/napi/wallpaperextension/wallpaper_extension_module.cpp @@ -25,8 +25,8 @@ void NAPI_application_WallpaperExtension_AutoRegister() { auto moduleManager = NativeModuleManager::GetInstance(); NativeModule newModuleInfo = { - .name = "application.WallpaperExtension", - .fileName = "application/libwallpaperextension_napi.so/WallpaperExtension.js", + .name = "wallpaperextension", + .fileName = "libwallpaperextension_napi.so/WallpaperExtension.js", }; moduleManager->Register(&newModuleInfo);