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

@mini-dev/action-dispatch

v0.0.4

Published

miniapp action dispatch

Downloads

22

Readme

miniapp action dispatch

处理小程序内各种动态下发的跳转。

使用方式

安装:

npm install @mini-dev/action-dispatch

如果想启用默认的“支持跳转到网页”,需要先配置小程序内具体的 webview 页面地址。配置方式如下:

const {Dispatcher, MiniDispatcher} = require("@mini-dev/action-dispatch");
const dispatcher = new MiniDispatcher();
dispatcher.config("webview", '/pages/web/index'); 

配置自定义处理函数:

dispatcher.registerHandle((action, actionUrl, dispatcher) => {
    if (action.protocol === 'http' || action.protocol === 'https') {
        wx.navigateTo({
            url: `${dispatcher.config('webview')}?_url=${encodeURIComponent(actionUrl)}`
        });
        return true; //返回 true 表示不再向后续的事件处理器传递
    }
    return false; //返回 false 表示接着向后续的事件处理器传递
});

处理跳转 url

dispatcher.handle(actionUrl, extra, handleContext);

默认支持的跳转协议

根据具体路径跳转到小程序内的其他页面

/pages/pageB/index?from=source1

通过 extra 传入的参数,都会被附加到执行跳转的 path 上。

比如:

dispatcher.handle('/pages/pageB/index?from=source1', {a:100})

最终执行跳转的 path 为:

/pages/pageB/index?from=source1&a=100

通过页面名称跳转小程序内的其他页面

mini://page?_name={page name}&key=value

其中 _name 指定目标页面的名字,其他参数(比如:key=value)、以及通过 extra 传入的参数,都会被附加到执行跳转的 path 上。

比如:

dispatcher.handle('mini://page?_name=pageA&from=source2', {a:100})

最终执行跳转的 path 为:

/pages/pageB/index?_name=pageA&from=source2&a=100

跳转具体链接到网页

https://aa.bb.cc/xyz?key=value&from=source5

通过 extra 传入的参数,都会被附加到最终的网页地址上。

跳转到网页

mini://webview?_url={webpage url}&key=value

其中 _url 指定目标网页的链接地址,其他参数(比如:key=value)、以及通过 extra 传入的参数,都会被附加到执行跳转的 path 上,而不是最终的网页地址上。

跳转到其他小程序

mini://miniapp?appId={miniapp id}&path={page path}
    

执行特定方法

mini://func/{function name}?param1=value1

修改默认协议

MiniDispatcher 默认支持的协议是 mini:// ,支持修改:

dispatcher.config('protocol','test');

配置之后,默认的跳转协议就变成:

test://page?_name={page name}
test://webview?_url={webpage url}
test://miniapp?appId={miniapp id}&path={page path}
test://function/{function name}?param1=value1