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 🙏

© 2025 – Pkg Stats / Ryan Hefner

c-permission-listener

v1.2.0

Published

uniapp项目,支持android平台全局监听权限的申请。基于uni.createRequestPermissionListener实现。解决软件在运行时,未见向用户告知权限申请的目的,华为上架被拒

Readme

欢迎使用 c-permission-listener

downloads

注意事项
🚀 控制台打印“【c-permission-listener】onRequest回调...”,里面的列表就是所需的权限,看下manifest.json有没有添加
🚀 按需增加相对应权限,在 manifest.json 中添加,记得重新打自定义基座包
🚀 HBuilderX 4.01 Vue2项目需要使用自定义基座测试监听权限申请的功能,标准基座暂不支持测试。
🚀 uni.previewImage使用原生的,plus.nativeObj.View覆盖不了;解决方案一:uni.previewImage换成插件;解决方案二:调用uni.previewImage前,提前使用plus.android.requestPermissions请求相关的权限。类似的可以使用上述的两种解决方案
🚀 拨打电话需要添加两个权限READ_PHONE_STATE、CALL_PHONE
🚀 存储权限在原来的WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE两个权限上,记得同时加上相对应的最新权限,做兼容处理,具体看Android权限文档;访问图片权限:READ_MEDIA_IMAGES, 读取视频权限:READ_MEDIA_VIDEO, 读取音频权限:READ_MEDIA_AUDIO


🔍 相关文档、文章
🚀 安卓离线打包方法:https://ask.dcloud.net.cn/article/41380
🚀 uniapp官方权限文档:https://uniapp.dcloud.net.cn/tutorial/app-permission-android.html#default
🚀 Android权限文档:https://developer.android.google.cn/reference/android/Manifest.permission
🚀 把文章修改成插件,原文:https://ask.dcloud.net.cn/article/41194

安装

// npm安装方式,插件市场导入无需执行此命令。插件市场导入地址:https://ext.dcloud.net.cn/plugin?name=c-permission-listener
npm install c-permission-listener

使用方法

utils/permissionEnums.js文件添加以下代码,按需添加需要的权限说明

export default {
	// 取android.permission.ACCESS_COARSE_LOCATION后面那个
	"ACCESS_COARSE_LOCATION": {
		name: "定位", // 当前权限的名称
		explain: "展示附近店铺、填写收货地址等相关功能"       // 权限说明
	},
	"CALL_PHONE,READ_PHONE_STATE": {
		name: "电话", // 当前权限的名称
		explain: "拨打电话"     // 权限说明
	},
	"WRITE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE,READ_MEDIA_IMAGES": {
		name: "存储", // 当前权限的名称
		explain: "上传头像完善个人信息"       // 权限说明
	},
	"CAMERA": {
		name: "相机", // 当前权限的名称
		explain: "上传头像完善个人信息"       // 权限说明
	}
}

App.vue文件添加下列代码:

<script>
	// 以下导入方式按照安装方式导入
	import permissionListener from "@/uni_modules/c-permission-listener";		// 插件市场导入方法
	import permissionListener from "c-permission-listener";		// npm导入方法
	import permissionEnums from "@/utils/permissionEnums.js";	// 导入权限说明枚举类
	export default {
		onLaunch: function() {
			console.log('App Launch')
			// 如果想让listenerFunc函数在onLaunch生命周期执行,那onHide生命周期就不执行stopFunc函数,有没有bug需要测试下
		},
		onShow: function() {
			console.log('App Show')
			// 拦截器,没有用到后面三个api就不需要添加,拦截部分api:getLocation、chooseLocation、openBluetoothAdapter,手机系统没有开启定位或者蓝牙先提示用户前往开启
			permissionListener && permissionListener.permissionInterceptor();
			// 唤起权限会触发onHide,所以listenerFunc须在onShow生命周期调用
			permissionListener && permissionListener.listenerFunc(permissionEnums);
		},
		onHide: function() {
			console.log('App Hide')
			// 移除拦截器
			permissionListener && permissionListener.removeInterceptor();
			// 取消监听权限唤起
			permissionListener && permissionListener.stopFunc();
		}
	}
</script>