🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

if-auth

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

if-auth

Vue3路由权限插件

latest
npmnpm
Version
1.0.3
Version published
Weekly downloads
10
25%
Maintainers
1
Weekly downloads
 
Created
Source

if-auth

动态路由解决方案(Vue3)

How to Use 使用

Register Plugin 注册插件

import IfAuth from 'if-auth'
app.use(IfAuth, {store, router, routesMap: [
    {
        home: {
            path: "/home",
            name: 'Home',
            component: () => import(('@/views/demo-one')),
        },
    }
]})

Load Async Routes 加载动态路由

import { useAuth } from 'if-auth'
const $ = useAuth()
const asyncRoutesConfig = [{ router:'home', authority: 'home' } ];
$.loadRoutes(asyncRoutesConfig);

Set Routes Permisson 动态设置路由权限

import { useAuth } from 'if-auth'
const $ = useAuth()
const permissions = [{id: 'home', operation: ['edit', 'read']}]
$.setPerm(permissons)

Page Render 页面渲染

Delete button should be disabled.

<button v-auth="`read`"> Read </button>
<button v-auth="`edit`"> Edit </button>
<button v-auth="`Delete`"> Delete </button>

Config

app.use(IfAuth, config)

  • store
  • router
  • routesMap
  • noAuthClass = 'disabled'
  • noAuthTitle = '无此权限'
  • onAuthSuccess(el) {}
  • onAuthFail(el) {}

Customize configuration

See Configuration Reference.

FAQs

Package last updated on 21 Oct 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts