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

umi-plugin-uzai-auth

v2.0.5

Published

悠哉权限插件

Downloads

255

Readme

umi-plugin-uzai-auth

umi-plugin-uzai-auth (umi 权限插件)

安装

# or yarn
$ npm install umi-plugin-uzai-auth

流程图

点击查看

使用

Configure in .umirc.js,

export default {
  auth: {
    namesData: {}, //路由名称对象
    upload: true, //是否开启上传
    url: '/xxx/xx', //上传地址http
    appKey: '', //应用名称
    password: 'xxxx', //密码
    exclude: ['/', '/login'], //不需要验证权限的地址默认值:["/","/login","/home"]
  },
};

路由配置

{
    path: '/page/home',
    name: 'page',//用于匹配namesData对象
    auth: 'page:auth',//路由权限
    component: '../page/index',
    pKey: 'appTest',//应用名称
    componentAuth: [
    'component:auth',
    ],//组件权限
    apiAuth:[{
    path:"/api",
    auth:"api:auth"
  }]//api权限
}//同一权限类型不能存在重复权限

组件说明

AuthComponent

参数 children:子组件
参数 authKey:权限 key(不传则不验证)
参数 pKey:应用 key(不传则不验证)
参数 style:样式

PKeyAuthComponent

参数 children:子组件
参数 pKey:应用 key(不传则不验证)

AuthSettingComponent (开启设置模式)

参数 children:子组件
参数 onChange:监听页面权限设置改变(auth:string)=>void
参数 contextAuthData:当前需要验证的权限

hooks 说明

useCheckPkeyAndAuth({authObj,authKey:string,pKey:string});//批量验证权限+应用 key

参数 authObj:验证数据源(Record<string, any> []);
参数 authKey:权限 key 字段名(默认 authKey);
参数 pKey:应用 key 字段名(默认 pKey);
返回值:authObj

useCheckAuth({settingAuth,authKey,pKey});//单个验证权限+应用 key

参数 settingAuth:设置模式独有,慎用(Record<string, any>[]);
参数 authKey:权限 key 参数 pKey:应用 key
返回值:bool

useCheckAuthObj({authObj,authKey:string})//批量验证权限

参数 authObj:验证数据源(Record<string, any>[]);
参数 authKey:权限 key 字段名(默认 authKey);
返回值:authObj

usePkeyCheck(pKey:string|string[]);//批量验证应用 key

返回值:为 string 时返回 bool,数组时返回 string[];

useCheckPageAuth();//验证当前页面权限

返回值:403//没有权限

Api 说明

checkAuth(params:ParamsModal|string);//验证权限

返回值:bool
ParamsModal:{pathname,authKey,pKey} //pathname 内部自动创建慎用

checkPkey(pKey:string|string[]);//批量验证应用 key

返回值:为 string 时返回 bool,数组时返回 string[];

getApiAuth(url:string)//获取 api 权限

返回值:string

AppAuthData 说明

项目 authData 数据源
pathAuthData(所有路由权限树)
pKeyList(所有应用 key)
pKeyAuthData(所有应用 key 权限树分类)
rootPathData(当前应用权限树) apiAuthData(当前 api 权限)

LICENSE

MIT