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 🙏

© 2024 – Pkg Stats / Ryan Hefner

touchui-api

v1.3.5

Published

touchui api

Downloads

192

Readme

API

WeTouch(TouchUI) API

使用文档

使用浏览器打开网址

api.openBrowser(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- url|String|是|要浏览的页面地址 system|Boolean|否|是否使用系统浏览器打开(默认为:false,使用内置浏览器打开) backgroundColor|String|否|标题栏背景颜色 color|String|否|标题栏文字颜色 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

扫码

api.scanCode(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- onlyFromCamera|Boolean|否|是否只能从相机扫码,不允许从相册选择图片 backgroundColor|String|否|标题栏背景颜色 color|String|否|标题栏文字颜色 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

判断指纹硬件是否可用

api.canUseTouchID(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

使用指纹进行验证

api.useTouchID(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

分享到第三方应用

api.share(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- target|String|是|要分享到的应用(weixin_timeline、weixin_message、weibo、qq) type|String|否|分享类型(link、text、image 默认为link) title|String|否|分享标题(分享类型需为link) content|String|否|分享内容(分享类型为text时必选) icon|String|否|分享缩略图(分享类型需为link、图片大小需要小于30Kb) href|String|否|分享链接(分享类型需为link) pictures|Array|否|分享图片(分享类型需为image、图片地址不支持网络路径、部分平台仅支持分享一张图片) success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

选择联系人电话号码

api.pickPhoneNumber(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回电话号码 phoneNumber fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

监听状态栏点击事件(仅支持iOS)

api.onStatusbarTap(CALLBACK)

CALLBACK返回参数:

监听返回按钮点击事件

api.onBackButtonClick(CALLBACK)

CALLBACK返回参数:

取消监听返回按钮点击

api.offBackButtonClick(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- listener|Function|是|要移除的事件监听回调函数 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

获取页面的侧滑手势是否开启(仅支持iOS)

api.getPagePopGesture(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回手势是否开启(openPagePopGesture) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

设置页面的侧滑关闭手势(仅支持iOS)

api.setPagePopGesture(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- openPagePopGesture|Boolean|是|是否开启侧滑关闭手势 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

设置系统状态栏样式(仅支持iOS和部分安卓)

api.setStatusBarStyle(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- style|String|是|系统状态栏样式("dark":深色前景色样式、"light":浅色前景色样式) success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

获取系统状态栏样式(仅支持iOS和部分安卓)

api.getStatusBarStyle(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回系统状态栏样式 style("dark":深色前景色样式、"light":浅色前景色样式) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

进入全屏模式

api.enterFullscreen(CALLBACK)

CALLBACK返回参数:

离开全屏模式

api.leaveFullscreen(CALLBACK)

CALLBACK返回参数:

H5+ API初始化完毕

api.plusReady(CALLBACK)

CALLBACK返回参数:

判断是否APP环境

api.isApp

判断是否Android环境

api.isAndroid

判断是否iOS环境

api.isIos

获取客户端推送标识信息

api.getPushInfo(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回客户端推送标识信息 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

客户端推送标识信息

参数|类型|说明 -|-|- appid|String|应用在个推申请的appid appkey|String|应用在个推申请的appkey clientid|String|本机的clientid token|String|本机的token

监听推送消息点击

api.onPushClick(CALLBACK)

CALLBACK返回参数:

参数|类型|说明 -|-|- title|String|消息标题 content|String|消息内容 payload|String|附加内容

清空推送消息

api.clearPushMessage()

调用第三方地图进行导航

api.openSysMap(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- latitude|Number|是|纬度,范围为-90~90,负数表示南纬 longitude|Number|是|经度,范围为-180~180,负数表示西经 name|String|否|位置名 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

查询启动界面是否显示状态

api.hasSplashscreen()

关闭启动界面

api.closeSplashscreen()

监听页面滚动

api.onScroll(CALLBACK)

CALLBACK返回参数:

参数|类型|说明 -|-|- scrollLeft|Number|当前页面的document.body.scrollLeft scrollTop|Number|当前页面的document.body.scrollTop

滚动页面到指定位置

api.scrollTo(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- scrollLeft|Number|否|缺省为0 scrollTop|Number|否|缺省为0

显示页面的垂直滚动条

api.showScrollIndicator()

隐藏页面的垂直滚动条

api.hideScrollIndicator()

初始化美洽客服

api.initMeiqia(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- appKey|String|否|美洽 App Key success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

启动美洽客服界面

api.startMeiqia(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- info|Object|否|需要携带的信息 group|String|否|指定客服分组ID agent|String|否|指定客服ID message|String|否|启动客服界面后的预发送消息 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

获取美洽ID

api.getMeiqiaClientId(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回美洽ID clientId fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

设置美洽ID

api.setMeiqiaClientId(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- clientId|String|是|美洽ID success|Function|否|接口调用成功的回调,返回美洽ID clientId fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

监听页面显示

api.onPageShow(CALLBACK)

CALLBACK返回参数:

获取当前页面信息

api.getPage(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回页面id fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

事件监听

api.on(EVENT,CALLBACK)

取消事件监听

api.off(EVENT,CALLBACK)

主动触发事件

api.emit(EVENT,DATA,PAGEID)

登录

api.login(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- target|String|是|要获取登录信息的应用(qq、weixin) success|Function|否|接口调用成功的回调,返回登录数据 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

支付

api.requestPayment(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- target|String|是|支付方式(alipay、wxpay) statement|Object|是|支付订单信息,不同的支付方式不同(支付宝订单参数微信订单参数) success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

监听应用进入后台

api.onAppPause(CALLBACK)

监听应用返回前台继续运行

api.onAppResume(CALLBACK)

获取设备信息

api.getDeviceInfo(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回设备信息(imei、imsi、mac、uuid) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

获取状态栏高度

api.statusbarHeight()

获取顶部安全区插入位置

api.getSafeAreaInsetTop()

获取底部安全区插入位置

api.getSafeAreaInsetBottom()

获取左侧安全区插入位置

api.getSafeAreaInsetLeft()

获取右侧安全区插入位置

api.getSafeAreaInsetRight()

获取安全区插入位置

api.getSafeAreaInsets(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回安全区信息(top、left、right、bottom) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

监听安全区插入位置变更

api.onSafeAreaInsetsChange(CALLBACK)

CALLBACK返回参数:

参数|类型|说明 -|-|- top|Number|safeAreaInsets.top left|Number|safeAreaInsets.left right|Number|safeAreaInsets.right bottom|Number|safeAreaInsets.bottom

获取系统音量

api.getVolume(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回系统音量(value) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

设置系统音量

api.setVolume(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- value|Number|是|要设置的系统音量值,0到1,0为静音,1为最大音量 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

开始语音识别

api.startSpeechRecognize(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- timeout|Number|否|无语音输入识别超时时间,单位:毫秒,默认10秒 lang|String|否|语言类型(zh-cn:中文-普通话;en-us:英语;zh-cantonese:中文-粤语;zh-henanese:中文-河南话。 默认值为“zh-cn”) punctuation|Boolean|否|识别结果中是否包含标点符号,默认:false success|Function|否|接口调用成功的回调,返回识别结果(text) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

停止(取消)语音识别

api.stopSpeechRecognize()

安装软件包(wgt、apk)

api.installPackage(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- src|String|否|安装包的路径(可以是临时文件路径或存储文件路径,网络路径需先下载) success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

获取当前应用信息

api.getAppInfo(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回当前应用信息 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

应用信息

参数|类型|说明 -|-|- appName|String|应用名称 version|String|应用版本 runtimeVersion|String|应用运行环境版本

比较版本信息

api.compareVersions(v1,v2)

返回(Number)

  • 1:v1版本高
  • 0:v1和v2版本相等
  • -1:v1版本低

关闭APP

api.closeApp()

重启APP

api.restartApp()

获取启动参数

api.getLaunchArguments(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回启动参数 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

启动参数

参数|类型|说明 -|-|- arguments|String|应用的启动参数

监听从其他应用启动事件

api.onLaunch(CALLBACK)

测试能否打开URL

api.canOpenURL(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- url|String|是|要测试打开的URL success|Function|否|接口调用成功的回调,返回appList fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明

参数|类型|说明 appList|Array|可以打开此URL的应用列表(安卓返回应用包名,iOS返回URL)

打开URL

api.openURL(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- url|String|是|要打开的URL identity|String|否|要打开应用的包名(安卓) fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

设置本地化语言

api.setI18n(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- locale|String|是|语言类型 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

打开数据库

api.openDatabase(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- name|String|是|数据库名称 path|String|是|数据库路径 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

执行sql语句参数

api.executeSql(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- name|String|是|数据库名称 sql|String|是|sql语句 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

执行事务操作

api.executetTansaction(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- name|String|是|数据库名称 operation|String|是|事务操作类型(begin、commit、rollback) success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

执行sql查询

api.selectSql(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- name|String|是|数据库名称 sql|String|是|sql语句 success|Function|否|接口调用成功的回调,返回查询结果 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明

参数|类型|说明 -|-|- data|Array|查询到的结果集合

关闭数据库

api.closeDatabase(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- name|String|是|数据库名称 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

扫描打印机

api.scanPrinters(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调,返回查询结果 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明

参数|类型|说明 -|-|- printers|Array|打印机名称集合

连接打印机

api.connectPrinter(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

开始打印

api.startPrint(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- width|Number|否|打印区域宽度,单位mm height|Number|否|打印区域高度,单位mm orientation|Number|否|旋转角度,支持0、90、180、270 success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

创建打印机上下文对象

api.createPrinterContext() 创建并返回printerContext对象

printerContext对象的方法列表

方法|参数|类型|说明 -|-|-|- setItemOrientation|orientation|Number|设置顺时针旋转角度,支持0、90、180、270 setItemHorizontalAlignment|alignment|String|设置水平对齐方式,支持left、center、right setItemVerticalAlignment|alignment|String|设置垂直对齐方式,支持top、center、bottom drawText|OBJECT|Object|绘制文本 drawBarcode|OBJECT|Object|绘制条形码 drawQRCode|OBJECT|Object|绘制二维码 drawImage|OBJECT|Object|绘制图像 drawLine|OBJECT|Object|绘制线条 drawRoundRectangle|OBJECT|Object|绘制圆角矩形

drawText 的 OBJECT 参数列表:

参数|类型|必填|说明 -|-|-|- text|String|是|要绘制的文本 x|Number|否|绘制文本的x坐标,单位mm y|Number|否|绘制文本的y坐标,单位mm width|Number|否|文本绘制的宽度,单位mm height|Number|否|文本绘制的高度,单位mm fontHeight|Number|否|文字高度,单位mm

drawBarcode 的 OBJECT 参数列表:

参数|类型|必填|说明 -|-|-|- text|String|是|条形码内容 x|Number|否|绘制条形码的x坐标,单位mm y|Number|否|绘制条形码的y坐标,单位mm width|Number|否|条形码绘制的宽度,单位mm height|Number|否|条形码绘制的高度,单位mm

drawQRCode 的 OBJECT 参数列表:

参数|类型|必填|说明 -|-|-|- text|String|是|二维码内容 x|Number|否|绘制二维码的x坐标,单位mm y|Number|否|绘制二维码的y坐标,单位mm width|Number|否|二维码绘制的宽度,单位mm height|Number|否|二维码绘制的高度,单位mm

drawImage 的 OBJECT 参数列表:

参数|类型|必填|说明 -|-|-|- path|String|是|图像地址 x|Number|否|绘制图像的x坐标,单位mm y|Number|否|绘制图像的y坐标,单位mm width|Number|是|图像绘制的宽度,单位mm height|Number|是|图像绘制的高度,单位mm

drawLine 的 OBJECT 参数列表:

参数|类型|必填|说明 -|-|-|- x|Number|否|绘制线条的x坐标,单位mm y|Number|否|绘制线条的y坐标,单位mm width|Number|否|线条绘制的宽度,单位mm height|Number|否|线条绘制的高度,单位mm

drawRoundRectangle 的 OBJECT 参数列表:

参数|类型|必填|说明 -|-|-|- x|Number|否|绘制圆角矩形的x坐标,单位mm y|Number|否|绘制圆角矩形的y坐标,单位mm width|Number|是|圆角矩形绘制的宽度,单位mm height|Number|是|圆角矩形绘制的高度,单位mm lineWidth|Number|否|边框宽度,单位mm radius|Number|否|圆角大小,单位mm isFilled|Boolean|否|是否填充

提交打印

api.commitPrint(OBJECT)

OBJECT参数说明

参数|类型|必填|说明 -|-|-|- success|Function|否|接口调用成功的回调 fail|Function|否|接口调用失败的回调函数 complete|Function|否|接口调用结束的回调函数(调用成功、失败都会执行)

关闭打印机连接

api.closePrinter()