npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@cordova-ohos/cordova-plugin-ionic-webview

v5.0.2

Published

Cordova Ionic Webview Plugin

Readme

cordova-plugin-ionic-webview

zh-CN en

本项目基于 [email protected] 开发,本文档重点阐述其在 OpenHarmony(OHOS)系统中的具体应用。

简介

cordova-plugin-ionic-webview 是 Harmony Cordova 生态系统中一款核心插件,为 Apache Cordova / Ionic 应用提供高性能、现代化的 WebView 解决方案,替代原生 Cordova WebView,优化加载速度、本地资源访问和跨域兼容性,本文档主要说明在 OHOS 系统中的应用。

核心特性

  • 性能优化:基于 Chrome 内核,加载速度提升 30%+,支持硬件加速

  • 本地资源访问:通过 http(s):// 协议高效访问本地文件(HTML/CSS/JS/图片等),支持离线缓存

  • 跨域友好:内置 CORS 支持,无需额外配置即可实现跨域请求

  • 现代化特性:支持 ES6+ 语法、WebGL、Service Worker、WebRTC 等现代 Web 特性

  • 安全增强:支持 HTTPS 强制模式、内容安全策略(CSP)、防止混合内容警告

  • Ionic 兼容:与 Ionic Framework 深度集成,完美支持 Ionic 应用的路由、动画和组件

  • 调试便捷:支持 WEB 调试工具远程调试

支持平台

  • Android:API 19 及以上(Android 4.4+)

  • iOS:10.0 及以上

  • OHOS:5.0 及以上

下载安装

通过 hcordova CLI 即可快速安装插件,支持从 npm 仓库或 GitCode 仓库获取,可根据需求选择稳定版、指定版本或开发版。

基础安装(推荐)

# 安装 hcordova 命令化工具
npm install -g hcordova
# 安装最新稳定版插件
hcordova plugin add cordova-plugin-ionic-webview

指定平台安装 ohos

仅为 OHOS 平台安装插件,可选择指定版本:

# 安装特定版本(例如 1.0.0)并指定 OHOS 平台
hcordova plugin add [email protected] --platform ohos

从 GitCode 仓库安装

仅为 OHOS 平台安装插件(开发版,获取主分支最新代码):

# 安装主分支最新开发版并指定 OHOS 平台
hcordova plugin add https://gitcode.com/CPF-Cordova/cordova-plugin-ionic-webview.git --platform ohos

# 指定标签/分支安装
hcordova plugin add https://gitcode.com/CPF-Cordova/cordova-plugin-ionic-webview.git@develop --platform ohos

离线安装(本地包)

适用于无网络环境,先下载插件包到本地,再执行离线安装:

# 下载插件包到本地(示例路径:~/Downloads/cordova-plugin-ionic-webview)
# 执行离线安装
hcordova plugin add ~/Downloads/cordova-plugin-ionic-webview --platform ohos

安装后验证

安装完成后,可通过以下命令验证插件是否成功添加到项目中:

# 查看已安装的插件列表,若包含本插件 ID 则表示插件已成功安装
hcordova plugin list

卸载

# Cordova CLI 全平台卸载
hcordova plugin rm cordova-plugin-ionic-webview 
# 指定 OHOS 平台卸载
hcordova plugin rm cordova-plugin-ionic-webview --platform ohos

约束与限制

  1. 插件替代原生 Cordova WebView,安装后将覆盖原生 WebView 相关配置,建议安装前备份项目配置;
  2. OHOS 平台下,默认使用 https://www.example.com 加载 Rawfile/www/index.html 文件,可通过 config.cml 配置自定义 scheme 和域名;
  3. 加载页面在 OHOS 系统中,已有 @cordova-ohos/ohos 框架实现;
  4. 需确保项目兼容 Chrome 内核相关特性,部分老旧 Web 语法可能需要适配调整;
  5. 开启 HTTPS 强制模式后,需确保所有资源访问均使用 HTTPS 协议,避免混合内容警告。

兼容性

支持:

| 项目 | 版本/信息 | |-----|--------| | SDK | API12+ | | IDE | DevEco Studio: 5.0+ | | ROM | 5.1+ | | Emulator | OpenHarmony 6.0+ |

在以下版本中已测试通过:

| 项目 | 版本/信息 | |-----|--------| | @cordova-ohos/ohos | 14.0.1-ohos-14.0.1 | | SDK | 5.0.0(12) | | IDE | DevEco Studio: 6.0.13.200 | | ROM | 5.1.0.120 SP3 | | Emulator | OpenHarmony 6.0.1(21) |

使用说明

配置说明

1. 基础配置(选配)

默认是使用 https://www.example.com 加载 Rawfile/www/index.html 文件,可通过 config.cml 配置自定义 scheme 和域名。

config.cml 配置
<!-- 配置加载 scheme,支持 http|https,默认推荐 https -->
<preference name="Scheme" value="https" />

<!-- 配置自定义加载域名 -->
<preference name="Hostname" value="app" />

使用注意

  1. 配置 scheme 时仅支持 http 和 https,推荐使用 https 以提升安全性;
  2. 自定义 hostname 需符合域名规范,避免特殊字符;
  3. 调试时可通过 WEB 调试工具远程调试,提升开发效率;
  4. 若需使用离线缓存功能,需确保本地资源路径配置正确,支持通过 http(s):// 协议访问。

新增特性

  1. 适配 OHOS 5.0+ 系统,严格遵循 OpenHarmony 开发规范,替代原生 Cordova WebView;
  2. 保留插件核心功能,优化 OHOS 平台本地资源访问效率,支持 http(s):// 协议访问本地文件;
  3. 完善 OHOS 平台配置说明,明确 config.cml 配置方式及参数含义;
  4. 兼容 Cordova 14.0.1-ohos 版本,与 Ionic Framework 深度集成,保障应用流畅运行。

目录结构

cordova-plugin-ionic-webview/
├── src/                          # 源代码目录
│   └── main/                     # 主要源代码
│       └── cpp/                  # C++ 原生代码
│           ├── IonicWebView/     # Ionic WebView 模块
│           │   ├── IonicWebView.cpp  # Ionic WebView 功能的 C++ 实现
│           │   └── IonicWebView.h    # Ionic WebView 功能的头文件
│           └── NativeStorage/    # 原生存储模块
│               ├── NativeStorage.cpp  # 原生存储功能的 C++ 实现
│               └── NativeStorage.h    # 原生存储功能的头文件
├── www/                          # Web 资源目录
│   └── util.js                   # JavaScript 工具函数接口(Cordova 桥接层)
├── .gitignore                    # Git 忽略文件配置
├── LICENSE                       # 项目开源许可证
├── OAT.xml                       # OpenHarmony 审核配置文件
├── package.json                  # Node.js 包配置
├── plugin.xml                    # Cordova 插件描述文件(核心配置)
└── README.md                     # 项目说明文档

贡献代码

使用过程中发现任何问题都可以提 Issue ,当然也非常欢迎发 PR 共建。

许可证

本插件基于 Apache License 2.0 开源,可自由用于商业和非商业项目,详见 LICENSE 文件。

官方资源

  1. Android 和 iOS:cordova-plugin-ionic-webview 官方指南

  2. GitCode 仓库:CPF-Cordova/cordova-plugin-ionic-webview