access_control_vue

### 用法: ```javascript // ajax.js Vue.prototype.$axios = axios

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
00Sep 30, 2018Apr 18, 2018Minified + gzip package size for access_control_vue in KB

Readme

vue access control

用法:

// ajax.js
Vue.prototype.$axios = axios

axios.interceptors.request.use(
    config => {
        // 没有权限
        if (config.haveNoRight) {
            return Promise.reject({
                haveNoRight: true
            })
        }
        // ...
    }
)

// 使用的地方
// ...
import AccessControl from 'access_control_vue'

// 区分生产环境,用以控制AccessControl开关是否打开
const isProduction = process.env.NODE_ENV === 'production' || process.env.NODE_ENV === 'test'

// 异步接口权限限制
AccessControl.syncLimit({
    axios: this.$axios,
    asyncInterface: '异步接口1,异步接口2...',
    switchOn: isProduction
})

// 全局导航守卫
this.$router.beforeEach(
    AccessControl.routerGuard({
        syncInterface: '可访问路由1,可访问路由2...',
        certainPath: '/certainPath/',
        switchOn: isProduction,
        defaultPage: '/welcomePage'
    })
)


If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.