UNPKG

xlb-main-login

Version:

``` yarn install ```

31 lines (28 loc) 1.01 kB
function plugin(Vue) { if (plugin.installed) { return } !Vue.prototype.$auth && Object.defineProperties(Vue.prototype, { $auth: { get() { const _this = this return (permission) => { const nameList = _this.$router.currentRoute.name?.split('-') || [] const [navName, moduleName, pageName] = [...nameList] if (pageName) { const module = _this.$store.getters.permissions.find((item) => item.name === navName)?.children || [] const page = module.find((item) => item.name === moduleName)?.children || [] const actions = page.find((item) => item.name === pageName)?.url || '' const actionList = actions.split(':') if (actionList.includes(permission) || actionList.includes('*')) { return true } } return false } }, }, }) } export default plugin