w-web-sso 1.0.0

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.
Files changed (102) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.github/workflows/ci-test.yml +24 -0
  5. package/.jsdoc +25 -0
  6. package/.vscode/launch.json +20 -0
  7. package/LICENSE +21 -0
  8. package/README.md +25 -0
  9. package/SECURITY.md +5 -0
  10. package/babel.config.js +15 -0
  11. package/dist/css/app.969ad1db.css +1 -0
  12. package/dist/index.tmp +3 -0
  13. package/dist/js/app-legacy.ff64be1c.js +2 -0
  14. package/dist/js/app-legacy.ff64be1c.js.map +1 -0
  15. package/dist/js/app.ff64be1c.js +2 -0
  16. package/dist/js/app.ff64be1c.js.map +1 -0
  17. package/dist/js/chunk-vendors-legacy.0bb7a31b.js +13 -0
  18. package/dist/js/chunk-vendors-legacy.0bb7a31b.js.map +1 -0
  19. package/dist/js/chunk-vendors.0bb7a31b.js +13 -0
  20. package/dist/js/chunk-vendors.0bb7a31b.js.map +1 -0
  21. package/dist/w-web-sso.umd.js +7 -0
  22. package/dist/w-web-sso.umd.js.map +1 -0
  23. package/docs/WWebSso.html +938 -0
  24. package/docs/WWebSso.mjs.html +721 -0
  25. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  26. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  27. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  28. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  29. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  30. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  31. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  32. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  35. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  36. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  37. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  38. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  39. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  40. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  41. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  42. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  43. package/docs/index.html +84 -0
  44. package/docs/scripts/collapse.js +39 -0
  45. package/docs/scripts/commonNav.js +28 -0
  46. package/docs/scripts/linenumber.js +25 -0
  47. package/docs/scripts/nav.js +12 -0
  48. package/docs/scripts/polyfill.js +4 -0
  49. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  50. package/docs/scripts/prettify/lang-css.js +2 -0
  51. package/docs/scripts/prettify/prettify.js +28 -0
  52. package/docs/scripts/search.js +99 -0
  53. package/docs/styles/jsdoc.css +776 -0
  54. package/docs/styles/prettify.css +80 -0
  55. package/g.backupDb.mjs +10 -0
  56. package/g.getSettings.mjs +17 -0
  57. package/g.initialData.mjs +94 -0
  58. package/g.initialTestData.mjs +21 -0
  59. package/g.mOrm.mjs +24 -0
  60. package/g.provideUsers.mjs +45 -0
  61. package/package.json +70 -0
  62. package/public/index.html +30 -0
  63. package/script.txt +22 -0
  64. package/server/WWebSso.mjs +649 -0
  65. package/server/hashPassword.mjs +27 -0
  66. package/server/proc.mjs +543 -0
  67. package/server/provideUsers.mjs +68 -0
  68. package/src/App.vue +123 -0
  69. package/src/components/Common/CheckYes.vue +85 -0
  70. package/src/components/Common/CheckYesNo.vue +91 -0
  71. package/src/components/Common/LabelItem.vue +106 -0
  72. package/src/components/Common/LoadingWinBar.vue +115 -0
  73. package/src/components/Layout.vue +160 -0
  74. package/src/components/LayoutContent.vue +193 -0
  75. package/src/components/LayoutContentUsers.vue +498 -0
  76. package/src/components/LayoutState.vue +91 -0
  77. package/src/components/PageLogin.vue +524 -0
  78. package/src/components/VeUser.vue +446 -0
  79. package/src/components/ruleGroup.vue +645 -0
  80. package/src/main.js +97 -0
  81. package/src/plugins/mDataSelectorSchema.mjs +30 -0
  82. package/src/plugins/mDataSupport.mjs +23 -0
  83. package/src/plugins/mShare.mjs +229 -0
  84. package/src/plugins/mUI.mjs +229 -0
  85. package/src/schema/gi.mjs +8 -0
  86. package/src/schema/index.mjs +18 -0
  87. package/src/schema/tables/tokens.mjs +70 -0
  88. package/src/schema/tables/users.mjs +110 -0
  89. package/src/store/actions.mjs +1 -0
  90. package/src/store/getters.mjs +1 -0
  91. package/src/store/index.mjs +25 -0
  92. package/src/store/mutations.mjs +333 -0
  93. package/src/store/types.mjs +15 -0
  94. package/srv.mjs +84 -0
  95. package/tableTags-web-sso.json +1 -0
  96. package/test/all.test.mjs +10 -0
  97. package/toolg/addVersion.mjs +4 -0
  98. package/toolg/cleanFolder.mjs +4 -0
  99. package/toolg/gDistRollup.mjs +36 -0
  100. package/toolg/genEntry.mjs +23 -0
  101. package/toolg/modifyReadme.mjs +4 -0
  102. package/vue.config.js +15 -0
package/src/main.js ADDED
@@ -0,0 +1,97 @@
1
+ import Vue from 'vue'
2
+ import get from 'lodash-es/get.js'
3
+ import WServHapiClient from 'w-serv-hapi/src/WServHapiClient.mjs'
4
+ import WAlert from 'w-component-vue/src/components/WAlert.mjs'
5
+ import domMutation from 'w-component-vue/src/js/domMutation.mjs'
6
+ import domResize from 'w-component-vue/src/js/domResize.mjs'
7
+ import domDragDrop from 'w-component-vue/src/js/domDragDrop.mjs'
8
+ import App from './App.vue'
9
+ import store from './store/index.mjs'
10
+ import ui from './plugins/mUI.mjs'
11
+ import mDataSelectorSchema from './plugins/mDataSelectorSchema.mjs'
12
+ // import mDataSupport from './plugins/mDataSupport.mjs'
13
+ import * as s from './plugins/mShare.mjs'
14
+ import ds from './schema/index.mjs'
15
+ // console.log('ds', ds)
16
+
17
+
18
+ //不提示vue產品
19
+ Vue.config.productionTip = false
20
+
21
+ //$alert
22
+ Vue.prototype.$alert = function() {
23
+ let [msg, type] = arguments
24
+ console.log(msg, type)
25
+ if (msg !== 'close') {
26
+ WAlert(msg, type)
27
+ }
28
+ }
29
+
30
+ //dssm
31
+ let dssm = mDataSelectorSchema(ds)
32
+
33
+ // //dspt
34
+ // let dspt = mDataSupport(Vue.prototype)
35
+
36
+ //prototype
37
+ Vue.prototype.$ui = ui
38
+ Vue.prototype.$t = ui.getKpText
39
+ Vue.prototype.$s = s
40
+ Vue.prototype.$dssm = dssm
41
+ // Vue.prototype.$dspt = dspt
42
+ // Vue.prototype.$ds = ds
43
+ Vue.prototype.$dg = {}
44
+
45
+ //directive
46
+ Vue.directive('domresize', domResize())
47
+ Vue.directive('dommutation', domMutation())
48
+ Vue.directive('domdragdrop', domDragDrop())
49
+
50
+ //WServHapiClient
51
+ let bFirstSync = false
52
+ WServHapiClient({
53
+ showLog: false,
54
+ getUrl: () => {
55
+ return window.location.origin + window.location.pathname
56
+ },
57
+ useWaitToken: false,
58
+ getToken: () => {
59
+ // let token = get(Vue.prototype, `$store.state.userToken`, '')
60
+ // console.log('getToken', token)
61
+ // return token
62
+ return ''
63
+ },
64
+ getServerMethods: (_fapi) => {
65
+ console.log('$fapi', _fapi)
66
+ Vue.prototype.$fapi = _fapi
67
+ _fapi.getWebInfor() //已有fapi時優先取得web資訊
68
+ .then((wi) => {
69
+ console.log('$fapi getWebInfor', wi)
70
+ Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateWebInfor, wi)
71
+ ui.setLang() //因更新webInfor得要重刷語系才能依照語言取得顯示文字
72
+ })
73
+ .catch((err) => {
74
+ console.log(err)
75
+ })
76
+ },
77
+ recvData: (r) => {
78
+ console.log('sync data', r.tableName, r.data)
79
+ Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateTableData, r)
80
+ },
81
+ getAfterUpdateTableTags: (r) => {
82
+ // console.log('getAfterUpdateTableTags', r, 'needToRefresh', JSON.stringify(r.oldTableTags) !== JSON.stringify(r.newTableTags))
83
+ if (bFirstSync) {
84
+ return
85
+ }
86
+ bFirstSync = true
87
+ console.log('first-sync')
88
+ Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateSyncState, true)
89
+ },
90
+ })
91
+
92
+ //new
93
+ new Vue({
94
+ store,
95
+ render: h => h(App)
96
+ }).$mount('#app')
97
+
@@ -0,0 +1,30 @@
1
+ import get from 'lodash-es/get.js'
2
+ import find from 'lodash-es/find.js'
3
+ import isestr from 'wsemi/src/isestr.mjs'
4
+
5
+
6
+ function mDataSelectorSchema(ds, opt = {}) {
7
+
8
+ function getTableInforBy(keyFind, valueFind, keyPick) {
9
+ let r = find(ds, { [keyFind]: valueFind })
10
+ if (!r) {
11
+ r = ''
12
+ }
13
+ if (isestr(keyPick)) {
14
+ r = get(r, keyPick, '')
15
+ }
16
+ return r
17
+ }
18
+
19
+ function getTableChtByKey(valueFind) {
20
+ return getTableInforBy('keyTable', valueFind, 'tableNameCht')
21
+ }
22
+
23
+ return {
24
+ getTableInforBy,
25
+ getTableChtByKey,
26
+ }
27
+ }
28
+
29
+
30
+ export default mDataSelectorSchema
@@ -0,0 +1,23 @@
1
+ // import get from 'lodash-es/get.js'
2
+ // import each from 'lodash-es/each.js'
3
+ // import map from 'lodash-es/map.js'
4
+ // import cloneDeep from 'lodash-es/cloneDeep.js'
5
+ // import isestr from 'wsemi/src/isestr.mjs'
6
+ // import isfun from 'wsemi/src/isfun.mjs'
7
+ // import iseobj from 'wsemi/src/iseobj.mjs'
8
+ // import isearr from 'wsemi/src/isearr.mjs'
9
+ // import cint from 'wsemi/src/cint.mjs'
10
+
11
+
12
+ function mDataSupport(vo) {
13
+
14
+
15
+ return {
16
+
17
+ // fun,
18
+
19
+ }
20
+ }
21
+
22
+
23
+ export default mDataSupport
@@ -0,0 +1,229 @@
1
+ //前後端共用函數區
2
+ import JSON5 from 'json5'
3
+ import get from 'lodash-es/get.js'
4
+ import each from 'lodash-es/each.js'
5
+ import map from 'lodash-es/map.js'
6
+ import find from 'lodash-es/find.js'
7
+ import join from 'lodash-es/join.js'
8
+ import cloneDeep from 'lodash-es/cloneDeep.js'
9
+ import takeRight from 'lodash-es/takeRight.js'
10
+ import dropRight from 'lodash-es/dropRight.js'
11
+ import sortBy from 'lodash-es/sortBy.js'
12
+ import sep from 'wsemi/src/sep.mjs'
13
+ import iseobj from 'wsemi/src/iseobj.mjs'
14
+ import haskey from 'wsemi/src/haskey.mjs'
15
+ import composeToTree from 'wsemi/src/composeToTree.mjs'
16
+
17
+
18
+ //dlm
19
+ let dlm = '/'
20
+
21
+
22
+ function getAllBlocks(targets) {
23
+
24
+ //rs
25
+ let rs = map(targets, (v) => {
26
+
27
+ //text, parentId
28
+ let s = sep(v.id, dlm) //[tag:dlm]
29
+ let text = get(takeRight(s), 0) //取最後節點
30
+ s = dropRight(s, 1)
31
+ let parentId = join(s, dlm) //[tag:dlm] 取父節點
32
+
33
+ return {
34
+ ...v,
35
+ idTemp: v.id,
36
+ parentId,
37
+ text,
38
+ }
39
+ })
40
+ // console.log('rs', rs)
41
+
42
+ //sortBy
43
+ rs = sortBy(rs, 'order')
44
+ // console.log('rs sortBy', rs)
45
+
46
+ return rs
47
+ }
48
+
49
+
50
+ function getTreeBlocks(targets) {
51
+
52
+ //getAllBlocks
53
+ let blocks = getAllBlocks(targets)
54
+ // console.log('blocks', blocks)
55
+
56
+ //opt
57
+ let opt = {
58
+ bindKey: 'id',
59
+ bindParent: 'parentId',
60
+ bindChildren: 'children',
61
+ saveExtProps: true,
62
+ }
63
+
64
+ //composeToTree
65
+ let r
66
+ try {
67
+ r = composeToTree(blocks, opt)
68
+ }
69
+ catch (err) {
70
+ console.log(err)
71
+ }
72
+ // console.log('treeBlocks', cloneDeep(r))
73
+
74
+ return r
75
+ }
76
+
77
+
78
+ function getUserGroups(user, ruleGroups) {
79
+
80
+ //userGroups
81
+ let ruleGroupsIds = get(user, 'ruleGroupsIds', '')
82
+
83
+ //sep
84
+ let s = sep(ruleGroupsIds, ';')
85
+
86
+ //gs
87
+ let gs = []
88
+ each(s, (id) => {
89
+ let g = find(ruleGroups, { id })
90
+ if (iseobj(g)) {
91
+ gs.push(g)
92
+ }
93
+ })
94
+
95
+ //add rules
96
+ gs = map(gs, (g) => {
97
+ let rules = JSON5.parse(g.crules)
98
+ g.rules = rules
99
+ return g
100
+ })
101
+
102
+ return gs
103
+ }
104
+
105
+
106
+ function getTargetsByGroup(targets, group) {
107
+
108
+ //cloneDeep
109
+ targets = cloneDeep(targets)
110
+
111
+ //sortBy
112
+ targets = sortBy(targets, 'order')
113
+
114
+ //cloneDeep
115
+ group = cloneDeep(group)
116
+
117
+ //rules
118
+ let rules = JSON5.parse(group.crules)
119
+
120
+ //rulesDisplay
121
+ let rulesDisplay = {}
122
+ let ks = ['show', 'active']
123
+ each(ks, (k) => {
124
+
125
+ //___all___
126
+ let def = get(rules, `___all___.${k}`)
127
+ def = (def === 'y') ? 'y' : 'n'
128
+
129
+ //other props
130
+ each(targets, (v) => {
131
+
132
+ //krule
133
+ let krule = v.id
134
+
135
+ //check
136
+ if (!rulesDisplay[krule]) {
137
+ rulesDisplay[krule] = {}
138
+ }
139
+
140
+ //rule
141
+ let rule = rules[krule]
142
+
143
+ //r
144
+ let r = null
145
+
146
+ //b
147
+ let b = get(rule, `${k}`)
148
+ if (b === 'y' || b === 'n') {
149
+ r = b
150
+ }
151
+ else {
152
+ r = def
153
+ }
154
+
155
+ //save
156
+ rulesDisplay[krule][k] = r //因krule內含有「.」故不能用set
157
+
158
+ })
159
+
160
+ })
161
+ // console.log('rulesDisplay', rulesDisplay)
162
+
163
+ return rulesDisplay
164
+ }
165
+
166
+
167
+ function getUserRules(user, ruleGroups, targets) {
168
+ //依照使用者所允許之ruleGroups轉出對全部targets權限
169
+
170
+ //ruleGroupsIds
171
+ let ruleGroupsIds = get(user, 'ruleGroupsIds', '')
172
+
173
+ //getUserGroups
174
+ let gs = getUserGroups(user, ruleGroups)
175
+ // console.log('gs', gs)
176
+
177
+ //ruleGroupsNames
178
+ let ruleGroupsNames = map(gs, 'name')
179
+ ruleGroupsNames = join(ruleGroupsNames, ';')
180
+
181
+ //getTargetsByGroup
182
+ let rulesDisplay = {}
183
+ each(gs, (g) => {
184
+ let r = getTargetsByGroup(targets, g)
185
+ each(r, (v, k) => {
186
+
187
+ //check
188
+ if (!haskey(rulesDisplay, k)) {
189
+ rulesDisplay[k] = {}
190
+ }
191
+
192
+ //merge
193
+ let ks = ['show', 'active']
194
+ each(ks, (kk) => {
195
+ let bOld = rulesDisplay[k][kk]
196
+ let bNew = r[k][kk]
197
+ if (bOld === 'y') {
198
+ //不用覆寫
199
+ }
200
+ else {
201
+ //需覆寫
202
+ if (bNew === 'y') {
203
+ rulesDisplay[k][kk] = 'y'
204
+ }
205
+ else {
206
+ rulesDisplay[k][kk] = 'n'
207
+ }
208
+ }
209
+ })
210
+
211
+ })
212
+ })
213
+ // console.log('rulesDisplay', rulesDisplay)
214
+
215
+ return {
216
+ ruleGroupsIds,
217
+ ruleGroupsNames,
218
+ rules: rulesDisplay,
219
+ }
220
+ }
221
+
222
+
223
+ export {
224
+ getAllBlocks,
225
+ getTreeBlocks,
226
+ // getUserGroups,
227
+ // getTargetsByGroup,
228
+ getUserRules
229
+ }
@@ -0,0 +1,229 @@
1
+ import Vue from 'vue'
2
+ import min from 'lodash-es/min.js'
3
+ import size from 'lodash-es/size.js'
4
+ import take from 'lodash-es/take.js'
5
+ import isEqual from 'lodash-es/isEqual.js'
6
+ import uniq from 'lodash-es/uniq.js'
7
+ import set from 'lodash-es/set.js'
8
+ import get from 'lodash-es/get.js'
9
+ import each from 'lodash-es/each.js'
10
+ import map from 'lodash-es/map.js'
11
+ import filter from 'lodash-es/filter.js'
12
+ import last from 'lodash-es/last.js'
13
+ import split from 'lodash-es/split.js'
14
+ import join from 'lodash-es/join.js'
15
+ import drop from 'lodash-es/drop.js'
16
+ import dropRight from 'lodash-es/dropRight.js'
17
+ import groupBy from 'lodash-es/groupBy.js'
18
+ import sortBy from 'lodash-es/sortBy.js'
19
+ import cloneDeep from 'lodash-es/cloneDeep.js'
20
+ import cint from 'wsemi/src/cint.mjs'
21
+ import delay from 'wsemi/src/delay.mjs'
22
+ import isarr from 'wsemi/src/isarr.mjs'
23
+ import isestr from 'wsemi/src/isestr.mjs'
24
+ import isfun from 'wsemi/src/isfun.mjs'
25
+ import iseobj from 'wsemi/src/iseobj.mjs'
26
+ import isearr from 'wsemi/src/isearr.mjs'
27
+ import isEle from 'wsemi/src/isEle.mjs'
28
+ import strleft from 'wsemi/src/strleft.mjs'
29
+ import strdelleft from 'wsemi/src/strdelleft.mjs'
30
+ import sep from 'wsemi/src/sep.mjs'
31
+ import aes2str from 'wsemi/src/aes2str.mjs'
32
+ import str2aes from 'wsemi/src/str2aes.mjs'
33
+ import haskey from 'wsemi/src/haskey.mjs'
34
+ import genPm from 'wsemi/src/genPm.mjs'
35
+ import pmSeries from 'wsemi/src/pmSeries.mjs'
36
+ import waitFun from 'wsemi/src/waitFun.mjs'
37
+ import browserView from 'wsemi/src/browserView.mjs'
38
+ import arrHas from 'wsemi/src/arrHas.mjs'
39
+ import arrSort from 'wsemi/src/arrSort.mjs'
40
+ import arrInsert from 'wsemi/src/arrInsert.mjs'
41
+ import replace from 'wsemi/src/replace.mjs'
42
+ import timemsTZ2past from 'wsemi/src/timemsTZ2past.mjs'
43
+ import convertToTree from 'wsemi/src/convertToTree.mjs'
44
+ // import WUiDwload from 'w-ui-dwload/src/WUiDwload.mjs'
45
+
46
+
47
+ let vo = Vue.prototype
48
+
49
+
50
+ function setVo(vObj) {
51
+ vo = vObj
52
+ }
53
+
54
+
55
+ function updateConnState(connState) {
56
+ vo.$store.commit(vo.$store.types.UpdateConnState, connState)
57
+ }
58
+
59
+
60
+ function updateLoading(loading) {
61
+ vo.$store.commit(vo.$store.types.UpdateLoading, loading)
62
+ }
63
+
64
+
65
+ function updateViewState(viewState) {
66
+ vo.$store.commit(vo.$store.types.UpdateViewState, viewState)
67
+ }
68
+
69
+
70
+ function updateUserToken(userToken) {
71
+ vo.$store.commit(vo.$store.types.UpdateUserToken, userToken)
72
+ }
73
+
74
+
75
+ function updateUserSelf(userSelf) {
76
+ vo.$store.commit(vo.$store.types.UpdateUserSelf, userSelf)
77
+ }
78
+
79
+
80
+ function forceUpdate() {
81
+ // console.log('call forceUpdate')
82
+
83
+ function broadcast(chs) {
84
+ each(chs, (v) => {
85
+ // console.log(v.$el)
86
+ v.$forceUpdate()
87
+ if (v.$children) {
88
+ broadcast(v.$children)
89
+ }
90
+ })
91
+ }
92
+
93
+ //broadcast, 注意此處需使用更換ui內vo為mounted後的vo, 也就是含元素, 才能使用廣播技術
94
+ broadcast(vo.$children)
95
+
96
+ }
97
+
98
+
99
+ function setLang(lang = null) {
100
+ // console.log('call setLang')
101
+
102
+ //check lang, 若有輸入才commit
103
+ if (isestr(lang)) {
104
+ vo.$store.commit(vo.$store.types.UpdateLang, lang)
105
+ }
106
+
107
+ //getKpLang, 切換lang得調用getKpLang重算kpText
108
+ getKpLang()
109
+
110
+ //forceUpdate
111
+ forceUpdate()
112
+
113
+ }
114
+
115
+
116
+ function getKpLang() {
117
+ // console.log('call getKpLang')
118
+
119
+ //merge keyLangs
120
+ let keyLangs = get(vo, '$store.state.keyLangs')
121
+ let webName = get(vo, '$store.state.webInfor.webName')
122
+ let webDescription = get(vo, '$store.state.webInfor.webDescription')
123
+ let kls = {
124
+ ...keyLangs,
125
+ webName: {
126
+ ...webName,
127
+ },
128
+ webDescription: {
129
+ ...webDescription,
130
+ },
131
+ }
132
+
133
+ //lang
134
+ let lang = get(vo, '$store.state.lang')
135
+
136
+ //kpText
137
+ let kpText = {}
138
+ each(kls, (v, k) => {
139
+ kpText[k] = v[lang]
140
+ })
141
+
142
+ //commit
143
+ vo.$store.commit(vo.$store.types.UpdateKpText, kpText)
144
+
145
+ return kpText
146
+ }
147
+
148
+
149
+ function getKpText(key) {
150
+ // console.log('call getKpText')
151
+ let kpText = get(vo, '$store.state.kpText')
152
+ return get(kpText, key, '')
153
+ }
154
+
155
+
156
+ function gv(o, k, cv = null) {
157
+ let r = get(o, k, '')
158
+ if (!isestr(r)) {
159
+ let def = getKpText('empty')
160
+ return def
161
+ }
162
+ if (isfun(cv)) {
163
+ r = cv(r)
164
+ }
165
+ return r
166
+ }
167
+
168
+
169
+ function syncHeight() {
170
+
171
+ //heightToolbar
172
+ let heightToolbar = get(vo, '$store.state.heightToolbar')
173
+
174
+ //heightAppEff
175
+ let heightAppEff = window.innerHeight - heightToolbar
176
+
177
+ //commit
178
+ // vo.$store.commit(vo.$store.types.UpdateHeightToolbar, heightToolbar)
179
+ vo.$store.commit(vo.$store.types.UpdateHeightApp, window.innerHeight)
180
+ vo.$store.commit(vo.$store.types.UpdateHeightAppEff, heightAppEff)
181
+
182
+ return ''
183
+ }
184
+
185
+
186
+ async function waitData(t = 0) {
187
+
188
+ //delay
189
+ if (t > 0) {
190
+ await delay(t)
191
+ }
192
+
193
+ //waitFun, 等待dsrl模組掛載
194
+ await waitFun(() => {
195
+ return iseobj(get(vo, '$dsrl'))
196
+ })
197
+
198
+ //等待前端第一次同步完畢數據
199
+ await waitFun(() => {
200
+ return get(vo, '$store.state.syncState')
201
+ })
202
+
203
+ }
204
+
205
+
206
+ let mUI = {
207
+
208
+ setVo,
209
+
210
+ updateConnState,
211
+ updateLoading,
212
+ updateViewState,
213
+ updateUserToken,
214
+ updateUserSelf,
215
+ forceUpdate,
216
+
217
+ setLang,
218
+ getKpLang,
219
+ getKpText,
220
+
221
+ gv,
222
+ syncHeight,
223
+
224
+ waitData,
225
+
226
+ }
227
+
228
+
229
+ export default mUI
@@ -0,0 +1,8 @@
1
+ import genIndex from 'w-data-collector/src/genIndex.mjs'
2
+
3
+
4
+ //genIndex
5
+ genIndex('./src/schema/tables', './src/schema')
6
+
7
+
8
+ //node --experimental-modules ./src/schema/gi.mjs
@@ -0,0 +1,18 @@
1
+ import tokens from './tables/tokens.mjs'
2
+ import users from './tables/users.mjs'
3
+ import build from 'w-data-collector/src/build.mjs'
4
+
5
+
6
+ let cs = {
7
+ tokens,
8
+ users,
9
+ }
10
+
11
+ //ds
12
+ let ds = {}
13
+ for (let k in cs) {
14
+ ds[k] = build(cs[k], { useCreateStorage: false })
15
+ }
16
+
17
+
18
+ export default ds
@@ -0,0 +1,70 @@
1
+ import map from 'lodash-es/map.js'
2
+ import keys from 'lodash-es/keys.js'
3
+ import genID from 'wsemi/src/genID.mjs'
4
+ import dtmapping from 'wsemi/src/dtmapping.mjs'
5
+ import dtpick from 'wsemi/src/dtpick.mjs'
6
+ import nowms2str from 'wsemi/src/nowms2str.mjs'
7
+ import now2strp from 'wsemi/src/now2strp.mjs'
8
+ import ot from 'dayjs'
9
+
10
+
11
+ let keyTable = 'tokens'
12
+ let tableNameCht = '金鑰'
13
+ let tableNameEng = 'Tokens'
14
+
15
+
16
+ let settings = {
17
+ id: {
18
+ pk: true,
19
+ name: '主鍵',
20
+ type: 'STRING',
21
+ },
22
+ token: {
23
+ name: '金鑰',
24
+ type: 'STRING',
25
+ },
26
+ userId: {
27
+ name: '使用者主鍵',
28
+ type: 'STRING',
29
+ },
30
+ timeCreate: {
31
+ name: '創建時間',
32
+ type: 'STRING',
33
+ },
34
+ timeEnd: {
35
+ name: '到期時間',
36
+ type: 'STRING',
37
+ },
38
+ timeUpdate: {
39
+ name: '更新時間',
40
+ type: 'STRING',
41
+ },
42
+ }
43
+
44
+ let funNew = (ndata = {}) => {
45
+ let o = dtmapping(ndata, keys(settings))
46
+ o.id = `${now2strp()}-${genID()}`
47
+ o.token = `${now2strp()}-${genID()}`
48
+ o.timeCreate = nowms2str()
49
+ o.timeEnd = ot().add(30, 'minute').format()
50
+ o.timeUpdate = o.timeCreate
51
+ return o
52
+ }
53
+
54
+ let funTest = () => {
55
+ let rs = []
56
+ return rs
57
+ }
58
+
59
+ let tab = {
60
+ keyTable,
61
+ tableNameCht,
62
+ tableNameEng,
63
+ settings,
64
+ funNew,
65
+ funTest,
66
+ }
67
+
68
+
69
+ export default tab
70
+