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

vue-router-store

v0.0.2

Published

vue router store plug-in

Downloads

1

Readme

Build Status dependencies Status devDependencies Status npm npm

vue-router-store

一个和vue-router配合使用的数据管理插件

功能

  • [ ] 基本的数据管理
  • [x] 分页列表数据管理
  • [x] 详情页面的数据管理
  • [ ] 记录局部滚动条位置

安装

npm install --save vue-router-store

入门的例子

以cnode社区的列表和详情为例子,当你前进或后台时,如果当前的地址和数据关联的地址匹配,会先渲染上次存储的数据,然后再请求服务器更新这一份数据,如果匹配不上,则会重置页面数据
例子代码地址请点击我

可选参数

pagekey

类型:String
默认值:page
描述:调用this.$rsList.search()方法时,会重置this.$route.query[pagekey]参数值为1

queryKey

类型:String 默认值:query
描述:将this.$route.query里面的参数设置到this.$data[queryKey]中

export default {
  //....
  data () {
    // ?keyname=xxxx 会设置到this.$data[queryKey].keyname中
    return {
      query: {
        keyname: ''
      }
    }
  }
}

fetchBefore

类型:Function
传入参数:name, type
描述:请求发送之前调用的钩子函数,this 指向到组件的实例中,无论成功失败

fetchAfter

类型:Function
传入参数:name, type
描述:请求结束之后调用的钩子函数,this 指向到组件的实例中,无论成功失败

fetchSuccess

类型:Function
传入参数:res, name, type
描述:请求成功之后调用的钩子函数,this 指向到组件的实例中,无论成功失败

fetchError

类型:Function
传入参数:e, name, type
描述:请求失败之后调用的钩子函数,this 指向到组件的实例中,无论成功失败

baseData

类型:Function
传入参数:name, type
返回类型:Object
描述:基本的数据

baseListData

类型:Function
传入参数:name
返回类型:Object
描述:列表的基本字段

baseDetailData

类型:Function
传入参数:name
返回类型:Object
描述:详情的基本字段

modules

类型:Object
默认值:{}
描述:设置各个模块之前的请求配置、数据配置等

传入的参数说明:
res: modules的fetch钩子执行完成后返回的数据
name:模块的名称
type:模块的类型
e:错误的信息

modules 模块的可选参数

  new VueRouterStore({
    // ...其他的可选参数
    modules: {
      ['模块名称']: {
        pagekey: 'page', // 分页的参数,不设置默认为全局的pagekey
        queryKey: 'query', // this.$route.query同步到this.$data[queryKey],不设置默认为全局的queryKey
        ListData () {
          return {
            // 单独定制当前模块的字段,模块的数据 = Object.assign(baseData, baseListData, 当前模块的基本数据)
          }
        },
        listFetch (next) {
          // 支持直接返回Promise
          next({
            // 更新的data
          })
        },
        detailData () {
          return {
            // 单独定制当前模块的字段,模块的数据 = Object.assign(baseData, baseDetailData, 当前模块的基本数据)
          }
        },
        detailFetch (next) {
          // 支持直接返回Promise
          next({
            // 更新的data
          })
        }
      }
    }
  })