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

dalitek.native

v1.1.25

Published

#### 项目介绍 邦奇超级app原生-h5交互接口 npm包 注意!!! 如果想调用原生方法,必须在项目启动时调用 async/await isReady()方法;

Downloads

181

Readme

dsan_npm

项目介绍

邦奇超级app原生-h5交互接口 npm包
注意!!! 如果想调用原生方法,必须在项目启动时调用 async/await isReady()方法;

注意事项

注意!!! 如果想调用原生方法,必须在项目启动时调用 async/await isReady()方法;

接口说明

isReady()
说明: 同步返回是否原生提供的方法和对象是否准备好了,仅会返回一个结果:true
参数: 无参数
用法: 直接调用,async/await
sendUDP(sport,rport,data,callback)
说明: 发送UDP广播
参数:
	1. sport: int/string 发送端口号;
	2. rport: int/string 接收端口号;
	3. data: 类型没有限制 发送UPD广播所需的报文;
	4. callback: function 回调函数;
用法:
	async/await调用,但是直接返回的结果没有实际意义,由于UPD广播可能会不同时的,多次返回的数据,所以UDP广播每返回一条数据,会调用一次callback,携带参数为UPD广播给的参数直接转发过来的.
savePreference(preference)
说明: 保存偏好设置
参数: preference: object/array 需要保存的偏好字段
	 preference内部的参数有两种形式;
	 第一种: 固定键值对;例如:
		 	[
		 		{ key: "name", value: "angle"}, 
		 		{ key: "age", value: "21"   }, 
		 		{key: "sex", value: "male"}
		 	];
	 第二种: 不固定键值对;例如:
		 	[
				{name:"angle"},
				{age:"21"},
				{sex:"male"}
		 	]
用法:async/await调用,直接返回true/false,表示保存成功/失败;
queryPreference()
说明: 查询偏好设置
参数: keys: string/array 需要查询的偏好字段的key值
	 keys有三种形式都支持;
	 第一种: 多个object元素组成的数组;例如:
		 	[
		 		{key:'key1'},
		 		{key:'key2'},
		 		...
		 	];
	 	调用示例: 
		 	let queryList = [{ key: "name" },{ key: "sex" }]
		 	console.log(await this.native.queryPreference(queryList))
	 第二种: 多个字符串元素组成的数组;例如
				["name", "age"]
	 第三种: 多个字符串;例如
				console.log(await this.native.queryPreference("name","age"))
用法: async/await调用,返回结果即查询结果
deletePreference()
说明: 删除偏好设置
参数: 同查询
用法: async/await调用,返回true/false表示成功/失败;
getDeviceImsi()
说明: 获取设备IMSI
参数: 无
用法: async/await调用,直接返回string类型的结果;
scanQcode()
说明: 扫描二维码
参数: 无
用法: async/await调用 同步返回扫描结果;示例:
		let result = await this.native.scanQcode();
		alert(result);
new native.Mqtt()
说明: 创建MQTT实例,建议创建了过后直接挂载在vue实例上面;
属性: 三个属性
	 mqttid: 实例id
	 connectStatus: 连接状态
	 topics: 已经订阅的topic(由于只考虑单个连接,这个属性这个版本没有实际意义)
方法: 
	 connect(con)
	 说明: 连接MQTT服务器
	 参数:
	 	con: object 连接mqtt服务器所需参数
	 	con.url: string, mqtt服务器地址(注意:带上协议头)
		con.clientid: string, 客户端id
		con.username: string, 用户名
		con.password: string, 密码
		提示: url需要带上协议头,安卓必须带上协议头才能连接到,IOS必须没有协议头才能连接到,在业务中使用时,统一带上协议头,执行IOS方法时会自动把协议头去掉;
		关于断后重连,需要在业务中通过connectStatus判断当前连接状态,如果connectStatus为false,则是连接已经断开,重新调用connect()方法重新连接;
		返回: true/false 表示连接成功/失败
		
	subscribe(topic,qos)
	说明: 订阅主题
	参数:
		topic: string 需要连接到的主题
		qos: number 可选,如果没有传入,默认为0;可选值为0/1/2
	返回: true/false 表示订阅成功/失败
	
	on(callback)
	说明: 监听和接收mqtt消息
	会传入回调的参数:
		  topic: string 来自主题
		  content: string/object 消息体
	返回: 无
	
	publish(pub)
	说明: 发布消息
	参数: pub: object 发布所需的所有数据,包括发布的主题和消息体
		  pub.topic: string 发布消息的主题
		  pub.payload: object 发布的消息体
		 参数示例: 
			let pub = {};
			pub.topic="testTopic";
			pub.payload={
							msg:"hallo hallo",
							msg1:"world world",
							...
						}
	返回: true/false 表示代码是否去执行了发布操作,并不代表发布成功或失败.
	
	dissubscribe(topic)
	说明: 取消订阅
	参数: topic: string 需要取消订阅的主题
	返回: true/false 取消订阅成功或失败
	
	disconnect()
	说明: 断开连接
	参数: 无
	返回: true/false 断开连接成功或失败

​ ​ 用法示例:

	// 导入
	import native from "dalitek.native";
	
	// mqtt实例挂载到vue实例
	Vue.prototype.native = native;
	Vue.prototype.mqtt = new native.Mqtt();
	
	// 连接
	async connect() {
      let con = {};
      con.url = "tcp://www.dalitek.online:1883";
      con.clientid = "b52e1250_app_001497171862_IOSTER";
      con.username = "default_user";
      con.password = "defalut_password";
      let res = await this.mqtt.connect(con);
      if (res) {
        alert("MQTT连接成功!");
      }else{
        alert("MQTT连接失败!");
      }
    }
    
    // 订阅 建议先监听消息返回再去订阅
    async subscribe() {
      await this.mqtt.on(this.mqttR);
      await this.mqtt.subscribe("jeffrey_test");
    },
    mqttR(topic, content) {
      alert("MQTT RECEIVED TOPIC===>" + topic);
      alert("MQTT RECEIVED CONTENT===>" + JSON.stringify(content));
    }
    
    // 发布
    async publish() {
      await this.mqtt.publish({
        topic:"jeffrey_test",
        payload:{
          msg:"jeffrey_test_content"
        }
      })
    }
    
    // 取消订阅
    async dissubscribe() {
      await this.mqtt.unsubscribe("jeffrey_test");
    }
    
    // 断开连接
    async disconnect() {
      await this.mqtt.disconnect();
    }
showSettingLayout()
说明: 调用原生方法打开侧边栏
参数: 无
用法: 直接调用,无返回结果,无回调方法
openSassApp()
说明: 调用原生方法打开其他应用
参数: String url
用法: 直接调用,无返回结果,无回调方法
distanceTop()
说明: 异形屏适配方法
参数: 无参数
用法: 直接调用,返回 Object (json) 结果,无回调方法
requestLBSLocation()
说明: 获取定位方法
参数: 无参数
用法:async/await调用,直接返回json;