From 413ac4c6866ca08e63031ef1b49e2c607482dc86 Mon Sep 17 00:00:00 2001 From: KrrI Date: Mon, 17 Feb 2025 16:38:32 +0800 Subject: [PATCH] =?UTF-8?q?chore:=E6=B7=86=E8=A7=84=E5=88=99=E9=85=8D?= =?UTF-8?q?=E7=BD=AE.=20docs:=E6=B7=B7=E6=B7=86=E8=A7=84=E5=88=99=E8=AF=B4?= =?UTF-8?q?=E6=98=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: KrrI --- README.md | 8 ++++++++ README_zh.md | 9 +++++++++ entry/build-profile.json5 | 18 ++++++++++++++++-- entry/obfuscation-rules.txt | 26 ++++++++++++++++++++++++++ 4 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 entry/obfuscation-rules.txt diff --git a/README.md b/README.md index 7386ad9..6c3aecf 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,14 @@ This project has been verified in the following version: DevEco Studio: DevEco Studio:4.0 (4.0.3.512), SDK:API10 (4.0.10.9) +## About obfuscation +- Code obfuscation, please see[Code Obfuscation](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md) +- If you want the axios library not to be obfuscated during code obfuscation, you need to add corresponding exclusion rules in the obfuscation rule configuration file obfuscation-rules.txt: +``` +-keep +./oh_modules/@ohos/pinyin4js +``` + ## How to Contribute If you find any problem when using the project, submit an [Issue](https://gitee.com/openharmony-tpc/pinyin4js/issues) or a [PR](https://gitee.com/openharmony-tpc/pinyin4js/pulls) to us. diff --git a/README_zh.md b/README_zh.md index 0211d64..5e34bc6 100644 --- a/README_zh.md +++ b/README_zh.md @@ -74,6 +74,15 @@ ohpm install @ohos/pinyin4js DevEco Studio版本: Deveco Studio:4.0 (4.0.3.512),SDK:API10 (4.0.10.9) +## 关于混淆 +- 代码混淆,请查看[代码混淆简介](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/arkts-utils/source-obfuscation.md) +- 如果希望pinyin4js库在代码混淆过程中不会被混淆,需要在混淆规则配置文件obfuscation-rules.txt中添加相应的排除规则: + +``` +-keep +./oh_modules/@ohos/pinyin4js +``` + ## 贡献代码 使用过程中发现任何问题都可以提 [Issue](https://gitee.com/openharmony-tpc/pinyin4js/issues) 给组件,当然,也非常欢迎给发 [PR](https://gitee.com/openharmony-tpc/pinyin4js/pulls)共建 。 diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index f8f0340..f0b27c7 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -1,7 +1,21 @@ { "apiType": 'stageMode', - "buildOption": { - }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + // 混淆规则文件 + ] + } + } + } + } + ], "targets": [ { "name": "default" diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000..0aa2612 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,26 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -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 + +-keep +./oh_modules/@ohos/pinyin4js \ No newline at end of file -- Gitee