From add8cd10bdec521b684a15226cab6faa47220b05 Mon Sep 17 00:00:00 2001 From: JackLee <809262979@qq.com> Date: Mon, 23 Feb 2026 18:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=94=99=E8=AF=AF=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/build-profile.json5 | 3 +-- entry/obfuscation-rules.txt | 8 ++++---- entry/src/main/cpp/napi_init.cpp | 10 ++-------- entry/src/main/ets/pages/modelView.ets | 2 +- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 5340ac0a..cd0de013 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -38,7 +38,7 @@ }, "nativeLib": { "debugSymbol": { - "strip": false, + "strip": true, "exclude": [] } } @@ -47,7 +47,6 @@ "targets": [ { "name": "default", - "runtimeOS": "HarmonyOS" }, { "name": "ohosTest", diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt index 1e7e54e1..c0caa13e 100644 --- a/entry/obfuscation-rules.txt +++ b/entry/obfuscation-rules.txt @@ -17,7 +17,7 @@ # -keep-property-name: specifies property names that you want to keep # -keep-global-name: specifies names that you want to keep in the global scope --enable-property-obfuscation --enable-toplevel-obfuscation --enable-filename-obfuscation --enable-export-obfuscation \ No newline at end of file +#-enable-property-obfuscation +#-enable-toplevel-obfuscation +#-enable-filename-obfuscation +#-enable-export-obfuscation \ No newline at end of file diff --git a/entry/src/main/cpp/napi_init.cpp b/entry/src/main/cpp/napi_init.cpp index fb77f12a..01c7103b 100644 --- a/entry/src/main/cpp/napi_init.cpp +++ b/entry/src/main/cpp/napi_init.cpp @@ -114,19 +114,13 @@ static napi_value DestroyRenderer(napi_env env, napi_callback_info info) { EXTERN_C_START static napi_value Init(napi_env env, napi_value exports) { - if ((env == nullptr) || (exports == nullptr)) { - return nullptr; - } napi_property_descriptor desc[] = { {"initRenderer", nullptr, InitRenderer,nullptr, nullptr, nullptr, napi_default, nullptr}, {"loadModel", nullptr, LoadModel,nullptr, nullptr, nullptr, napi_default, nullptr}, {"onMouseEvent", nullptr, OnMouseEvent,nullptr, nullptr, nullptr, napi_default, nullptr}, {"destroyRenderer", nullptr, DestroyRenderer,nullptr, nullptr, nullptr, napi_default, nullptr}, }; - - if (napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc) != napi_ok) { - return nullptr; - } + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); return exports; } EXTERN_C_END @@ -142,7 +136,7 @@ static napi_module OpenCAXModel = { .reserved = { 0 } }; -extern "C" __attribute__((constructor)) +extern "C" __attribute__((visibility("default"))) void RegisterOpenCAXModule(void) { napi_module_register(&OpenCAXModel); diff --git a/entry/src/main/ets/pages/modelView.ets b/entry/src/main/ets/pages/modelView.ets index ad1665b2..18e61caf 100644 --- a/entry/src/main/ets/pages/modelView.ets +++ b/entry/src/main/ets/pages/modelView.ets @@ -60,7 +60,7 @@ export struct ModelView { }) Button('测试模块加载').onClick(()=>{ try { - let NaviteOCCT = import("libopencax.so") + const NaviteOCCT = import("libopencax.so") console.info(`[NDK] 模块类型: ${typeof NaviteOCCT}`); console.info(`[NDK] 模块值: ${JSON.stringify(NaviteOCCT)}`); console.info(`[NDK] 所有属性: ${Object.keys(NaviteOCCT).join(', ')}`);