if-auth

1.0.3 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i if-auth

Weekly Downloads

1

Version

1.0.3

License

none

Unpacked Size

18.2 kB

Total Files

6

Last publish

Collaborators

  • alibob