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

@xysfe/admin-menu

v2.4.4

Published

``` npm install @xysfe/admin-menu -S ``` ## 如何使用

Downloads

9

Readme

@xys/admin-menu

安装

npm install @xysfe/admin-menu -S

如何使用

简单使用

必须传入router实例,不然会报错

import router from './router'
import { AdminContainer, auth } from '@xysfe/admin-menu'

// 插件控制了路由beforeEach,并在vue原型上挂载了$auth和$isInDepartment两个方法
Vue.use(AdminContainer, { router })
// 权限校验方法,根据权限id返回是否有权限, 等同于在vue原型上的$auth
const hasPermit = auth(10000) 

组件的注册名称为admin-container


<template>
    <admin-container
            :env="env">
        <div class="router-view-container">
            <router-view />
        </div>
    </admin-container>
</template>

<script>
import { hostConf } from '@xysfe/util'

export default {
    name: 'Layout',
    computed: {
        // 控制logo展示
        env () {
            // 100: 小雨伞dev
            // 600: 小雨伞beta
            // 500: 小雨伞alpha
            // 200: 小雨伞idc
            // 700: 创信beta
            // 800:创信idc
            // 1000: 木成林beta
            // 900: 木成林idc
            const ENVMARK = parseInt(hostConf.ENVMARK)
            if (ENVMARK === 700 || ENVMARK === 800) {
                return 2 // 创信logo
            } else if (ENVMARK === 1000 || ENVMARK === 900) {
                return 3 // 木成林logo
            }
            return 1 // 小雨伞logo
        }
    }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
    .router-view-container {
        background: #F1F3FA;
        padding: 30px;
        min-height: 100%;
        box-sizing: border-box;
    }
</style>

进阶使用

import router from './router'
import { AdminContainer } from '@xysfe/admin-menu'

Vue.use(AdminContainer, {
  router,
  beforeEach (to, from, next, auth) {
    if (to.path === '/cpsAuth/accountLogout') {
      next()
    } else {
      auth()
    }
  }
})

beforeEach方法选填。 beforeEach钩子和router本身的钩子使用方式类似,但是添加了第四个参数auth。 执行auth方法可以对页面权限进行对应的校验,通过后进入页面。 也可以跳过auth,直接执行next。

<template>
  <p v-auth="999999">
     无权限999999
  </p>
</template>

v-auth 指令 可以通过使用v-auth指令,传入权限id来隐藏或展示该dom节点 暂时只支持传入单个权限id

开发

npm run serve

打包编译

npm run lib