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-app-exit

v0.0.2

Published

Cordova Exit Plugin

Downloads

144

Readme

cordova-plugin-app-exit

一款轻量级的 Cordova 插件,专为混合移动应用提供简洁高效的退出功能,支持 Android 、 iOS 和 OHOS 三平台,适配不同系统的退出行为规范,助力开发者快速实现应用退出场景,提升用户体验。

功能特性

  • 跨平台兼容:统一 Android 、 iOS 和 OHOS平台退出 API,屏蔽系统差异,降低开发成本

  • 轻量无依赖:插件体积小巧,不依赖任何第三方库,对应用性能无影响

  • 系统规范适配:遵循各平台退出行为规范,Android、OHOS 支持完全退出

  • 无权限要求:无需申请额外系统权限,安装后即可使用核心功能

  • 支持调试模式:开发环境下可输出调试日志,便于问题定位和排查

安装方法

确保已进入 Cordova 项目根目录,选择以下方式之一安装插件:

#安装hcordova
npm install -g hcordova

# 基础安装
hcordova plugin add cordova-plugin-app-exit 

# 指定OHOS安装
hcordova plugin add cordova-plugin-app-exit --platform ohos

# 从GitCode安装(推荐,获取最新稳定版)
hcordova plugin add https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-app-exit.git  --platform ohos

卸载

如需移除插件,在项目根目录执行以下命令:

# 全平台卸载
cordova plugin remove cordova-plugin-app-exit

#指定OHOS卸载
cordova plugin remove cordova-plugin-app-exit --platform ohos

4. 安装后验证

安装完成后,可通过以下命令验证插件是否安装成功:


# 查看已安装的插件列表
hcordova plugin list

# 若列表中显示 cordova-plugin-app-exit 则安装成功

快速开始

插件安装后无需额外初始化,只需在 deviceready 事件触发后调用 API 即可实现退出功能。以下是最简使用示例:


// 等待 Cordova 环境完全加载完成
document.addEventListener('deviceready', onDeviceReady, false);

function onDeviceReady() {
    navigator.app.exitApp();
}

注意:Android 平台中,应用退出后进程会被终止,因此 then 中的回调逻辑可能无法执行,建议仅在 iOS 平台依赖此回调。

API 参考

退出应用(exit)

触发应用退出操作,Android 平台会完全终止应用进程,iOS 平台会将应用退至后台。

  navigator.app.exitApp();

许可证

本插件基于 Apache License 开源,详见 LICENSE 文件。

联系方式

OHOS Cordova https://gitcode.com/OpenHarmony-Cordova/cordova-plugin-app-exit

Android/iOS:https://npmjs.com/cordova-plugin-app-exit/issues