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

jwb-app-invoker

v1.0.28

Published

jwb-app-invoker

Downloads

115

Readme

jwb-app-invoker

为了您的网页和交我办app通信,交我办app封装了一些方法供调用,使用jwb-app-invoker后可以很方便的调用这些封装的方法。

Install

npm install jwb-app-invoker

Usage

有两种方式可供选择,如果您的项目使用npm管理依赖,推荐作为es模块导入方式

  • 作为es模块导入
  • 使用script标签全局引入

Import ES Module

<script>
import { invoke, close, setTitle} from 'jwb-app-invoker';
...
invoke('close');
</script>

Import global variable by script tag

<!DOCTYPE html>
<html>
    <head>
        <!-- 将本项目dist目录中的invoker.global.prod.js放到自己网站合适的目录中并全局引入,引入后会产生全局变量JwbAppInvoker -->
        <script src="scripts/invoker.global.prod.js"></script>
    </head>
    <body>
        <div style="display: flex; flex-direction: column;">
            <!-- 调用封装在JwbAppInvoker上的方法即可 -->
            <button onclick="JwbAppInvoker.invoke('close')">close me</button>
            <button onclick="JwbAppInvoker.close()">close me</button>
        </div>
    </body>
</html>

api

目前该开发包封装了以下方法,除了特殊指明返回类型的方法,其他所有方法返回值均为布尔值表示是否调用成功,如果返回false多数是由交我办版本过低造成的,可提示用户升级交我办

  • invoke(methodName,param1,param2,...)

    调用app封装的方法,第一个参数是方法名,后面参数是app封装方法使用的参数,格式为{name,value}的键值对,参数次序必须和app封装方法的参数次序一致,使用本方法可以调用所有app封装的方法。

  • register(id)

    向交我办注册当前应用,其实是调用invoke('register',{name:'certId', value:id})的快捷方式。注册后标题栏将显示网络信息中心技术支持、主管部门、联系方式等信息。参数id是应用认证id,第三方可以联系网络信息中心获取。该方法开发者可自己调用,也可在script引用时加入注册的id参数,脚本引入后会自动注册。

<!DOCTYPE html>
<html>
    <head>
        <!-- 引入脚本时加入id参数可自动注册 -->
        <script src="scripts/invoker.global.prod.js?id=xxxx"></script>
    </head>
</html>
  • isApp():boolean

    返回布尔值,判断是否在交我办中

  • getVersion():string

    返回交我办版本,如果不在交我办中会返回空字符串

  • close()

    关闭本窗口,其实是调用invoke('close')的快捷方式

  • setTitle(title)

    设置窗口标题,其实是调用invoke('setTitle',{name:'title',value:'新的标题'})的快捷方式

  • openLink(url [,back = false] [,title])

    新窗口打开链接,其实是调用invoke('openLink',{name:'url',value:url},{name:'back',value:back},{name:'title',value:title})的快捷方式

    参数说明:

    • url 必填,链接地址
    • back 选填,是否标题栏显示回退按钮,缺省false显示的是关闭按钮
    • title 选填,自定义标题,不传该参数时将自动获取页面标题作为标题
  • closeAndOpenLink(url [,back = false] [,title])

    新窗口打开链接,并关闭原先的窗口。

    参数说明:

    • url 必填,链接地址,支持原生url
    • back 选填,是否标题栏显示回退按钮,缺省false显示的是关闭按钮
    • title 选填,自定义标题,不传该参数时将自动获取页面标题作为标题
  • openNative(url)

    打开交我办原生应用,其实是调用invoke('openNative',{name:'url',value:url})的快捷方式

    目前支持的原生url列表如下:

    • 思源码 'taskcenter://edu.sjtu.push/unicode'
    • 扫一扫 'taskcenter://edu.sjtu.push/scan'
    • 校园卡 'taskcenter://edu.sjtu.push/campusCard'
    • 日程 'taskcenter://edu.sjtu.push/schedule'
    • 消息中心 'taskcenter://edu.sjtu.push/messageCenter'
    • 应用分类 'taskcenter://edu.sjtu.push/app_list?type=分类名'
  • closeAndOpenNative(url)

    新窗口打开交我办原生应用,并关闭原先的窗口。

  • getLocation(callback)

    获取当前定位信息,callback参数为回调函数。