Socket
Book a DemoInstallSign in
Socket

@wisdomgarden/cloak-plugin-code-scanner

Package Overview
Dependencies
Maintainers
7
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wisdomgarden/cloak-plugin-code-scanner

A plugin for the Cloak framework that enables scanning QR code

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
7
Created
Source

English Version | 中文版

CloakPluginCodeScanner

CloakPluginCodeScanner 是 Cloak 框架的插件之一,用于在 Cloak 应用中进行二维码扫描。

使用方法

前置条件

安装 Cloak 框架 @wisdomgarden/cloak

具体细节参考 @wisdomgarden/cloak

  • 安装 CloakPluginCodeScanner 插件

    ohpm install @wisdomgarden/cloak-plugin-code-scanner
    npm install @wisdomgarden/cloak-plugin-code-scanner # optional
    
  • 在项目 entry/src/main/module.json5 中声明相机权限。

    官方文档

    示例:

    "requestPermissions": [
     // ...
     {
       "name": "ohos.permission.CAMERA",
       "reason": "$string:permission_camera_reason",
       "usedScene": {
         "abilities": [
           "EntryAbility"
         ],
         "when": "inuse"
       }
     },
     // ...
    ]
    
  • 在 H5 逻辑代码中就可以直接调用该插件。

  • 如果你使用 Typescript 或者想在前端扩展插件,安装 NPM 包

    npm install @wisdomgarden/cloak-plugin-code-scanner
    

示例代码

扫描二维码

const scanQRCode = async () => {
  const result = await Cloak.plugins.CodeScanner.scan();
  alert(JSON.stringify(result, null, 2));
};

核心接口

扫描二维码

export interface CodeScannerPlugin extends Plugin {
  scan(): Promise<ScanResult>;
}

接口类型定义

扫描结果

export interface ScanResult {
  error?: {
    code: number;
    name: string;
    message: string;
  };
  result?: {
    originalValue: string;
    scanType: ScanType;
  };
}

关于 Cloak

Cloak 是专为 HarmonyOS 设计的混合开发框架,类似 CordovaCapacitor,但具备 更轻量更高性能 的特性。

该框架可将 Web 应用快速转换为原生应用,同时通过插件机制访问 HarmonyOS 原生能力。

核心特性

  • 快速打包:将 H5 应用快速编译为 HarmonyOS 应用。
  • 原生能力访问:通过插件机制调用原生接口。
  • WebView 支持:提供高性能 WebView 容器,确保 H5 应用流畅运行。
  • 插件开发:支持开发者自定义插件以扩展原生功能。

更多关于 Cloak 框架信息,请查看: https://github.com/WisdomGardenInc/Cloak

Keywords

Cloak

FAQs

Package last updated on 30 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts