New:Socket for Asana Is Now Available.Learn more
Get Started

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路由权限插件

npmnpm
Version
1.0.2
Version published
Weekly downloads
6
500%
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 20 Oct 2022

Related posts