w-web-perm 1.0.19 → 1.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * w-web-perm v1.0.19
2
+ * w-web-perm v1.0.21
3
3
  * (c) 2018-2021 yuda-lyu(semisphere)
4
4
  * Released under the MIT License.
5
5
  */
@@ -925,7 +925,7 @@
925
925
  <br class="clear">
926
926
 
927
927
  <footer>
928
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Sep 24 2024 19:39:53 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
928
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Sep 24 2024 20:21:16 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
929
929
  </footer>
930
930
 
931
931
  <script>prettyPrint();</script>
@@ -1176,7 +1176,7 @@ export default WWebPerm
1176
1176
  <br class="clear">
1177
1177
 
1178
1178
  <footer>
1179
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Sep 24 2024 19:39:53 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1179
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Sep 24 2024 20:21:16 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
1180
1180
  </footer>
1181
1181
 
1182
1182
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -71,7 +71,7 @@
71
71
  <br class="clear">
72
72
 
73
73
  <footer>
74
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Sep 24 2024 19:39:53 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
74
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a> on Tue Sep 24 2024 20:21:16 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
75
75
  </footer>
76
76
 
77
77
  <script>prettyPrint();</script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-web-perm",
3
- "version": "1.0.19",
3
+ "version": "1.0.21",
4
4
  "main": "dist/w-web-perm.umd.js",
5
5
  "dependencies": {
6
6
  "@mdi/js": "^7.4.47",
package/src/perm.mjs CHANGED
@@ -12,6 +12,9 @@ function perm() {
12
12
 
13
13
  //pmd
14
14
  let pmd = null
15
+ let _user = {}
16
+ let _rules = []
17
+ let _kpRule = {}
15
18
 
16
19
  //conn
17
20
  let conn = (url, opt = {}) => {
@@ -43,6 +46,9 @@ function perm() {
43
46
  .then((res) => {
44
47
  // console.log('perm.getPerm then', res)
45
48
  pmd = res
49
+ genUser()
50
+ genRules()
51
+ genKpRule()
46
52
  if (isfun(permSuccess)) {
47
53
  permSuccess(pmd)
48
54
  }
@@ -59,48 +65,57 @@ function perm() {
59
65
  return pm
60
66
  }
61
67
 
62
- //user
63
- let user = get(pmd, `user`, {})
68
+ let isInit = () => {
69
+ return pmd !== null
70
+ }
64
71
 
65
- //rules
66
- let rules = get(pmd, `rules`, [])
72
+ let genUser = () => {
73
+ _user = get(pmd, `user`, {})
74
+ }
67
75
 
68
- //kpRule
69
- let kpRule = {}
70
- each(rules, (v) => {
76
+ let genRules = () => {
77
+ _rules = get(pmd, `rules`, [])
78
+ }
71
79
 
72
- //name
73
- let name = get(v, 'name', '')
74
- if (!isestr(name)) {
75
- return true //跳出換下一個
76
- }
80
+ let genKpRule = () => {
81
+ let kpRule = {}
82
+ each(_rules, (v) => {
77
83
 
78
- //isActive
79
- let _isActive = get(v, 'isActive', '')
80
- let isActive = _isActive === 'y' ? 'y' : 'n'
84
+ //name
85
+ let name = get(v, 'name', '')
86
+ if (!isestr(name)) {
87
+ return true //跳出換下一個
88
+ }
81
89
 
82
- //save
83
- kpRule[name] = isActive
90
+ //isActive
91
+ let _isActive = get(v, 'isActive', '')
92
+ let isActive = _isActive === 'y' ? 'y' : 'n'
93
+
94
+ //save
95
+ kpRule[name] = isActive
84
96
 
85
- })
97
+ })
98
+ _kpRule = kpRule
99
+ }
86
100
 
87
101
  //kp
88
102
  let kp = {
89
103
  conn,
104
+ isInit,
90
105
  getUser: () => {
91
- return user
106
+ return _user
92
107
  },
93
108
  getRules: () => {
94
- return rules
109
+ return _rules
95
110
  },
96
111
  getKpRule: () => {
97
- return kpRule
112
+ return _kpRule
98
113
  },
99
114
  // rule: (key) => {
100
- // return get(kpRule, key, '')
115
+ // return get(_kpRule, key, '')
101
116
  // },
102
117
  active: (key) => {
103
- let _isActive = get(kpRule, key, '')
118
+ let _isActive = get(_kpRule, key, '')
104
119
  let isActive = _isActive === 'y' ? 'y' : 'n'
105
120
  return isActive
106
121
  },