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

@yangsansuan/vue-auth

v1.0.2

Published

vue 权限控制插件

Downloads

6

Readme

安装

npm install @yangsansuan/vue-auth -S

使用

  1. 引入 & 配置
import Auth from '@yangsansuan/vue-auth'
Vue.use(Auth, options)

options为插件的配置项:

{
  globalComponets: true, // 默认开启,给全局组件增加权限控制(包括第三方库,比如element,必须先引入库)
  directive: true, // 默认开启,给vue增加`v-auth`指令
  checker: fn // 权限的校验函数,fn必须返回一个Boolean值,false表示隐藏,fn接受一个参数(参见api)
}

一般来说只需要配置checker即可,此时直接将options配置为checker函数即可:

const checkAuthFn = function(xx){
  // ...
}
Vue.use(auth, checkAuthFn)
  1. 使用
  • 组件上使用

在组件上添加auth属性,其值会注入checker函数中,如果函数返回false则不会渲染此组件

<my-component auth="xx"></my-component>
  • 标签上使用

在组件上添加v-auth指令,其值会注入checker函数中,如果函数返回false则会隐藏并删除此标签

<div v-auth="xxx"></div>

apis

options

  1. globalComponets

Boolean,可选,默认开启。给全局组件增加权限控制,关闭后可能全局组件无法进行权限控制

  1. directive

Boolean,可选,默认开启。给vue增加v-auth指令,在非组件元素上需要使用此指令进行权限控制

  1. checker

Function,必填。权限的校验函数,用户在此函数中判断是否有权限

此函数接受一个参数(由auth属性或v-auth指令提供),并要求返回一个Boolean

wrap

wrap(component)

用来包裹一个组件,返回一个函数式组件,然后使用返回的组件代替原组件在页面使用,这样就可以使用auth属性进行权限控制

regDirective

regDirective()

给vue增加v-auth指令

构建

npm run build

npm发版

  1. 修改package.json中的version
  2. 发布
npm publish