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

wx-nav

v0.0.3

Published

powerful weixin miniapp router

Downloads

8

Readme

wx-nav

中文说明

powerful weixin miniapp router.

wx-nav 's APIs relative to weixin miniapp official API:

| | wx-nav API | | :-------------: | :------------: | | wx.navigateTo | navigateTo | | wx.navigateBack | navigateBack | | | navigateBackTo | | | navigateLastTo | | | refresh | | wx.switchTab | switchTab | | wx.redirectTo | redirectTo | | wx.reLaunch | reLaunch |

Feature

  1. router interceptor

  2. new API

  3. deal with the max count of weixin miniapp page stack

  4. when target page is repeated sequential, navigateBacknavigateBackTonavigateLastTo will merge them

  5. auto deal tabBar page

  6. better performance and code experience

install

require ./dist/wx-nav.cjs.js or ./dist/wx-nav.esm.js.

or use npm or yarn:

npm i --save wx-nav

yarn add wx-nav

Usage

// src/utils/wxnav.js
import WxNav from "wx-nav"

export const {
  navigateTo,
  navigateBack,
  navigateBackTo,
  navigateLastTo,
  refresh,
  switchTab,
  redirectTo,
  reLaunch
} = new WxNav({
  // optional. default value 10. max length of page stack.
  maxStack: 10,
  // optional. for `refresh()` or `switchTab(pageAlias)`
  tabBarPages: {
    // pageAlias: pageRoute
    home: "pages/home/main",
    userCenter: "pages/userCenter/main"
  },
  // optional
  beforeEach(to, from, next, apiName){
    next()
  },
  // optional
  afterEach(to, from, apiName){}
})

// index.vue
goToNextPage(){
  navigateTo("pages/nextpage/main", {from: "home"}, (isSuccess) => {
    if(!isSuccess){
      console.log("navigateTo fail")
    }
  })
}

API

navigateTo

navigateTo(url [, query [, cb]]) navigateTo(url [, cb])

  • url: string.
  • query: object. like {a:b, c:d} will be transform to ${url}?a=b&c=d.
  • cb: function. optional. receive a boolean value that mark the function call success or fail.

like wx.navigateTo, but navigateTo will use redirectTo instead when current pages length is MAX_PAGES_LENGTH.

navigateBack

navigateBack(delta ,cb) navigateBack(cb) navigateBack()

  • delta: integer. default value is 1.

like wx.navigateBack, but navigateBack() will check the target url whether repeat sequential or not. if page stack is [A, B, C, C, C, D], navigateBack() will be back to page C, stack is [A, B, C].

navigateBackTo

navigateBackTo(url [, cb])

navigateBackTo(url) will find the latest url page in page stack, and back to the page. there is also check url whether repeat sequential or not. if url is repeated, back to the earlist url. if page stack is [A, B, C, C, C, D, E, F], navigateBackTo(C) will be back to page C, stack is [A, B, C].

navigateLastTo

navigateLastTo(url [, cb])

navigateLastTo(url) assert last page is url, and back to url

  1. if last page is url and repeat: page stack is [A, B, C, C, C, D], navigateLastTo(C) will change page stack to [A, B, C]
  2. if last page is not url,there is call redirectTo(url) inside。 page stack is [A, B, C, D], navigateLastTo(C) will cahnge page stack to [A, B, C]. page stack is [A, B, C, D], navigateLastTo(D) will change page stack to [A, B, C, D], current page D will refresh。

refresh

refresh(cb) refresh()

refresh current page, such as TabBar page.

switchTab

switchTab(target [, cb])

  • target: string. url or alias of url. why there doesn't support query? see official document

redirectTo

redirectTo(url [, query [, cb]]) redirectTo(url [, cb])

reLaunch

reLaunch(url [, query [, cb]]) reLaunch(url [, cb])

it's better perfermance than wx.reLaunch.

License

MIT