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

v2-permission

v1.0.3

Published

一个 Vue2 的权限指令

Downloads

1

Readme

v2-permission

Node.js Package

快速上手

安装

npm install v2-permission

引入

import Vue from 'vue';
import permissions from 'v2-permission';

Vue.use(permissions, {
  // 权限 API
  getPermissionsApi: async () => fetch(`/api.json?t=${new Date().getTime()}`).then((res) => res.json()),
});

使用

<!-- 同时存在多个权限 -->
<button v-permission="['orders::add', 'orders::update']">新增&编辑</button>

<!-- 单个校验 -->
<button v-permission="'orders::delete'">删除</button>

API

options

| 参数名 | 类型 | 必填 | 描述 | | ------------------- | ---------- | --- | -------------------- | | getPermissionsApi | Function | 是 | 获取权限的方法 | | checkPermission | Function | 否 | 检查权限的方法 | | name | String | 否 | 自定义指令名称 | | className | String | 否 | 自定义指令隐藏时添加的 class 名称 |

详细内容

期望接口返回值

如果接口不确定是否能够给你这种格式,你可以选择转一下,或者自己写一个checkPermission。

{
    "orders": [
        "add",
        "update",
        "delete",
        "query",
        "detail",
        "enable",
        "disable"
    ]
}

自定义 checkPermission

你如果需要自定义需求,可以在 Use 时传入 checkPermission这样就会将内置的内容覆盖掉,注释如下,接受 value,返回 Boolean。

/**
 * @name checkPermission
 * @param { String | Array } value 权限指令的 value
 * @returns { Boolean } 是否有权限
 */