1.0.3 • Published 2 years ago

if-auth v1.0.3

Weekly downloads
-
License
-
Repository
-
Last release
2 years ago

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.