|
@@ -0,0 +1,26 @@
|
|
1
|
+import { useModel } from '@zjxpcyc/vue-tiny-store'
|
|
2
|
+
|
|
3
|
+const shiro = {
|
|
4
|
+ install: (app, options) => {
|
|
5
|
+ const { permissions, getPermission } = useModel('shiro')
|
|
6
|
+
|
|
7
|
+ const removeNode = el => el.parentNode.removeChild(el)
|
|
8
|
+
|
|
9
|
+ app.directive('shiro', (el, binding) => {
|
|
10
|
+ const permission = permissions[binding.value]
|
|
11
|
+ if (typeof permission !== 'boolean') {
|
|
12
|
+ getPermission(props.name).then(x => {
|
|
13
|
+ if (!x) {
|
|
14
|
+ removeNode(el)
|
|
15
|
+ }
|
|
16
|
+ })
|
|
17
|
+ } else {
|
|
18
|
+ if (!permission) {
|
|
19
|
+ removeNode(el)
|
|
20
|
+ }
|
|
21
|
+ }
|
|
22
|
+ })
|
|
23
|
+ }
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+export default shiro
|