vue-role-acl

0.3.0 • Public • Published

Vue Role Acl 权限管理

vue 的权限管理中间件

Usage

<p v-if="$acl.check('read')">user can read</p>
<p v-if="$acl.check('edit')">user can edit</p>
<p v-if="$acl.check('delete')">user can delete</p>
<p v-if="$acl.check('list')">user can list</p>
<p v-if="$acl.check('read', 'list')">user can read or list</p>
const router = new VueRouter({
  routes: [
    { path: '/read', component: { template: '<p>read</p>' }, meta: { rule: ['read'] } },
    { path: '/edit', component: { template: '<p>edit</p>' }, meta: { rule: ['edit'] } },
    { path: '/delete', component: { template: '<p>delete</p>' }, meta: { rule: ['delete'] } },
    { path: '/list', component: { template: '<p>list</p>' }, meta: { rule: ['list'] } },
    { path: '/public', component: { template: '<p>public</p>' } },
    { path: '/not-found', component: { template: '<p>not-found</p>' } },
  ]
})
 
Vue.use(VueRoleAcl, {
  initial: 'public',
  router,
  notfound: '/not-found',
  rules: {
    '*': ['read'],
    admin: '*',
    login: ['read', 'list'],
    editor: ['read', 'list', 'edit', 'delete'],
  },
})

/vue-role-acl/

    Package Sidebar

    Install

    npm i vue-role-acl

    Weekly Downloads

    1

    Version

    0.3.0

    License

    Apache-2.0

    Unpacked Size

    17.6 kB

    Total Files

    10

    Last publish

    Collaborators

    • eyasliu