@ohos-cpf/3rdloop 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -0
- package/lib/cli.js +22 -5
- package/lib/doctor.js +111 -10
- package/lib/mcp.js +498 -0
- package/package.json +6 -2
- package/vendor/Archive/data/.index/meta.json +7 -0
- package/vendor/Archive/data/.index/search.db +0 -0
- package/vendor/Archive/data/docs/experiences/arkts-check-tool-pitfalls-baseline-comparison.md +13 -0
- package/vendor/Archive/data/docs/experiences/arkts-deep-path-import-recognition.md +31 -0
- package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-entry-file-case-mismatch.md +25 -0
- package/vendor/Archive/data/docs/experiences/arkts-demo-coverage-import-trailing-slash.md +20 -0
- package/vendor/Archive/data/docs/experiences/arkts-library-source-files-may-be-ts.md +18 -0
- package/vendor/Archive/data/docs/experiences/arkts-typedarray-buffer-interface-cast-compile-fixes.md +36 -0
- package/vendor/Archive/data/docs/experiences/arkts-xts-compile-error-clustering-fix.md +24 -0
- package/vendor/Archive/data/docs/experiences/arkts-xts-doc-expected-value-runtime-probe.md +35 -0
- package/vendor/Archive/data/docs/experiences/arkts-xts-fixture-rawfile-testability-injection.md +33 -0
- package/vendor/Archive/data/docs/experiences/code-linter-chinese-comment-false-positive.md +16 -0
- package/vendor/Archive/data/docs/experiences/esobject-new-expression-variable-tracking.md +33 -0
- package/vendor/Archive/data/docs/experiences/filesystem-case-sensitivity-module-resolution.md +31 -0
- package/vendor/Archive/data/docs/experiences/gitcode-clone-redirect-warning-normal.md +13 -0
- package/vendor/Archive/data/docs/experiences/kn_msgvq1w585ec8319.md +77 -0
- package/vendor/Archive/data/docs/experiences/kn_msovnm6rd46de72c.md +98 -0
- package/vendor/Archive/data/docs/experiences/kn_mspt8vntfe708576.md +87 -0
- package/vendor/Archive/data/docs/experiences/kn_mspu1ei77adbbb48.md +133 -0
- package/vendor/Archive/data/docs/experiences/kn_mspubgak8d30bfce.md +128 -0
- package/vendor/Archive/data/docs/experiences/kn_mspug2de3cb1f7c3.md +115 -0
- package/vendor/Archive/data/docs/experiences/kn_skill_opt_001.md +38 -0
- package/vendor/Archive/data/docs/experiences/loop-artifacts-verification-evidence-triangle.md +19 -0
- package/vendor/Archive/data/docs/experiences/macos-bash-replace-build-ps1.md +19 -0
- package/vendor/Archive/data/docs/experiences/macos-bsd-diff-q-illegal-option.md +15 -0
- package/vendor/Archive/data/docs/experiences/migrate-cjs-compatible-api-version-map-limit.md +17 -0
- package/vendor/Archive/data/docs/experiences/mp3agic-arkts-library-behavior-quirks.md +21 -0
- package/vendor/Archive/data/docs/experiences/ohos-face-detection-scan-api-mapping.md +15 -0
- package/vendor/Archive/data/docs/experiences/pr-metadata-and-diff-integrity-verification.md +12 -0
- package/vendor/Archive/data/docs/experiences/rn-coverage-index-signature-pseudo-member-false-negative.md +32 -0
- package/vendor/Archive/data/docs/experiences/rn-memory-check-severity-calibration.md +21 -0
- package/vendor/Archive/data/docs/experiences/rn-platform-specific-api-exclusion-evidence.md +24 -0
- package/vendor/Archive/data/docs/experiences/rn-upstream-version-diff-pitfalls.md +17 -0
- package/vendor/Archive/data/docs/experiences/rn-version-gap-risk-rating-rules.md +13 -0
- package/vendor/Archive/data/docs/experiences/rn-view-lib-native-contract-diff-fabric-spec.md +16 -0
- package/vendor/Archive/data/docs/experiences/rnoh-adapter-package-version-field-semantics.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-arkts-sqlite-rows-array-format.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-dependency-residue-scan-strategy.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-local-lib-dep-use-tgz.md +53 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-prereserve-rntesterlist.md +17 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-template-compatiblesdkversion-upgrade.md +29 -0
- package/vendor/Archive/data/docs/experiences/rnoh-example-turbomodule-shell-adaptation-checklist.md +41 -0
- package/vendor/Archive/data/docs/experiences/rnoh-mcp-build-project-tool-risk.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-npm-devdependencies-version-precheck.md +29 -0
- package/vendor/Archive/data/docs/experiences/rnoh-repo-baseline-version-verification.md +13 -0
- package/vendor/Archive/data/docs/experiences/rnoh-repo-upstream-directory-mapping.md +18 -0
- package/vendor/Archive/data/docs/experiences/rnoh-stateless-library-zero-leak-verification.md +31 -0
- package/vendor/Archive/data/docs/experiences/rnoh-template-npmrc-credential-removal.md +15 -0
- package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-codegen-wiring-verification.md +19 -0
- package/vendor/Archive/data/docs/experiences/rnoh-turbomodule-cpp-methodmap-compatibility-check.md +20 -0
- package/vendor/Archive/data/docs/experiences/scenario-doc-vs-source-signature-diff-four-patterns.md +24 -0
- package/vendor/Archive/data/docs/experiences/static-analysis-grep-cross-validation.md +29 -0
- package/vendor/Archive/demo.js +489 -0
- package/vendor/Archive/index.js +43 -0
- package/vendor/Archive/package.json +16 -0
- package/vendor/Archive/src/constants.js +83 -0
- package/vendor/Archive/src/data/stopwords.txt +110 -0
- package/vendor/Archive/src/data/synonyms.json +25 -0
- package/vendor/Archive/src/data/terms.txt +59 -0
- package/vendor/Archive/src/db/sqlite-backend.js +312 -0
- package/vendor/Archive/src/db/sqlite-schema.js +64 -0
- package/vendor/Archive/src/engine.js +501 -0
- package/vendor/Archive/src/index/index-manager.js +203 -0
- package/vendor/Archive/src/index/index-state.js +94 -0
- package/vendor/Archive/src/index/search-text-builder.js +106 -0
- package/vendor/Archive/src/index.js +22 -0
- package/vendor/Archive/src/parser/api-identifiers.js +121 -0
- package/vendor/Archive/src/parser/api-suffixes.js +48 -0
- package/vendor/Archive/src/parser/heading-normalize.js +40 -0
- package/vendor/Archive/src/parser/markdown-splitter.js +215 -0
- package/vendor/Archive/src/search/catalog-routing.js +87 -0
- package/vendor/Archive/src/search/fts-search.js +289 -0
- package/vendor/Archive/src/search/query-normalizer.js +159 -0
- package/vendor/Archive/src/search/query-rewriter.js +72 -0
- package/vendor/Archive/src/search/search-engine.js +72 -0
- package/vendor/Archive/src/search/snippet.js +64 -0
- package/vendor/Archive/src/store/dir-store.js +103 -0
- package/vendor/Archive/src/store/doc-store.js +36 -0
- package/vendor/Archive/src/tokenizer/lexicon.js +151 -0
- package/vendor/Archive/src/tokenizer/tokenizer.js +167 -0
- package/vendor/Archive/src/types.js +86 -0
- package/vendor/Archive/src/utils/hash.js +16 -0
- package/vendor/Archive/src/utils/lock.js +73 -0
- package/vendor/Archive/src/utils/path-safety.js +96 -0
- package/vendor/Archive/src/utils/paths.js +39 -0
- package/vendor/BadCase/rn/INDEX.md +127 -0
- package/vendor/BadCase/rn/cases/KI-001-webview/350/247/206/351/242/221/346/227/240/346/263/225/346/250/252/345/261/217.md +52 -0
- package/vendor/BadCase/rn/cases/KI-002-fastImage/347/203/255/346/233/264/346/226/260/345/233/276/347/211/207/345/244/261/350/264/245.md +37 -0
- package/vendor/BadCase/rn/cases/KI-003-wechat/347/274/251/347/225/245/345/233/276/346/234/254/345/234/260/345/233/276/347/211/207.md +62 -0
- package/vendor/BadCase/rn/cases/KI-004-wechat/345/233/236/350/260/203/346/227/266/345/272/217.md +47 -0
- package/vendor/BadCase/rn/cases/KI-005-geolocation/345/257/274/345/205/245/350/267/257/345/276/204/345/220/216/347/274/200.md +31 -0
- package/vendor/BadCase/rn/cases/KI-006-SmartRefreshLayout/346/231/272/350/203/275/346/214/207/351/222/210/345/264/251/346/272/203.md +55 -0
- package/vendor/BadCase/rn/cases/KI-007-orientation-locker/344/274/240/346/204/237/345/231/250/345/210/235/345/247/213/345/214/226.md +58 -0
- package/vendor/BadCase/rn/cases/KI-008-orientation-locker/344/274/240/346/204/237/345/231/250/345/274/225/347/224/250/350/256/241/346/225/260.md +47 -0
- package/vendor/BadCase/rn/cases/KI-009-pager-view/345/265/214/345/245/227/346/273/221/345/212/250.md +38 -0
- package/vendor/BadCase/rn/cases/KI-010-screens/346/211/213/345/212/277/345/206/262/347/252/201.md +48 -0
- package/vendor/BadCase/rn/cases/KI-011-spring-scrollview/346/211/213/345/212/277/351/207/215/345/244/215/347/273/221/345/256/232.md +49 -0
- package/vendor/BadCase/rn/cases/KI-012-qr-camera/346/250/252/345/261/217/351/200/202/351/205/215.md +59 -0
- package/vendor/BadCase/rn/cases/KI-013-webview/346/267/261/350/211/262/346/250/241/345/274/217/350/203/214/346/231/257/350/211/262.md +37 -0
- package/vendor/BadCase/rn/cases/KI-014-amap-geolocation/345/233/236/350/260/203/347/274/272/345/244/261.md +42 -0
- package/vendor/BadCase/rn/cases/KI-015-reanimated/350/277/220/350/241/214/346/227/266/346/236/220/346/236/204/345/264/251/346/272/203.md +54 -0
- package/vendor/BadCase/rn/cases/KI-016-fs/346/226/207/344/273/266/350/257/273/345/217/226/347/274/226/347/240/201.md +58 -0
- package/vendor/BadCase/rn/cases/KI-017-blob-util/345/217/202/346/225/260/347/274/226/347/240/201/351/224/231/350/257/257.md +39 -0
- package/vendor/BadCase/rn/cases/KI-018-modal/345/274/271/347/252/227/351/227/252/347/203/201.md +53 -0
- package/vendor/BadCase/rn/cases/KI-019-code-push/351/207/215/345/220/257/351/200/273/350/276/221/345/244/261/346/225/210.md +79 -0
- package/vendor/BadCase/rn/cases/KI-020-netinfo/346/225/217/346/204/237/344/277/241/346/201/257/346/263/204/351/234/262.md +60 -0
- package/vendor/BadCase/rn/cases/KI-021-video/346/234/254/345/234/260/350/247/206/351/242/221/346/222/255/346/224/276/345/274/202/345/270/270.md +79 -0
- package/vendor/BadCase/rn/cases/KI-022-audio-recorder-player/346/236/232/344/270/276/347/274/272/345/244/261.md +38 -0
- package/vendor/BadCase/rn/cases/KI-023-svg/346/270/220/345/217/230/347/273/247/346/211/277/345/244/261/346/225/210.md +62 -0
- package/vendor/BadCase/rn/generalization-log.md +55 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.json +328 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-SmartRefreshLayout-32.md +382 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.json +1351 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-amap-geolocation-27.md +1176 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.json +538 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-audio-recorder-player-22.md +1488 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.json +211 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-blob-util-23.md +35 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.json +2048 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-code-push-17.md +3866 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fast-image-102.md +40 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.json +751 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-fs-38.md +883 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.json +1544 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-geolocation-24.md +2598 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.json +246 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-modal-20.md +554 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.json +211 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-netinfo-31.md +54 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.json +1626 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-45.md +2213 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.json +208 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-orientation-locker-51.md +77 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.json +377 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-pager-view-32.md +174 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.json +232 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-qr-decode-image-camera-37.md +194 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-reanimated-82.md +67 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-87.md +38 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.json +208 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-screens-93.md +34 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.json +222 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-spring-scrollview-38.md +56 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.json +463 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-svg-117.md +383 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.json +464 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-video-66.md +565 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.json +198 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-112.md +47 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.json +232 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-webview-121.md +422 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.json +295 -0
- package/vendor/BadCase/rn/pr-info/rntpc_react-native-wechat-lib-15.md +1038 -0
- package/vendor/BadCase/rn/rules/R-01-/345/205/250/345/261/217/347/252/227/345/217/243/347/212/266/346/200/201/347/256/241/347/220/206/345/256/214/346/225/264/346/200/247.md +20 -0
- package/vendor/BadCase/rn/rules/R-02-/350/265/204/346/272/220URI/345/275/242/346/200/201/345/210/206/346/224/257/350/246/206/347/233/226.md +21 -0
- package/vendor/BadCase/rn/rules/R-03-/351/231/204/345/261/236/346/223/215/344/275/234/345/244/261/350/264/245/351/230/273/346/226/255/344/270/273/346/265/201/347/250/213.md +20 -0
- package/vendor/BadCase/rn/rules/R-04-/345/274/202/346/255/245/345/233/236/350/260/203/346/263/250/345/206/214/346/227/266/345/272/217.md +20 -0
- package/vendor/BadCase/rn/rules/R-05-/346/250/241/345/235/227/345/257/274/345/205/245/350/267/257/345/276/204/350/247/204/350/214/203.md +19 -0
- package/vendor/BadCase/rn/rules/R-06-/344/274/240/346/204/237/345/231/250/347/241/254/344/273/266/346/235/203/351/231/220/346/214/211/351/234/200/350/216/267/345/217/226.md +21 -0
- package/vendor/BadCase/rn/rules/R-07-/346/231/272/350/203/275/346/214/207/351/222/210/347/224/237/345/221/275/345/221/250/346/234/237/347/256/241/347/220/206.md +20 -0
- package/vendor/BadCase/rn/rules/R-08-/346/211/213/345/212/277/344/272/213/344/273/266/346/263/250/345/206/214/344/270/216/345/206/262/347/252/201/345/244/204/347/220/206.md +22 -0
- package/vendor/BadCase/rn/rules/R-09-/346/250/252/347/253/226/345/261/217/345/244/232/345/275/242/346/200/201/345/270/203/345/261/200/351/200/202/351/205/215.md +20 -0
- package/vendor/BadCase/rn/rules/R-10-/346/267/261/350/211/262/346/250/241/345/274/217/344/270/273/351/242/230/351/242/234/350/211/262/351/200/202/351/205/215.md +19 -0
- package/vendor/BadCase/rn/rules/R-11-/346/216/245/345/217/243/345/233/236/350/260/203/345/256/236/347/216/260/345/256/214/346/225/264/346/200/247.md +20 -0
- package/vendor/BadCase/rn/rules/R-12-/345/216/237/347/224/237/350/277/220/350/241/214/346/227/266/350/265/204/346/272/220/346/236/220/346/236/204/346/227/266/345/272/217.md +20 -0
- package/vendor/BadCase/rn/rules/R-13-/346/226/207/344/273/266/346/225/260/346/215/256/347/274/226/347/240/201/344/270/216/346/240/274/345/274/217/345/205/274/345/256/271.md +21 -0
- package/vendor/BadCase/rn/rules/R-14-/345/212/250/347/224/273/345/210/235/345/247/213/345/214/226/346/227/266/345/272/217/344/270/216/347/212/266/346/200/201/345/220/214/346/255/245.md +20 -0
- package/vendor/BadCase/rn/rules/R-15-/347/212/266/346/200/201/346/214/201/344/271/205/345/214/226/344/270/216/351/207/215/345/220/257/351/200/273/350/276/221/344/270/200/350/207/264/346/200/247.md +20 -0
- package/vendor/BadCase/rn/rules/R-16-/346/225/217/346/204/237/344/277/241/346/201/257/346/227/245/345/277/227/346/263/204/351/234/262.md +19 -0
- package/vendor/BadCase/rn/rules/R-17-/345/252/222/344/275/223/350/265/204/346/272/220/347/224/237/345/221/275/345/221/250/346/234/237/344/270/216/351/224/231/350/257/257/345/244/204/347/220/206.md +21 -0
- package/vendor/BadCase/rn/rules/R-18-/350/203/275/345/212/233/346/236/232/344/270/276/351/205/215/347/275/256/345/256/214/346/225/264/346/200/247.md +19 -0
- package/vendor/BadCase/rn/rules/R-19-/345/233/276/345/275/242/346/270/262/346/237/223/345/261/236/346/200/247/347/273/247/346/211/277/344/270/216/351/207/215/347/275/256.md +19 -0
- package/vendor/MCP/README.md +490 -0
- package/vendor/MCP/config.json +29 -0
- package/vendor/MCP/package.json +23 -0
- package/vendor/MCP/scripts/analyze-demo-coverage.cjs +1203 -0
- package/vendor/MCP/scripts/analyze-xts-coverage.cjs +1245 -0
- package/vendor/MCP/scripts/deveco_docs.js +247 -0
- package/vendor/MCP/scripts/extract-interfaces.cjs +1487 -0
- package/vendor/MCP/scripts/flutter-analyze-demo-coverage.cjs +666 -0
- package/vendor/MCP/scripts/flutter-analyze-xts-coverage.cjs +684 -0
- package/vendor/MCP/scripts/flutter-extract-interfaces.cjs +1251 -0
- package/vendor/MCP/scripts/flutter-render-spec-doc.cjs +351 -0
- package/vendor/MCP/scripts/render-spec-doc.cjs +347 -0
- package/vendor/MCP/scripts/rn-analyze-demo-coverage.cjs +645 -0
- package/vendor/MCP/scripts/rn-analyze-test-coverage.cjs +614 -0
- package/vendor/MCP/scripts/rn-extract-interfaces.cjs +1462 -0
- package/vendor/MCP/scripts/rn-render-spec-doc.cjs +327 -0
- package/vendor/MCP/scripts/rn-scan-exports.cjs +1336 -0
- package/vendor/MCP/src/client/MCPClientPool.js +220 -0
- package/vendor/MCP/src/config/ConfigLoader.js +189 -0
- package/vendor/MCP/src/executor/ScriptExecutor.js +110 -0
- package/vendor/MCP/src/gateway/Gateway.js +451 -0
- package/vendor/MCP/src/index.js +87 -0
- package/vendor/MCP/src/library/KBToolProvider.js +229 -0
- package/vendor/MCP/src/library/logger.js +60 -0
- package/vendor/MCP/src/registry/ScriptRegistry.js +238 -0
- package/vendor/MCP/src/registry/ToolRegistry.js +111 -0
- package/vendor/MCP/src/types.js +115 -0
- package/vendor/Server/Skills/arkts-library-test-coverage-check/references/MCP_TOOL_USAGE.md +4 -2
- package/vendor/Server/Skills/arkts-library-xts-coverage/SKILL.md +3 -3
- package/vendor/Server/Skills/knowledge-import/SKILL.md +1 -1
- package/vendor/Server/Skills/knowledge-import/references/MCP_TOOL_USAGE.md +12 -4
- package/vendor/Server/Skills/ohos-lib-pr-push/SKILL.md +5 -4
- package/vendor/Server/Skills/rn-library-issue-generalizer/SKILL.md +2 -2
- package/vendor/Server/Skills/rn-library-known-issue-check/SKILL.md +2 -2
- package/vendor/Server/Skills/rnoh-lib-demo-coverage/SKILL.md +1 -2
- package/vendor/Server/Skills/rnoh-lib-test-align/references/port-test-demo-guide.md +1 -1
- package/vendor/Server/Skills/rnoh-lib-xts-coverage/SKILL.md +1 -2
- package/vendor/Server/package.json +5 -1
- package/vendor/VERSION +3 -3
|
@@ -0,0 +1,1038 @@
|
|
|
1
|
+
# PR #15: fix: 修复shareWebpage接口缩略图不支持本地图片问题
|
|
2
|
+
|
|
3
|
+
- **状态**: merged
|
|
4
|
+
- **作者**: houahui
|
|
5
|
+
- **创建时间**: 2026-07-15T14:18:32+08:00
|
|
6
|
+
- **分支**: br_rnoh0.72 → br_rnoh0.72
|
|
7
|
+
- **变更文件数**: 5
|
|
8
|
+
|
|
9
|
+
## PR 描述
|
|
10
|
+
|
|
11
|
+
fix: 修复shareWebpage接口缩略图不支持本地图片问题
|
|
12
|
+
|
|
13
|
+
## 变更文件
|
|
14
|
+
|
|
15
|
+
| 文件 | 变更 | +行 | -行 |
|
|
16
|
+
|------|------|-----|-----|
|
|
17
|
+
| `README.md` | ? | +395 | -7 |
|
|
18
|
+
| `README_en.md` | added | +400 | -0 |
|
|
19
|
+
| `harmony/react_native_wechat_lib/src/main/ets/WechatLibTurboModule.ets` | ? | +66 | -41 |
|
|
20
|
+
| `package.json` | ? | +2 | -1 |
|
|
21
|
+
| `src/index.ts` | ? | +11 | -2 |
|
|
22
|
+
|
|
23
|
+
## Diff
|
|
24
|
+
|
|
25
|
+
### `README.md`
|
|
26
|
+
|
|
27
|
+
```diff
|
|
28
|
+
@@ -1,13 +1,401 @@
|
|
29
|
+
-# @react-native-ohos/react-native-wechat-lib
|
|
30
|
+
+> 模板版本:v0.4.0
|
|
31
|
+
|
|
32
|
+
-This project is based on [react-native-wechat-lib@v3.0.0](https://github.com/little-snow-fox/react-native-wechat-lib/tree/v3.0.0)
|
|
33
|
+
+<p align="center">
|
|
34
|
+
+ <h1 align="center"> <code>react-native-wechat-lib</code> </h1>
|
|
35
|
+
+</p>
|
|
36
|
+
+<p align="center">
|
|
37
|
+
+ <a href="https://github.com/little-snow-fox/react-native-wechat-lib">
|
|
38
|
+
+ <img src="https://img.shields.io/badge/platforms-android%20|%20ios%20|%20harmony%20-lightgrey.svg" alt="Supported platforms" />
|
|
39
|
+
+ </a>
|
|
40
|
+
+ <a href="https://github.com/little-snow-fox/react-native-wechat-lib/blob/master/LICENSE">
|
|
41
|
+
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
|
|
42
|
+
+ <!-- <img src="https://img.shields.io/badge/license-Apache-blue.svg" alt="License" /> -->
|
|
43
|
+
+ </a>
|
|
44
|
+
+</p>
|
|
45
|
+
|
|
46
|
+
-## Documentation
|
|
47
|
+
+本项目基于 [原库react-native-wechat-lib](https://github.com/little-snow-fox/react-native-wechat-lib) 开发。
|
|
48
|
+
|
|
49
|
+
-- [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-wechat-lib.md)
|
|
50
|
+
+该第三方库的仓库支持直接从 npm 下载,新的包名为:@react-native-ohos/react-native-wechat-lib 版本所属关系如下:
|
|
51
|
+
+| 三方库名称 | 三方库版本 | 发布信息 | 支持RN版本 | Autolink | 编译API版本 | 社区基线版本 | npm地址 |
|
|
52
|
+
+| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
|
|
53
|
+
+| @react-native-ohos/react-native-wechat-lib | ~3.2.0(开发中) | [Github Releases](https://github.com/react-native-oh-library/react-native-wechat-lib/releases) | 0.82.* | 是 | API12+ | 3.0.4 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-wechat-lib?activeTab=versions) |
|
|
54
|
+
+| @react-native-ohos/react-native-wechat-lib | ~3.1.0 | [Github Releases](https://github.com/react-native-oh-library/react-native-wechat-lib/releases) | 0.77.* | 否 | API12+ | 3.0.4 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-wechat-lib?activeTab=versions) |
|
|
55
|
+
+| @react-native-ohos/react-native-wechat-lib | ~3.0.6 | [Github Releases](https://github.com/react-native-oh-library/react-native-wechat-lib/releases) | 0.72.* | 是 | API12+ | 3.0.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-wechat-lib?activeTab=versions) |
|
|
56
|
+
|
|
57
|
+
-- [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-wechat-lib.md)
|
|
58
|
+
+## 1. 安装与使用
|
|
59
|
+
|
|
60
|
+
-## License
|
|
61
|
+
+进入到工程目录并输入以下命令:
|
|
62
|
+
|
|
63
|
+
-This library is licensed under [The MIT License (MIT)](https://github.com/react-native-oh-library/react-native-wechat-lib/blob/sig/License)
|
|
64
|
+
+<!-- tabs:start -->
|
|
65
|
+
+
|
|
66
|
+
+#### **npm**
|
|
67
|
+
+
|
|
68
|
+
+```bash
|
|
69
|
+
+npm install @react-native-ohos/react-native-wechat-lib
|
|
70
|
+
+```
|
|
71
|
+
+
|
|
72
|
+
+#### **yarn**
|
|
73
|
+
+
|
|
74
|
+
+```bash
|
|
75
|
+
+yarn add @react-native-ohos/react-native-wechat-lib
|
|
76
|
+
+```
|
|
77
|
+
+
|
|
78
|
+
+<!-- tabs:end -->
|
|
79
|
+
+
|
|
80
|
+
+下面的代码展示了这个库的基本使用场景:
|
|
81
|
+
+
|
|
82
|
+
+> [!WARNING] 使用时 import 的库名不变。
|
|
83
|
+
+
|
|
84
|
+
+> [tips] 下面 demo 在使用的过程中,请将 AppID 改为在[微信开放平台申请鸿蒙应用](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/ohos.html)的 AppID
|
|
85
|
+
+
|
|
86
|
+
+```js
|
|
87
|
+
+import * as React from 'react';
|
|
88
|
+
+
|
|
89
|
+
+import { StyleSheet, View, Text, Button, Alert } from 'react-native';
|
|
90
|
+
+import { getApiVersion, registerApp, openWXApp, sendAuthRequest, shareText } from 'react-native-wechat-lib';
|
|
91
|
+
+
|
|
92
|
+
+export default function App() {
|
|
93
|
+
+ const [versionNumber, setVersionNumber] = React.useState<string | undefined>();
|
|
94
|
+
+
|
|
95
|
+
+ React.useEffect(() => {
|
|
96
|
+
+ registerApp('AppID', 'universalLink').then((res) => {
|
|
97
|
+
+ console.log("registerApp: " + res)
|
|
98
|
+
+ });
|
|
99
|
+
+
|
|
100
|
+
+ }, []);
|
|
101
|
+
+
|
|
102
|
+
+ function onLogin() {
|
|
103
|
+
+ sendAuthRequest('snsapi_userinfo', '')
|
|
104
|
+
+ .then((response: any) => {
|
|
105
|
+
+ Alert.alert('登录成功,code: ' + response.code)
|
|
106
|
+
+ })
|
|
107
|
+
+ .catch(error => {
|
|
108
|
+
+ console.log(error)
|
|
109
|
+
+ let errorCode = Number(error.code);
|
|
110
|
+
+ if (errorCode === -2) {
|
|
111
|
+
+ Alert.alert('已取消授权登录')
|
|
112
|
+
+ } else {
|
|
113
|
+
+ Alert.alert('微信授权登录失败')
|
|
114
|
+
+ }
|
|
115
|
+
+ });
|
|
116
|
+
+
|
|
117
|
+
+ }
|
|
118
|
+
+
|
|
119
|
+
+ function onShareText() {
|
|
120
|
+
+ shareText({
|
|
121
|
+
+ text: 'test content.',
|
|
122
|
+
+ scene: 0
|
|
123
|
+
+ }).then()
|
|
124
|
+
+ }
|
|
125
|
+
+
|
|
126
|
+
+ return (
|
|
127
|
+
+ <View style={styles.container}>
|
|
128
|
+
+ <Text style={styles.title}>Call wechat SDK demo</Text>
|
|
129
|
+
+ <Text style={styles.versionBox}>
|
|
130
|
+
+ Version: {versionNumber}
|
|
131
|
+
+ </Text>
|
|
132
|
+
+ <View style={styles.buttonGroup}>
|
|
133
|
+
+ <View style={styles.button}>
|
|
134
|
+
+ <Button title={'拉起微信'} onPress={() => { openWXApp().then() }} />
|
|
135
|
+
+ </View>
|
|
136
|
+
+ <View style={styles.button}>
|
|
137
|
+
+ <Button title={'授权登录'} onPress={() => { onLogin() }} />
|
|
138
|
+
+ </View>
|
|
139
|
+
+ <View style={styles.button}>
|
|
140
|
+
+ <Button title={'分享'} onPress={() => { onShareText() }} />
|
|
141
|
+
+ </View>
|
|
142
|
+
+ </View>
|
|
143
|
+
+ </View>
|
|
144
|
+
+ );
|
|
145
|
+
+}
|
|
146
|
+
+
|
|
147
|
+
+const styles = StyleSheet.create({
|
|
148
|
+
+ container: {
|
|
149
|
+
+ width: '100%',
|
|
150
|
+
+ // flex: 1,
|
|
151
|
+
+ alignItems: 'center',
|
|
152
|
+
+ // justifyContent: 'center',
|
|
153
|
+
+ },
|
|
154
|
+
+ box: {
|
|
155
|
+
+ width: 60,
|
|
156
|
+
+ height: 60,
|
|
157
|
+
+ marginVertical: 20,
|
|
158
|
+
+ },
|
|
159
|
+
+ title: {
|
|
160
|
+
+ marginTop: 48,
|
|
161
|
+
+ fontSize: 24,
|
|
162
|
+
+ color: 'rgba(0, 0, 0, 0.6)',
|
|
163
|
+
+ },
|
|
164
|
+
+ versionBox: {
|
|
165
|
+
+ color: 'rgba(0, 0, 0, 0.6)'
|
|
166
|
+
+ },
|
|
167
|
+
+ buttonGroup: {
|
|
168
|
+
+ width: '100%',
|
|
169
|
+
+ padding: 6,
|
|
170
|
+
+ marginTop: 24,
|
|
171
|
+
+ },
|
|
172
|
+
+ button: {
|
|
173
|
+
+ margin: 6,
|
|
174
|
+
+
|
|
175
|
+
+ }
|
|
176
|
+
+});
|
|
177
|
+
+```
|
|
178
|
+
+
|
|
179
|
+
+## 2. Link
|
|
180
|
+
+
|
|
181
|
+
+| | 是否支持autolink | RN框架版本 |
|
|
182
|
+
+|--------------------------------------|-----------------|------------|
|
|
183
|
+
+| ~3.2.0 | Yes | 0.82 |
|
|
184
|
+
+| ~3.1.0 | No | 0.77 |
|
|
185
|
+
+| ~3.0.6 | Yes | 0.72 |
|
|
186
|
+
+
|
|
187
|
+
+使用AutoLink的工程需要根据该文档配置,Autolink框架指导文档:https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
|
|
188
|
+
+
|
|
189
|
+
+如您使用的版本支持 Autolink,并且工程已接入 Autolink,可跳过ManualLink配置。
|
|
190
|
+
+<details>
|
|
191
|
+
+ <summary>ManualLink: 此步骤为手动配置原生依赖项的指导</summary>
|
|
192
|
+
+
|
|
193
|
+
+首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`。
|
|
194
|
+
+
|
|
195
|
+
+### 2.1 在工程根目录的 `oh-package.json5` 添加 overrides 字段
|
|
196
|
+
+
|
|
197
|
+
+```json
|
|
198
|
+
+{
|
|
199
|
+
+ ...
|
|
200
|
+
+ "overrides": {
|
|
201
|
+
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
|
|
202
|
+
+ }
|
|
203
|
+
+}
|
|
204
|
+
+```
|
|
205
|
+
+
|
|
206
|
+
+### 2.2 引入原生端代码
|
|
207
|
+
+
|
|
208
|
+
+目前有两种方法:
|
|
209
|
+
+
|
|
210
|
+
+1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
|
|
211
|
+
+2. 直接链接源码。
|
|
212
|
+
+
|
|
213
|
+
+方法一:通过 har 包引入(推荐)
|
|
214
|
+
+
|
|
215
|
+
+> [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
|
|
216
|
+
+
|
|
217
|
+
+打开 `entry/oh-package.json5`,添加以下依赖
|
|
218
|
+
+
|
|
219
|
+
+```json
|
|
220
|
+
+"dependencies": {
|
|
221
|
+
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
|
|
222
|
+
+ "@react-native-ohos/react-native-wechat-lib": "file:../../node_modules/@react-native-ohos/react-native-wechat-lib/harmony/react_native_wechat_lib.har"
|
|
223
|
+
+ }
|
|
224
|
+
+```
|
|
225
|
+
+
|
|
226
|
+
+点击右上角的 `sync` 按钮
|
|
227
|
+
+
|
|
228
|
+
+或者在终端执行:
|
|
229
|
+
+
|
|
230
|
+
+```bash
|
|
231
|
+
+cd entry
|
|
232
|
+
+ohpm install
|
|
233
|
+
+```
|
|
234
|
+
+
|
|
235
|
+
+方法二:直接链接源码
|
|
236
|
+
+
|
|
237
|
+
+> [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](./link-source-code.md)
|
|
238
|
+
+
|
|
239
|
+
+### 2.3 配置 CMakeLists 和引入 RNWechatLibPackage
|
|
240
|
+
+
|
|
241
|
+
+打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
|
|
242
|
+
+
|
|
243
|
+
+```diff
|
|
244
|
+
+project(rnapp)
|
|
245
|
+
+cmake_minimum_required(VERSION 3.4.1)
|
|
246
|
+
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
|
247
|
+
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
248
|
+
+set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
|
|
249
|
+
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
250
|
+
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
|
|
251
|
+
+set(LOG_VERBOSITY_LEVEL 1)
|
|
252
|
+
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
|
|
253
|
+
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
|
|
254
|
+
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
|
|
255
|
+
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
|
|
256
|
+
+
|
|
257
|
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
|
258
|
+
+
|
|
259
|
+
+# RNOH_BEGIN: manual_package_linking_1
|
|
260
|
+
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
|
|
261
|
+
++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-wechat-lib/src/main/cpp" ./wechat-lib)
|
|
262
|
+
+# RNOH_END: manual_package_linking_1
|
|
263
|
+
+
|
|
264
|
+
+file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
|
|
265
|
+
+
|
|
266
|
+
+add_library(rnoh_app SHARED
|
|
267
|
+
+ ${GENERATED_CPP_FILES}
|
|
268
|
+
+ "./PackageProvider.cpp"
|
|
269
|
+
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
|
270
|
+
+)
|
|
271
|
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
|
|
272
|
+
+
|
|
273
|
+
+# RNOH_BEGIN: manual_package_linking_2
|
|
274
|
+
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
|
|
275
|
+
++ target_link_libraries(rnoh_app PUBLIC wechat_lib)
|
|
276
|
+
+# RNOH_END: manual_package_linking_2
|
|
277
|
+
+```
|
|
278
|
+
+
|
|
279
|
+
+打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
|
|
280
|
+
+
|
|
281
|
+
+```diff
|
|
282
|
+
+#include "RNOH/PackageProvider.h"
|
|
283
|
+
+#include "generated/RNOHGeneratedPackage.h"
|
|
284
|
+
+#include "SamplePackage.h"
|
|
285
|
+
++ #include "RNWechatLibPackage.h"
|
|
286
|
+
+
|
|
287
|
+
+using namespace rnoh;
|
|
288
|
+
+
|
|
289
|
+
+std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
|
|
290
|
+
+ return {
|
|
291
|
+
+ std::make_shared<RNOHGeneratedPackage>(ctx),
|
|
292
|
+
+ std::make_shared<SamplePackage>(ctx),
|
|
293
|
+
++ std::make_shared<RNWechatLibPackage>(ctx),
|
|
294
|
+
+ };
|
|
295
|
+
+}
|
|
296
|
+
+```
|
|
297
|
+
+
|
|
298
|
+
+### 2.4 在 ArkTs 侧引入 WechatLibPackage
|
|
299
|
+
+
|
|
300
|
+
+打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
|
|
301
|
+
+
|
|
302
|
+
+```diff
|
|
303
|
+
+ ...
|
|
304
|
+
++ import { WechatLibPackage } from '@react-native-ohos/react-native-wechat-lib/ts';
|
|
305
|
+
+
|
|
306
|
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
|
307
|
+
+ return [
|
|
308
|
+
+ new SamplePackage(ctx),
|
|
309
|
+
++ new WechatLibPackage(ctx),
|
|
310
|
+
+ ];
|
|
311
|
+
+}
|
|
312
|
+
+```
|
|
313
|
+
+</details>
|
|
314
|
+
+
|
|
315
|
+
+### 2.5 必要的配置项
|
|
316
|
+
+
|
|
317
|
+
+> [!TIP] 该模块的内容无法通过autolink自动生成,始终需要手动配置。
|
|
318
|
+
+
|
|
319
|
+
+#### 2.5.1 配置 EntryAbility(该模块始终需要手动配置)
|
|
320
|
+
+
|
|
321
|
+
+鸿蒙工程下 EntryAbility,一般位于 `entry\src\main\ets\entryability\EntryAbility.ets`
|
|
322
|
+
+
|
|
323
|
+
+```diff
|
|
324
|
+
+import {RNAbility} from '@rnoh/react-native-openharmony';
|
|
325
|
+
++ import { AbilityConstant, Want } from '@kit.AbilityKit';
|
|
326
|
+
++ import { WechatLibTurboModule } from '@react-native-ohos/react-native-wechat-lib';
|
|
327
|
+
+
|
|
328
|
+
+export default class EntryAbility extends RNAbility {
|
|
329
|
+
+
|
|
330
|
+
++ onCreate(want: Want) {
|
|
331
|
+
++ super.onCreate(want)
|
|
332
|
+
++ this.handleWeChatCallIfNeed(want)
|
|
333
|
+
++ }
|
|
334
|
+
+
|
|
335
|
+
+ getPagePath() {
|
|
336
|
+
+ return 'pages/Index';
|
|
337
|
+
+ }
|
|
338
|
+
+
|
|
339
|
+
++ onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void {
|
|
340
|
+
++ this.handleWeChatCallIfNeed(want)
|
|
341
|
+
++ }
|
|
342
|
+
+
|
|
343
|
+
++ private handleWeChatCallIfNeed(want: Want) {
|
|
344
|
+
++ WechatLibTurboModule.handleWant(want)
|
|
345
|
+
++ }
|
|
346
|
+
+}
|
|
347
|
+
+
|
|
348
|
+
+```
|
|
349
|
+
+
|
|
350
|
+
+#### 2.5.2 配置 module.json5(该模块始终需要手动配置)
|
|
351
|
+
+
|
|
352
|
+
+打开 `entry/src/main/module.json5`,添加:
|
|
353
|
+
+
|
|
354
|
+
+```diff
|
|
355
|
+
+{
|
|
356
|
+
+ "module": {
|
|
357
|
+
+ "name": "entry",
|
|
358
|
+
+ "type": "entry",
|
|
359
|
+
+ "description": "$string:module_desc",
|
|
360
|
+
+ "mainElement": "EntryAbility",
|
|
361
|
+
+ "deviceTypes": [
|
|
362
|
+
+ "default"
|
|
363
|
+
+ ],
|
|
364
|
+
++ "querySchemes": [
|
|
365
|
+
++ "weixin",
|
|
366
|
+
++ ],
|
|
367
|
+
+ ...
|
|
368
|
+
+ }
|
|
369
|
+
+}
|
|
370
|
+
+```
|
|
371
|
+
+
|
|
372
|
+
+### 2.6 运行
|
|
373
|
+
+
|
|
374
|
+
+点击右上角的 `sync` 按钮
|
|
375
|
+
+
|
|
376
|
+
+或者在终端执行:
|
|
377
|
+
+
|
|
378
|
+
+```bash
|
|
379
|
+
+cd entry
|
|
380
|
+
+ohpm install
|
|
381
|
+
+```
|
|
382
|
+
+
|
|
383
|
+
+然后编译、运行即可。
|
|
384
|
+
+
|
|
385
|
+
+## 3. 约束与限制
|
|
386
|
+
+
|
|
387
|
+
+### 3.1 兼容性
|
|
388
|
+
+
|
|
389
|
+
+要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
|
|
390
|
+
+
|
|
391
|
+
+在以下版本验证通过:
|
|
392
|
+
+
|
|
393
|
+
+1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
394
|
+
+2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71;
|
|
395
|
+
+3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
396
|
+
+4. RNOH: 0.82.7; SDK: HarmonyOS 6.0.1 Release SDK; IDE: DevEco Studio 6.0.1 Release; ROM: 6.0.0.328 SP26;
|
|
397
|
+
+
|
|
398
|
+
+## 4. API
|
|
399
|
+
+
|
|
400
|
+
+> [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
|
|
401
|
+
+
|
|
402
|
+
+> [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
|
|
403
|
+
+
|
|
404
|
+
+> [!TIP] 移动应用跳转至小程序的规则,[请见APP拉起小程序的功能介绍](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html)
|
|
405
|
+
+
|
|
406
|
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
407
|
+
+| --------------------------------------------- | ------------------ | -------- | -------- | ----------- | ----------------- |
|
|
408
|
+
+| registerApp(appid) | 注册 | Function | no | Android/iOS | yes |
|
|
409
|
+
+| isWXAppInstalled() | 判断微信是否已安装 | Function | no | Android/iOS | yes |
|
|
410
|
+
+| isWXAppSupportApi() | 检查支持情况 | Function | no | Android/iOS | no |
|
|
411
|
+
+| getApiVersion() | 获取 API 版本号 | Function | no | Android/iOS | no |
|
|
412
|
+
+| openWXApp() | 打开微信 | Function | no | Android/iOS | yes |
|
|
413
|
+
+| sendAuthRequest([scope[, state]]) | 微信授权登录 | Function | no | Android/iOS | yes |
|
|
414
|
+
+| shareText(ShareTextMetadata) | 分享/收藏 文本 | Function | no | Android/iOS | partially(Session、Timeline) |
|
|
415
|
+
+| shareImage(ShareImageMetadata) | 分享/收藏 图片 | Function | no | Android/iOS | partially(Session、Timeline) |
|
|
416
|
+
+| shareLocalImage(ShareImageMetadata) | 分享/收藏 本地图片 | Function | no | Android/iOS | partially(Session、Timeline) |
|
|
417
|
+
+| shareFile(ShareFileMetadata) | 分享文件 | Function | no | Android/iOS | partially(Session) |
|
|
418
|
+
+| shareMusic(ShareMusicMetadata) | 分享音频 | Function | no | Android/iOS | no |
|
|
419
|
+
+| shareVideo(ShareVideoMetadata) | 分享视频 | Function | no | Android/iOS | partially(Session) |
|
|
420
|
+
+| shareWebpage (ShareWebpageMetadata) | 分享网页 | Function | no | Android/iOS | partially(Session) |
|
|
421
|
+
+| shareMiniProgram(ShareMiniProgramMetadata) | 分享小程序 | Function | no | Android/iOS | partially(Session) |
|
|
422
|
+
+| launchMiniProgram (LaunchMiniProgramMetadata) | 跳到小程序 | Function | no | Android/iOS | yes |
|
|
423
|
+
+| chooseInvoice (ChooseInvoice) | 选择发票 | Function | no | Android/iOS | no |
|
|
424
|
+
+| pay(payload) | 支付 | Function | no | Android/iOS | yes |
|
|
425
|
+
+| subscribeMessage(SubscribeMessageMetadata) | 一次性订阅消息 | Function | no | Android/iOS | no |
|
|
426
|
+
+
|
|
427
|
+
+## 5. 遗留问题
|
|
428
|
+
+
|
|
429
|
+
+## 6. 其他
|
|
430
|
+
+
|
|
431
|
+
+- ShareText、ShareImage、ShareLocalImage、ShareMiniProgram、ShareFile、ShareVideo、ShareWebpage 只支持分享,不支持收藏,原因为目前微信 Open SDK 还不支持 HarmonyOS 平台的收藏
|
|
432
|
+
+- isWXAppSupportApi、getApiVersion、ShareMusic、ChooseInvoice、subscribeMessage 这些接口目前在 HarmonyOS 微信 Open SDK 还不支持
|
|
433
|
+
+
|
|
434
|
+
+## 7. 开源协议
|
|
435
|
+
+
|
|
436
|
+
+本项目基于 [The MIT License (MIT)](https://github.com/little-snow-fox/react-native-wechat-lib/blob/master/LICENSE) ,请自由地享受和参与开源。
|
|
437
|
+
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### `README_en.md`
|
|
441
|
+
|
|
442
|
+
```diff
|
|
443
|
+
@@ -0,0 +1,400 @@
|
|
444
|
+
+> Template version:v0.4.0
|
|
445
|
+
+
|
|
446
|
+
+<p align="center">
|
|
447
|
+
+ <h1 align="center"> <code>react-native-wechat-lib</code> </h1>
|
|
448
|
+
+</p>
|
|
449
|
+
+<p align="center">
|
|
450
|
+
+ <a href="https://github.com/little-snow-fox/react-native-wechat-lib">
|
|
451
|
+
+ <img src="https://img.shields.io/badge/platforms-android%20|%20ios%20|%20harmony%20-lightgrey.svg" alt="Supported platforms" />
|
|
452
|
+
+ </a>
|
|
453
|
+
+ <a href="https://github.com/little-snow-fox/react-native-wechat-lib/blob/master/LICENSE">
|
|
454
|
+
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
|
|
455
|
+
+ <!-- <img src="https://img.shields.io/badge/license-Apache-blue.svg" alt="License" /> -->
|
|
456
|
+
+ </a>
|
|
457
|
+
+</p>
|
|
458
|
+
+
|
|
459
|
+
+This project is based on [react-native-wechat-lib](https://github.com/little-snow-fox/react-native-wechat-lib).
|
|
460
|
+
+
|
|
461
|
+
+This third-party library is available for direct download from npm. The new package name is @react-native-ohos/react-native-wechat-lib. The version correspondence details are as follows:
|
|
462
|
+
+
|
|
463
|
+
+| Name | Version | Release Information | Supported RN Version | Supported Autolink | Compile API Version | Community Baseline Version | npm Address |
|
|
464
|
+
+| ------------ | ------------ | ------------------------------ | ------------- | ------------- |------------------------ | ------------- | ------------- |
|
|
465
|
+
+| @react-native-ohos/react-native-wechat-lib | ~3.2.0(In development) | [Github Releases](https://github.com/react-native-oh-library/react-native-wechat-lib/releases) | 0.82.* | Yes | API12+ | 3.0.4 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-wechat-lib?activeTab=versions) |
|
|
466
|
+
+| @react-native-ohos/react-native-wechat-lib | ~3.1.0 | [Github Releases](https://github.com/react-native-oh-library/react-native-wechat-lib/releases) | 0.77.* | No | API12+ | 3.0.4 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-wechat-lib?activeTab=versions) |
|
|
467
|
+
+| @react-native-ohos/react-native-wechat-lib | ~3.0.6 | [Github Releases](https://github.com/react-native-oh-library/react-native-wechat-lib/releases) | 0.72.* | Yes | API12+ | 3.0.0 | [Npm Address](https://www.npmjs.com/package/@react-native-ohos/react-native-wechat-lib?activeTab=versions) |
|
|
468
|
+
+
|
|
469
|
+
+## 1. Installation and Usage
|
|
470
|
+
+
|
|
471
|
+
+Go to the project directory and execute the following instruction:
|
|
472
|
+
+
|
|
473
|
+
+<!-- tabs:start -->
|
|
474
|
+
+
|
|
475
|
+
+#### **npm**
|
|
476
|
+
+
|
|
477
|
+
+```bash
|
|
478
|
+
+npm install @react-native-ohos/react-native-wechat-lib
|
|
479
|
+
+```
|
|
480
|
+
+
|
|
481
|
+
+#### **yarn**
|
|
482
|
+
+
|
|
483
|
+
+```bash
|
|
484
|
+
+yarn add @react-native-ohos/react-native-wechat-lib
|
|
485
|
+
+```
|
|
486
|
+
+
|
|
487
|
+
+<!-- tabs:end -->
|
|
488
|
+
+
|
|
489
|
+
+The following code shows the basic use scenario of the repository:
|
|
490
|
+
+
|
|
491
|
+
+> [!WARNING] The name of the imported repository remains unchanged.
|
|
492
|
+
+
|
|
493
|
+
+> [tips] When using the demo below, please change the AppID to the AppID of the HarmonyOS application applied for on the [WeChat open platform](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/ohos.html).
|
|
494
|
+
+
|
|
495
|
+
+```js
|
|
496
|
+
+import * as React from 'react';
|
|
497
|
+
+
|
|
498
|
+
+import { StyleSheet, View, Text, Button, Alert } from 'react-native';
|
|
499
|
+
+import { getApiVersion, registerApp, openWXApp, sendAuthRequest, shareText } from 'react-native-wechat-lib';
|
|
500
|
+
+
|
|
501
|
+
+export default function App() {
|
|
502
|
+
+ const [versionNumber, setVersionNumber] = React.useState<string | undefined>();
|
|
503
|
+
+
|
|
504
|
+
+ React.useEffect(() => {
|
|
505
|
+
+ registerApp('AppID', 'universalLink').then((res) => {
|
|
506
|
+
+ console.log("registerApp: " + res)
|
|
507
|
+
+ });
|
|
508
|
+
+
|
|
509
|
+
+ }, []);
|
|
510
|
+
+
|
|
511
|
+
+ function onLogin() {
|
|
512
|
+
+ sendAuthRequest('snsapi_userinfo', '')
|
|
513
|
+
+ .then((response: any) => {
|
|
514
|
+
+ Alert.alert('Login successful, code' + response.code)
|
|
515
|
+
+ })
|
|
516
|
+
+ .catch(error => {
|
|
517
|
+
+ console.log(error)
|
|
518
|
+
+ let errorCode = Number(error.code);
|
|
519
|
+
+ if (errorCode === -2) {
|
|
520
|
+
+ Alert.alert('Authorized login has been canceled')
|
|
521
|
+
+ } else {
|
|
522
|
+
+ Alert.alert('WeChat authorized login failed')
|
|
523
|
+
+ }
|
|
524
|
+
+ });
|
|
525
|
+
+
|
|
526
|
+
+ }
|
|
527
|
+
+
|
|
528
|
+
+ function onShareText() {
|
|
529
|
+
+ shareText({
|
|
530
|
+
+ text: 'test content.',
|
|
531
|
+
+ scene: 0
|
|
532
|
+
+ }).then()
|
|
533
|
+
+ }
|
|
534
|
+
+
|
|
535
|
+
+ return (
|
|
536
|
+
+ <View style={styles.container}>
|
|
537
|
+
+ <Text style={styles.title}>Call wechat SDK demo</Text>
|
|
538
|
+
+ <Text style={styles.versionBox}>
|
|
539
|
+
+ Version: {versionNumber}
|
|
540
|
+
+ </Text>
|
|
541
|
+
+ <View style={styles.buttonGroup}>
|
|
542
|
+
+ <View style={styles.button}>
|
|
543
|
+
+ <Button title={'Open WeChat'} onPress={() => { openWXApp().then() }} />
|
|
544
|
+
+ </View>
|
|
545
|
+
+ <View style={styles.button}>
|
|
546
|
+
+ <Button title={'Authorized login'} onPress={() => { onLogin() }} />
|
|
547
|
+
+ </View>
|
|
548
|
+
+ <View style={styles.button}>
|
|
549
|
+
+ <Button title={'Share Text'} onPress={() => { onShareText() }} />
|
|
550
|
+
+ </View>
|
|
551
|
+
+ </View>
|
|
552
|
+
+ </View>
|
|
553
|
+
+ );
|
|
554
|
+
+}
|
|
555
|
+
+
|
|
556
|
+
+const styles = StyleSheet.create({
|
|
557
|
+
+ container: {
|
|
558
|
+
+ width: '100%',
|
|
559
|
+
+ // flex: 1,
|
|
560
|
+
+ alignItems: 'center',
|
|
561
|
+
+ // justifyContent: 'center',
|
|
562
|
+
+ },
|
|
563
|
+
+ box: {
|
|
564
|
+
+ width: 60,
|
|
565
|
+
+ height: 60,
|
|
566
|
+
+ marginVertical: 20,
|
|
567
|
+
+ },
|
|
568
|
+
+ title: {
|
|
569
|
+
+ marginTop: 48,
|
|
570
|
+
+ fontSize: 24,
|
|
571
|
+
+ color: 'rgba(0, 0, 0, 0.6)',
|
|
572
|
+
+ },
|
|
573
|
+
+ versionBox: {
|
|
574
|
+
+ color: 'rgba(0, 0, 0, 0.6)'
|
|
575
|
+
+ },
|
|
576
|
+
+ buttonGroup: {
|
|
577
|
+
+ width: '100%',
|
|
578
|
+
+ padding: 6,
|
|
579
|
+
+ marginTop: 24,
|
|
580
|
+
+ },
|
|
581
|
+
+ button: {
|
|
582
|
+
+ margin: 6,
|
|
583
|
+
+
|
|
584
|
+
+ }
|
|
585
|
+
+});
|
|
586
|
+
+```
|
|
587
|
+
+
|
|
588
|
+
+## 2. Link
|
|
589
|
+
+
|
|
590
|
+
+| | Is supporte autolink | Supported RN Version |
|
|
591
|
+
+|--------------------------------------|----------------------|------------|
|
|
592
|
+
+| ~3.2.0 | Yes | 0.82 |
|
|
593
|
+
+| ~3.1.0 | No | 0.77 |
|
|
594
|
+
+| ~3.0.6 | Yes | 0.72 |
|
|
595
|
+
+
|
|
596
|
+
+Using AutoLink need to be configured according to this document, Autolink Framework Guide Documentation: https://gitcode.com/openharmony-sig/ohos_react_native/blob/master/docs/zh-cn/Autolinking.md
|
|
597
|
+
+
|
|
598
|
+
+If the version you use supports Autolink and the project has been connected to Autolink, skip the ManualLink configuration.
|
|
599
|
+
+<details>
|
|
600
|
+
+ <summary>ManualLink: this step is a guide to manually configure native dependencies.</summary>
|
|
601
|
+
+
|
|
602
|
+
+First, use DevEco Studio to open the HarmonyOS project `harmony` in the project directory.
|
|
603
|
+
+
|
|
604
|
+
+### 2.1 Adding the overrides Field to oh-package.json5 File in the Root Directory of the Project
|
|
605
|
+
+
|
|
606
|
+
+```json
|
|
607
|
+
+{
|
|
608
|
+
+ ...
|
|
609
|
+
+ "overrides": {
|
|
610
|
+
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
|
|
611
|
+
+ }
|
|
612
|
+
+}
|
|
613
|
+
+```
|
|
614
|
+
+
|
|
615
|
+
+### 2.2 Introducing Native Code
|
|
616
|
+
+
|
|
617
|
+
+Currently, two methods are available:
|
|
618
|
+
+
|
|
619
|
+
+Method 1 (recommended): Use the HAR file.
|
|
620
|
+
+
|
|
621
|
+
+> [!TIP] The HAR file is stored in the `harmony` directory in the installation path of the third-party library.
|
|
622
|
+
+
|
|
623
|
+
+Open `entry/oh-package.json5` file and add the following dependencies:
|
|
624
|
+
+
|
|
625
|
+
+```json
|
|
626
|
+
+"dependencies": {
|
|
627
|
+
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
|
|
628
|
+
+ "@react-native-ohos/react-native-wechat-lib": "file:../../node_modules/@react-native-ohos/react-native-wechat-lib/harmony/react_native_wechat_lib.har"
|
|
629
|
+
+ }
|
|
630
|
+
+```
|
|
631
|
+
+
|
|
632
|
+
+Click the `sync` button in the upper right corner.
|
|
633
|
+
+
|
|
634
|
+
+Alternatively, run the following instruction on the terminal:
|
|
635
|
+
+
|
|
636
|
+
+```bash
|
|
637
|
+
+cd entry
|
|
638
|
+
+ohpm install
|
|
639
|
+
+```
|
|
640
|
+
+
|
|
641
|
+
+Method 2: Directly link to the source code.
|
|
642
|
+
+
|
|
643
|
+
+> [!TIP] For details, see [Directly Linking Source Code](./link-source-code.md).
|
|
644
|
+
+
|
|
645
|
+
+### 2.3 Configuring CMakeLists and Introducing RNWechatLibPackage
|
|
646
|
+
+
|
|
647
|
+
+open `entry/src/main/cpp/CMakeLists.txt` and add the following code:
|
|
648
|
+
+
|
|
649
|
+
+```diff
|
|
650
|
+
+project(rnapp)
|
|
651
|
+
+cmake_minimum_required(VERSION 3.4.1)
|
|
652
|
+
+set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
|
653
|
+
+set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
|
654
|
+
+set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
|
|
655
|
+
++ set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
|
|
656
|
+
+set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
|
|
657
|
+
+set(LOG_VERBOSITY_LEVEL 1)
|
|
658
|
+
+set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
|
|
659
|
+
+set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
|
|
660
|
+
+set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
|
|
661
|
+
+add_compile_definitions(WITH_HITRACE_SYSTRACE)
|
|
662
|
+
+
|
|
663
|
+
+add_subdirectory("${RNOH_CPP_DIR}" ./rn)
|
|
664
|
+
+
|
|
665
|
+
+# RNOH_BEGIN: manual_package_linking_1
|
|
666
|
+
+add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
|
|
667
|
+
++ add_subdirectory("${OH_MODULES}/@react-native-ohos/react-native-wechat-lib/src/main/cpp" ./wechat-lib)
|
|
668
|
+
+# RNOH_END: manual_package_linking_1
|
|
669
|
+
+
|
|
670
|
+
+file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
|
|
671
|
+
+
|
|
672
|
+
+add_library(rnoh_app SHARED
|
|
673
|
+
+ ${GENERATED_CPP_FILES}
|
|
674
|
+
+ "./PackageProvider.cpp"
|
|
675
|
+
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
|
|
676
|
+
+)
|
|
677
|
+
+target_link_libraries(rnoh_app PUBLIC rnoh)
|
|
678
|
+
+
|
|
679
|
+
+# RNOH_BEGIN: manual_package_linking_2
|
|
680
|
+
+target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
|
|
681
|
+
++ target_link_libraries(rnoh_app PUBLIC wechat_lib)
|
|
682
|
+
+# RNOH_END: manual_package_linking_2
|
|
683
|
+
+```
|
|
684
|
+
+
|
|
685
|
+
+Open `entry/src/main/cpp/PackageProvider.cpp` and add the following code:
|
|
686
|
+
+
|
|
687
|
+
+```diff
|
|
688
|
+
+#include "RNOH/PackageProvider.h"
|
|
689
|
+
+#include "generated/RNOHGeneratedPackage.h"
|
|
690
|
+
+#include "SamplePackage.h"
|
|
691
|
+
++ #include "RNWechatLibPackage.h"
|
|
692
|
+
+
|
|
693
|
+
+using namespace rnoh;
|
|
694
|
+
+
|
|
695
|
+
+std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
|
|
696
|
+
+ return {
|
|
697
|
+
+ std::make_shared<RNOHGeneratedPackage>(ctx),
|
|
698
|
+
+ std::make_shared<SamplePackage>(ctx),
|
|
699
|
+
++ std::make_shared<RNWechatLibPackage>(ctx),
|
|
700
|
+
+ };
|
|
701
|
+
+}
|
|
702
|
+
+```
|
|
703
|
+
+
|
|
704
|
+
+### 2.4 Introducing WechatLibPackage to ArkTS
|
|
705
|
+
+
|
|
706
|
+
+Open the `entry/src/main/ets/RNPackagesFactory.ts` file and add the following code:
|
|
707
|
+
+
|
|
708
|
+
+```diff
|
|
709
|
+
+ ...
|
|
710
|
+
++ import { WechatLibPackage } from '@react-native-ohos/react-native-wechat-lib/ts';
|
|
711
|
+
+
|
|
712
|
+
+export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
|
|
713
|
+
+ return [
|
|
714
|
+
+ new SamplePackage(ctx),
|
|
715
|
+
++ new WechatLibPackage(ctx),
|
|
716
|
+
+ ];
|
|
717
|
+
+}
|
|
718
|
+
+```
|
|
719
|
+
+</details>
|
|
720
|
+
+
|
|
721
|
+
+### 2.5 Necessary configuration items
|
|
722
|
+
+
|
|
723
|
+
+> [!TIP] The content of this module cannot be automatically generated by autolink and must always be manually configured.
|
|
724
|
+
+
|
|
725
|
+
+#### 2.5.1 Configuring EntryAbility(This module always requires manual configuration)
|
|
726
|
+
+
|
|
727
|
+
+Open `entry\src\main\ets\entryability\EntryAbility.ets` and add the following code:
|
|
728
|
+
+
|
|
729
|
+
+```diff
|
|
730
|
+
+import {RNAbility} from '@rnoh/react-native-openharmony';
|
|
731
|
+
++ import { AbilityConstant, Want } from '@kit.AbilityKit';
|
|
732
|
+
++ import { WechatLibTurboModule } from '@react-native-ohos/react-native-wechat-lib';
|
|
733
|
+
+
|
|
734
|
+
+export default class EntryAbility extends RNAbility {
|
|
735
|
+
+
|
|
736
|
+
++ onCreate(want: Want) {
|
|
737
|
+
++ super.onCreate(want)
|
|
738
|
+
++ this.handleWeChatCallIfNeed(want)
|
|
739
|
+
++ }
|
|
740
|
+
+
|
|
741
|
+
+ getPagePath() {
|
|
742
|
+
+ return 'pages/Index';
|
|
743
|
+
+ }
|
|
744
|
+
+
|
|
745
|
+
++ onNewWant(want: Want, _launchParam: AbilityConstant.LaunchParam): void {
|
|
746
|
+
++ this.handleWeChatCallIfNeed(want)
|
|
747
|
+
++ }
|
|
748
|
+
+
|
|
749
|
+
++ private handleWeChatCallIfNeed(want: Want) {
|
|
750
|
+
++ WechatLibTurboModule.handleWant(want)
|
|
751
|
+
++ }
|
|
752
|
+
+}
|
|
753
|
+
+
|
|
754
|
+
+```
|
|
755
|
+
+
|
|
756
|
+
+#### 2.5.2 Configuring module.json5(This module always requires manual configuration)
|
|
757
|
+
+
|
|
758
|
+
+open `entry/src/main/module.json5` and add the following code:
|
|
759
|
+
+
|
|
760
|
+
+```diff
|
|
761
|
+
+{
|
|
762
|
+
+ "module": {
|
|
763
|
+
+ "name": "entry",
|
|
764
|
+
+ "type": "entry",
|
|
765
|
+
+ "description": "$string:module_desc",
|
|
766
|
+
+ "mainElement": "EntryAbility",
|
|
767
|
+
+ "deviceTypes": [
|
|
768
|
+
+ "default"
|
|
769
|
+
+ ],
|
|
770
|
+
++ "querySchemes": [
|
|
771
|
+
++ "weixin",
|
|
772
|
+
++ ],
|
|
773
|
+
+ ...
|
|
774
|
+
+ }
|
|
775
|
+
+}
|
|
776
|
+
+```
|
|
777
|
+
+
|
|
778
|
+
+### 2.6 Running
|
|
779
|
+
+
|
|
780
|
+
+Click the `sync` button in the upper right corner.
|
|
781
|
+
+
|
|
782
|
+
+Alternatively, run the following instruction on the terminal:
|
|
783
|
+
+
|
|
784
|
+
+```bash
|
|
785
|
+
+cd entry
|
|
786
|
+
+ohpm install
|
|
787
|
+
+```
|
|
788
|
+
+
|
|
789
|
+
+Then build and run the code.
|
|
790
|
+
+
|
|
791
|
+
+## 3. Constraints
|
|
792
|
+
+
|
|
793
|
+
+### 3.1 Compatibility
|
|
794
|
+
+
|
|
795
|
+
+To use this repository, you need to use the correct React-Native and RNOH versions. In addition, you need to use DevEco Studio and the ROM on your phone.
|
|
796
|
+
+
|
|
797
|
+
+Verified in the following versions.
|
|
798
|
+
+
|
|
799
|
+
+1. RNOH: 0.72.96; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
800
|
+
+2. RNOH: 0.72.33; SDK: HarmonyOS NEXT B1; IDE: DevEco Studio: 5.0.3.900; ROM: Next.0.0.71;
|
|
801
|
+
+3. RNOH: 0.77.18; SDK: HarmonyOS 6.0.0 Release SDK; IDE: DevEco Studio 6.0.0.858; ROM: 6.0.0.112;
|
|
802
|
+
+4. RNOH: 0.82.7; SDK: HarmonyOS 6.0.1 Release SDK; IDE: DevEco Studio 6.0.1 Release; ROM: 6.0.0.328 SP26;
|
|
803
|
+
+
|
|
804
|
+
+## 4. API
|
|
805
|
+
+
|
|
806
|
+
+> [!TIP] The **Platform** column indicates the platform where the properties are supported in the original third-party library.
|
|
807
|
+
+
|
|
808
|
+
+> [!TIP] If the value of **HarmonyOS Support** is **yes**, it means that the HarmonyOS platform supports this property; **no** means the opposite; **partially** means some capabilities of this property are supported. The usage method is the same on different platforms and the effect is the same as that of iOS or Android.
|
|
809
|
+
+
|
|
810
|
+
+> [!TIP] The rules for mobile applications to jump to Mini Program, [please refer to the feature introduction for launching Mini Program in the app](https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Launching_a_Mini_Program/Launching_a_Mini_Program.html)
|
|
811
|
+
+
|
|
812
|
+
+| Name | Description | Type | Required | Platform | HarmonyOS Support |
|
|
813
|
+
+| --------------------------------------------- | ------------------ | -------- | -------- | ----------- | ----------------- |
|
|
814
|
+
+| registerApp(appid) | register | Function | no | Android/iOS | yes |
|
|
815
|
+
+| isWXAppInstalled() | Determine whether WeChat is installed | Function | no | Android/iOS | yes |
|
|
816
|
+
+| isWXAppSupportApi() | Check support | Function | no | Android/iOS | no |
|
|
817
|
+
+| getApiVersion() | Get API version number | Function | no | Android/iOS | no |
|
|
818
|
+
+| openWXApp() | Open WeChat | Function | no | Android/iOS | yes |
|
|
819
|
+
+| sendAuthRequest([scope[, state]]) | WeChat authorized login| Function | no | Android/iOS | yes |
|
|
820
|
+
+| shareText(ShareTextMetadata) | Share/Collect Text | Function | no | Android/iOS | partially(Session、Timeline) |
|
|
821
|
+
+| shareImage(ShareImageMetadata) | Share Image | Function | no | Android/iOS | partially(Session、Timeline) |
|
|
822
|
+
+| shareLocalImage(ShareImageMetadata) | Share LocalImage | Function | no | Android/iOS | partially(Session、Timeline) |
|
|
823
|
+
+| shareFile(ShareFileMetadata) | Share File | Function | no | Android/iOS | partially(Session) |
|
|
824
|
+
+| shareMusic(ShareMusicMetadata) | Share Music | Function | no | Android/iOS | no |
|
|
825
|
+
+| shareVideo(ShareVideoMetadata) | Share Video | Function | no | Android/iOS | partially(Session) |
|
|
826
|
+
+| shareWebpage (ShareWebpageMetadata) | Share Webpage | Function | no | Android/iOS | partially(Session) |
|
|
827
|
+
+| shareMiniProgram(ShareMiniProgramMetadata) | Share MiniProgram | Function | no | Android/iOS | partially(Session) |
|
|
828
|
+
+| launchMiniProgram (LaunchMiniProgramMetadata) | Launch MiniProgram | Function | no | Android/iOS | yes |
|
|
829
|
+
+| chooseInvoice (ChooseInvoice) | Select invoice | Function | no | Android/iOS | no |
|
|
830
|
+
+| pay(payload) | pay | Function | no | Android/iOS | yes |
|
|
831
|
+
+| subscribeMessage(SubscribeMessageMetadata) |
|
|
832
|
+
+One-time subscription to messages | Function | no | Android/iOS | no |
|
|
833
|
+
+
|
|
834
|
+
+## 5. Known Issues
|
|
835
|
+
+
|
|
836
|
+
+## 6. Others
|
|
837
|
+
+
|
|
838
|
+
+- ShareText、ShareImage、ShareLocalImage、ShareMiniProgram、ShareFile、ShareVideo、ShareWebpage: Only sharing is supported, collection is not supported, because the WeChat Open SDK currently does not support collection on the HarmonyOS platform.
|
|
839
|
+
+- isWXAppSupportApi、getApiVersion、ShareMusic、ChooseInvoice、subscribeMessage. These interfaces are currently not supported by HarmonyOS WeChat Open SDK.
|
|
840
|
+
+
|
|
841
|
+
+## 7. License
|
|
842
|
+
+
|
|
843
|
+
+This project is licensed under [The MIT License (MIT)](https://github.com/little-snow-fox/react-native-wechat-lib/blob/master/LICENSE).
|
|
844
|
+
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
### `harmony/react_native_wechat_lib/src/main/ets/WechatLibTurboModule.ets`
|
|
848
|
+
|
|
849
|
+
```diff
|
|
850
|
+
@@ -504,19 +504,7 @@ export class WechatLibTurboModule extends TurboModule implements TM.WechatLibTur
|
|
851
|
+
|
|
852
|
+
let thumbImageUrl = (message.thumbImageUrl ? message.thumbImageUrl : null);
|
|
853
|
+
if (thumbImageUrl != null && !(thumbImageUrl === "")) {
|
|
854
|
+
- await new Promise<void>((resolve) => {
|
|
855
|
+
- this.downloadImageWithUrl(thumbImageUrl!, async (imageData: ArrayBuffer) => {
|
|
856
|
+
- if (!imageData) {
|
|
857
|
+
- callback("shareVideo Failed to retrieve imageData", null);
|
|
858
|
+
- return;
|
|
859
|
+
- }
|
|
860
|
+
- let thumbPixel = image.createImageSource(imageData).createPixelMapSync();
|
|
861
|
+
- // 图片压缩
|
|
862
|
+
- let thumbBuffer = await this.bitmapResizeGetBytes(thumbPixel, this.THUMB_SIZE);
|
|
863
|
+
- mediaMessage.thumbData = new Uint8Array(thumbBuffer);
|
|
864
|
+
- resolve();
|
|
865
|
+
- }, callback);
|
|
866
|
+
- })
|
|
867
|
+
+ await this.loadThumbImage(thumbImageUrl, mediaMessage);
|
|
868
|
+
}
|
|
869
|
+
// 构造一个Req
|
|
870
|
+
const req = new wxopensdk.SendMessageToWXReq();
|
|
871
|
+
@@ -534,6 +522,67 @@ export class WechatLibTurboModule extends TurboModule implements TM.WechatLibTur
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
+ async loadThumbImage(
|
|
876
|
+
+ thumbImageUrl: string,
|
|
877
|
+
+ mediaMessage: wxopensdk.WXMediaMessage
|
|
878
|
+
+ ): Promise<void> {
|
|
879
|
+
+ const ASSET_PREFIX = 'asset://';
|
|
880
|
+
+ const RAWFILE_PREFIX = 'resource://RAWFILE/';
|
|
881
|
+
+ const DATA_PREFIX = 'data:';
|
|
882
|
+
+
|
|
883
|
+
+ const getBytes = (): Promise<ArrayBuffer> => {
|
|
884
|
+
+ return new Promise<ArrayBuffer>((resolve, reject) => {
|
|
885
|
+
+ try {
|
|
886
|
+
+ if (thumbImageUrl.startsWith('http://') || thumbImageUrl.startsWith('https://')) {
|
|
887
|
+
+ this.downloadImageWithUrl(thumbImageUrl, (imageData: ArrayBuffer) => {
|
|
888
|
+
+ if (!imageData) {
|
|
889
|
+
+ reject(new Error('Failed to retrieve imageData'));
|
|
890
|
+
+ return;
|
|
891
|
+
+ }
|
|
892
|
+
+ resolve(imageData);
|
|
893
|
+
+ }, (error: string | null, _result: null | boolean) => {
|
|
894
|
+
+ reject(new Error(error ?? 'Download image failed'));
|
|
895
|
+
+ });
|
|
896
|
+
+ } else if (thumbImageUrl.startsWith(DATA_PREFIX)) {
|
|
897
|
+
+ const commaIndex = thumbImageUrl.indexOf(',');
|
|
898
|
+
+ const base64Data = commaIndex >= 0
|
|
899
|
+
+ ? thumbImageUrl.substring(commaIndex + 1)
|
|
900
|
+
+ : thumbImageUrl.substring(DATA_PREFIX.length);
|
|
901
|
+
+ const decoded = new util.Base64Helper().decodeSync(base64Data);
|
|
902
|
+
+ const clean = new ArrayBuffer(decoded.byteLength);
|
|
903
|
+
+ new Uint8Array(clean).set(decoded);
|
|
904
|
+
+ resolve(clean);
|
|
905
|
+
+ } else {
|
|
906
|
+
+ let rawFilePath = thumbImageUrl;
|
|
907
|
+
+ if (rawFilePath.startsWith(ASSET_PREFIX)) {
|
|
908
|
+
+ rawFilePath = 'assets/' + rawFilePath.substring(ASSET_PREFIX.length);
|
|
909
|
+
+ } else if (rawFilePath.startsWith(RAWFILE_PREFIX)) {
|
|
910
|
+
+ rawFilePath = rawFilePath.substring(RAWFILE_PREFIX.length);
|
|
911
|
+
+ }
|
|
912
|
+
+ const content = getContext(this).resourceManager.getRawFileContentSync(rawFilePath);
|
|
913
|
+
+ resolve(content.buffer);
|
|
914
|
+
+ }
|
|
915
|
+
+ } catch (err) {
|
|
916
|
+
+ reject(err instanceof Error ? err : new Error('loadThumbImage getBytes error'));
|
|
917
|
+
+ }
|
|
918
|
+
+ });
|
|
919
|
+
+ };
|
|
920
|
+
+
|
|
921
|
+
+ const imageData = await getBytes();
|
|
922
|
+
+ let imageSource = image.createImageSource(imageData);
|
|
923
|
+
+ try {
|
|
924
|
+
+ let thumbPixel = imageSource.createPixelMapSync();
|
|
925
|
+
+ try {
|
|
926
|
+
+ let thumbBuffer = await this.bitmapResizeGetBytes(thumbPixel, this.THUMB_SIZE);
|
|
927
|
+
+ mediaMessage.thumbData = new Uint8Array(thumbBuffer);
|
|
928
|
+
+ } finally {
|
|
929
|
+
+ thumbPixel.release();
|
|
930
|
+
+ }
|
|
931
|
+
+ } finally {
|
|
932
|
+
+ imageSource.release();
|
|
933
|
+
+ }
|
|
934
|
+
+ }
|
|
935
|
+
+
|
|
936
|
+
/**
|
|
937
|
+
* 分享网页
|
|
938
|
+
* @param message
|
|
939
|
+
@@ -559,23 +608,11 @@ export class WechatLibTurboModule extends TurboModule implements TM.WechatLibTur
|
|
940
|
+
|
|
941
|
+
let thumbImageUrl = (message.thumbImageUrl ? message.thumbImageUrl : null);
|
|
942
|
+
if (thumbImageUrl != null && !(thumbImageUrl === "")) {
|
|
943
|
+
- await new Promise<void>((resolve) => {
|
|
944
|
+
- this.downloadImageWithUrl(thumbImageUrl!, async (imageData: ArrayBuffer) => {
|
|
945
|
+
- if (!imageData) {
|
|
946
|
+
- callback("shareWebpage Failed to retrieve imageData", null);
|
|
947
|
+
- return;
|
|
948
|
+
- }
|
|
949
|
+
- let thumbPixel = image.createImageSource(imageData).createPixelMapSync();
|
|
950
|
+
- // 图片压缩
|
|
951
|
+
- let thumbBuffer = await this.bitmapResizeGetBytes(thumbPixel, this.THUMB_SIZE);
|
|
952
|
+
- mediaMessage.thumbData = new Uint8Array(thumbBuffer);
|
|
953
|
+
- resolve();
|
|
954
|
+
- }, callback);
|
|
955
|
+
- })
|
|
956
|
+
+ await this.loadThumbImage(thumbImageUrl, mediaMessage);
|
|
957
|
+
}
|
|
958
|
+
// 构造一个Req
|
|
959
|
+
const req = new wxopensdk.SendMessageToWXReq();
|
|
960
|
+
- req.transaction = "webpage";
|
|
961
|
+
+ req.transaction = util.generateRandomUUID().toString();
|
|
962
|
+
req.scene = message.scene ?? wxopensdk.SendMessageToWXReq.WXSceneSession;
|
|
963
|
+
req.message = mediaMessage;
|
|
964
|
+
|
|
965
|
+
@@ -620,21 +657,9 @@ export class WechatLibTurboModule extends TurboModule implements TM.WechatLibTur
|
|
966
|
+
message.hdImageUrl ? message.hdImageUrl : (message.thumbImageUrl ? message.thumbImageUrl : null);
|
|
967
|
+
|
|
968
|
+
if (thumbImageUrl != null && !(thumbImageUrl === "")) {
|
|
969
|
+
- this.downloadImageWithUrl(thumbImageUrl, async (imageData: ArrayBuffer) => {
|
|
970
|
+
- if (!imageData) {
|
|
971
|
+
- callback("ShareMiniProgram Failed to retrieve imageData", null);
|
|
972
|
+
- return;
|
|
973
|
+
- }
|
|
974
|
+
- let thumbPixel = image.createImageSource(imageData).createPixelMapSync();
|
|
975
|
+
- // 图片压缩
|
|
976
|
+
- let thumbBuffer = await this.bitmapResizeGetBytes(thumbPixel, this.THUMB_SIZE);
|
|
977
|
+
- mediaMessage.thumbData = new Uint8Array(thumbBuffer);
|
|
978
|
+
-
|
|
979
|
+
- await this.shareMiniProgramSendReq(mediaMessage, message, callback);
|
|
980
|
+
- }, callback);
|
|
981
|
+
- } else {
|
|
982
|
+
- await this.shareMiniProgramSendReq(mediaMessage, message, callback);
|
|
983
|
+
+ await this.loadThumbImage(thumbImageUrl, mediaMessage);
|
|
984
|
+
}
|
|
985
|
+
+ await this.shareMiniProgramSendReq(mediaMessage, message, callback);
|
|
986
|
+
} catch (err) {
|
|
987
|
+
const message = err instanceof Error ? err.message : 'shareMiniProgram Unknown error';
|
|
988
|
+
callback(message, null);
|
|
989
|
+
|
|
990
|
+
```
|
|
991
|
+
|
|
992
|
+
### `package.json`
|
|
993
|
+
|
|
994
|
+
```diff
|
|
995
|
+
@@ -36,7 +36,8 @@
|
|
996
|
+
"package.json",
|
|
997
|
+
"!**/__tests__",
|
|
998
|
+
"!**/__fixtures__",
|
|
999
|
+
- "!**/__mocks__"
|
|
1000
|
+
+ "!**/__mocks__",
|
|
1001
|
+
+ "!build"
|
|
1002
|
+
],
|
|
1003
|
+
"keywords": [
|
|
1004
|
+
"react-native",
|
|
1005
|
+
|
|
1006
|
+
```
|
|
1007
|
+
|
|
1008
|
+
### `src/index.ts`
|
|
1009
|
+
|
|
1010
|
+
```diff
|
|
1011
|
+
@@ -343,14 +343,23 @@ export function shareWebpage(data: ShareWebpageMetadata) {
|
|
1012
|
+
data.scene = 0;
|
|
1013
|
+
}
|
|
1014
|
+
return new Promise((resolve, reject) => {
|
|
1015
|
+
- nativeShareWebpage?.(data);
|
|
1016
|
+
- emitter.once("SendMessageToWX.Resp", (resp) => {
|
|
1017
|
+
+ WechatLib.unregisterCallback("SendMessageToWX.Resp");
|
|
1018
|
+
+ WechatLib.registerCallback("SendMessageToWX.Resp", (result) => {
|
|
1019
|
+
+ if (!result) {
|
|
1020
|
+
+ return;
|
|
1021
|
+
+ }
|
|
1022
|
+
+ const resp = result as WechatResponse & { code?: string; returnKey?: string };
|
|
1023
|
+
+ if (resp.code !== undefined || resp.returnKey !== undefined) {
|
|
1024
|
+
+ return;
|
|
1025
|
+
+ }
|
|
1026
|
+
+ WechatLib.unregisterCallback("SendMessageToWX.Resp");
|
|
1027
|
+
if (resp.errCode === 0) {
|
|
1028
|
+
resolve(resp);
|
|
1029
|
+
} else {
|
|
1030
|
+
reject(new WechatError(resp));
|
|
1031
|
+
}
|
|
1032
|
+
});
|
|
1033
|
+
+ nativeShareWebpage?.(data);
|
|
1034
|
+
});
|
|
1035
|
+
}
|
|
1036
|
+
/**
|
|
1037
|
+
|
|
1038
|
+
```
|