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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@vue-spark/permission

v1.0.0

Published

Lightweight Vue permission management plugin for component-level access control.

Downloads

9

Readme

@vue-spark/permission

v1.0 开始,@vue-spark/permission 仅作为 @vue-spark/app-helpers/permission 的别名。

问题应该在 vue-spark/app-helpers 中进行报告!

轻量级 Vue3 权限管理插件,专注于组件级权限控制。

English Document

安装

npm i @vue-spark/permission

注册

// main.ts
import { createPermission } from '@vue-spark/permission'
import { createApp } from 'vue'

createApp().use(createPermission())

类型定义

declare const PERMISSION_CODE_ALL = '*'
type PermissionCodeAll = typeof PERMISSION_CODE_ALL

type PermissionCode = PermissionCodeAll | (string & {})

type PermissionOperator = 'or' | 'and'

interface Permission {
  /**
   * 全部已添加的权限编码列表
   */
  get codes(): readonly string[]
  /**
   * 添加权限编码
   */
  add: (codes: PermissionCode | PermissionCode[]) => void
  /**
   * 设置权限编码列表,将会完全覆盖已添加的权限编码列表
   */
  set: (codes: PermissionCode | PermissionCode[]) => void
  /**
   * 清空权限编码列表
   */
  clear: () => void
  /**
   * 检查权限编码
   * @param codes 权限编码
   * @param op 操作符,默认为 `or`
   * @returns 检查结果
   */
  check: (
    codes: PermissionCode | PermissionCode[],
    op?: PermissionOperator,
  ) => boolean
}

使用方式

PermissionGuard

通过组件 <PermissionGuard /> 来进行权限控制。

<script
  setup
  lang="ts"
>
  import { usePermission, PermissionGuard } from '@vue-spark/permission'

  const permission = usePermission()
  permission.set(['list:add', 'list:edit', 'list:delete'])
</script>

<template>
  <!-- 仅当用户有权限时,才显示按钮 -->
  <PermissionGuard
    :codes="['list:delete']"
    op="or"
  >
    <button>删除</button>
  </PermissionGuard>
</template>

vPermission

通过 v-permission 指令来进行权限控制。

<script
  setup
  lang="ts"
>
  import { vPermission, usePermission } from '@vue-spark/permission'

  const permission = usePermission()
  permission.set(['list:add', 'list:edit', 'list:delete'])
</script>

<template>
  <!-- 仅当用户有权限时,才显示按钮 -->
  <button v-permission:or="['list:delete']">删除</button>
</template>

usePermission 或 $permission

<script
  setup
  lang="ts"
>
  import { usePermission } from '@vue-spark/permission'

  const permission = usePermission()
  permission.set(['list:add', 'list:edit', 'list:delete'])
</script>

<template>
  <!-- 仅当用户有权限时,才显示按钮 -->
  <button v-if="permission.check(['list:delete'])">删除</button>

  <!-- 等价于 -->
  <button v-if="$permission.check('list:delete')">删除</button>
</template>

License

MIT License © 2025 leihaohao