0.0.3 • Published 3 years ago

v-gate v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

v-gate NPM Version

🌱 基于 vue3 + axios + vue-router 实现权限验证.

安装

npm i -S v-gate

使用

// main.js
createAuth({
    router,

    axios: http,

    component404: () => import('@/views/404.vue'),

    async isAuth(to) {
        if (null === permissionRoutes) {
            await http.get('/permission').then(data => {
                permissionRoutes = data.data.routes;
            })
        }
        return permissionRoutes!.some(path => path === to.matched[to.matched.length - 1].path)
    },
});