hupeng
5 years ago
3 changed files with 64 additions and 0 deletions
@ -0,0 +1,30 @@
|
||||
<template> |
||||
<div v-loading="loading" :style="'height:'+ height"> |
||||
<iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" /> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
export default { |
||||
props: { |
||||
src: { |
||||
type: String, |
||||
required: true |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
height: document.documentElement.clientHeight - 94.5 + 'px;', |
||||
loading: true |
||||
} |
||||
}, |
||||
mounted: function() { |
||||
setTimeout(() => { |
||||
this.loading = false |
||||
}, 230) |
||||
const that = this |
||||
window.onresize = function temp() { |
||||
that.height = document.documentElement.clientHeight - 94.5 + 'px;' |
||||
} |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,13 @@
|
||||
import permission from './permission' |
||||
|
||||
const install = function(Vue) { |
||||
Vue.directive('permission', permission) |
||||
} |
||||
|
||||
if (window.Vue) { |
||||
window['permission'] = permission |
||||
Vue.use(install); // eslint-disable-line
|
||||
} |
||||
|
||||
permission.install = install |
||||
export default permission |
@ -0,0 +1,21 @@
|
||||
import store from '@/store' |
||||
|
||||
export default { |
||||
inserted(el, binding, vnode) { |
||||
const { value } = binding |
||||
const roles = store.getters && store.getters.roles |
||||
if (value && value instanceof Array && value.length > 0) { |
||||
const permissionRoles = value |
||||
|
||||
const hasPermission = roles.some(role => { |
||||
return permissionRoles.includes(role) |
||||
}) |
||||
|
||||
if (!hasPermission) { |
||||
el.parentNode && el.parentNode.removeChild(el) |
||||
} |
||||
} else { |
||||
throw new Error(`使用方式: v-permission="['admin','editor']"`) |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue