w-web-api 1.0.9 → 1.0.12

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.
package/docs/WWebApi.html CHANGED
@@ -71,7 +71,7 @@
71
71
 
72
72
  <dt class="tag-source">Source:</dt>
73
73
  <dd class="tag-source"><ul class="dummy"><li>
74
- <a href="WWebApi.mjs.html">WWebApi.mjs</a>, <a href="WWebApi.mjs.html#line64">line 64</a>
74
+ <a href="WWebApi.mjs.html">WWebApi.mjs</a>, <a href="WWebApi.mjs.html#line68">line 68</a>
75
75
  </li></ul></dd>
76
76
 
77
77
 
@@ -604,7 +604,7 @@
604
604
  <br class="clear">
605
605
 
606
606
  <footer>
607
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 23:36:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
607
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Apr 17 2022 12:09:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
608
608
  </footer>
609
609
 
610
610
  <script>prettyPrint();</script>
@@ -43,16 +43,20 @@
43
43
  <section>
44
44
  <article>
45
45
  <pre class="prettyprint source linenums"><code>import get from 'lodash/get'
46
- import map from 'lodash/map'
46
+ // import map from 'lodash/map'
47
+ import each from 'lodash/each'
47
48
  import keys from 'lodash/keys'
48
- import cloneDeep from 'lodash/cloneDeep'
49
+ // import cloneDeep from 'lodash/cloneDeep'
49
50
  import j2o from 'wsemi/src/j2o.mjs'
50
51
  import iseobj from 'wsemi/src/iseobj'
51
52
  import isestr from 'wsemi/src/isestr'
52
53
  import ispint from 'wsemi/src/ispint'
53
54
  import isfun from 'wsemi/src/isfun'
54
- import fsIsFolder from 'wsemi/src/fsIsFolder'
55
55
  import cint from 'wsemi/src/cint'
56
+ import strleft from 'wsemi/src/strleft'
57
+ import strdelleft from 'wsemi/src/strdelleft'
58
+ import b642str from 'wsemi/src/b642str'
59
+ import fsIsFolder from 'wsemi/src/fsIsFolder'
56
60
  import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
57
61
  import ds from '../src/schema/index.mjs'
58
62
  import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
@@ -153,6 +157,14 @@ async function WWebApi(WOrm, url, db, opt = {}) {
153
157
  let webName = get(opt, 'webName', {})
154
158
 
155
159
 
160
+ //webDescription
161
+ let webDescription = get(opt, 'webDescription', {})
162
+
163
+
164
+ //webLogo
165
+ let webLogo = get(opt, 'webLogo', {})
166
+
167
+
156
168
  //WServOrm
157
169
  let optWServOrm = {
158
170
  bCheckUser,
@@ -173,6 +185,8 @@ async function WWebApi(WOrm, url, db, opt = {}) {
173
185
  let getWebInfor = (userId) => {
174
186
  return {
175
187
  webName,
188
+ webDescription,
189
+ webLogo,
176
190
  }
177
191
  }
178
192
 
@@ -187,12 +201,44 @@ async function WWebApi(WOrm, url, db, opt = {}) {
187
201
  //parsePayload
188
202
  let parsePayload = (req) => {
189
203
  let inp = get(req, 'payload')
204
+
205
+ //to obj
190
206
  if (isestr(inp)) {
191
207
  inp = j2o(inp)
192
208
  }
193
- if (!iseobj(inp)) {
209
+
210
+ //cv apis for base64
211
+ if (iseobj(inp)) {
212
+
213
+ //spread
214
+ let { levels, apis } = inp
215
+
216
+ //apis
217
+ each(apis, (api, kapi) => {
218
+ console.log(kapi, api.name)
219
+ each(api, (v, k) => {
220
+ console.log(k, v)
221
+ if (isestr(v)) {
222
+ console.log('b1')
223
+ if (strleft(v, 7) === 'base64:') {
224
+ console.log('b2')
225
+ v = strdelleft(v, 7)
226
+ v = b642str(v)
227
+ console.log('bbb inv base64', v)
228
+ apis[kapi][k] = v
229
+ }
230
+ }
231
+ })
232
+ })
233
+
234
+ //resave
235
+ inp = { levels, apis }
236
+
237
+ }
238
+ else {
194
239
  inp = null
195
240
  }
241
+
196
242
  return inp
197
243
  }
198
244
 
@@ -223,15 +269,8 @@ async function WWebApi(WOrm, url, db, opt = {}) {
223
269
  //delAll levels
224
270
  await woItems.apis.delAll({ levels })
225
271
 
226
- //rsApisTemp
227
- let rsApisTemp = cloneDeep(rsApis)
228
- rsApisTemp = map(rsApisTemp, (v) => {
229
- v.levels = levels
230
- return v
231
- })
232
-
233
272
  //insert
234
- let r = await woItems.apis.insert(rsApisTemp)
273
+ let r = await woItems.apis.insert(rsApis)
235
274
 
236
275
  return r
237
276
  }
@@ -367,7 +406,7 @@ export default WWebApi
367
406
  <br class="clear">
368
407
 
369
408
  <footer>
370
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 23:36:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
409
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Apr 17 2022 12:09:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
371
410
  </footer>
372
411
 
373
412
  <script>prettyPrint();</script>
package/docs/index.html CHANGED
@@ -68,7 +68,7 @@
68
68
  <br class="clear">
69
69
 
70
70
  <footer>
71
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Thu Apr 14 2022 23:36:04 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
71
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.10</a> on Sun Apr 17 2022 12:09:30 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
72
72
  </footer>
73
73
 
74
74
  <script>prettyPrint();</script>
package/g.getSettings.mjs CHANGED
@@ -7,7 +7,7 @@ function getSettings() {
7
7
  return {
8
8
  'dbUsername': 'username',
9
9
  'dbPassword': 'password',
10
- 'dbName': 'wapis',
10
+ 'dbName': 'rddmanager_api', //wapis
11
11
  'dbIP': 'localhost',
12
12
  'dbPort': 27017,
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w-web-api",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "main": "dist/w-web-api.umd.js",
5
5
  "dependencies": {
6
6
  "@mdi/js": "^6.6.96",
@@ -1,14 +1,18 @@
1
1
  import get from 'lodash/get'
2
- import map from 'lodash/map'
2
+ // import map from 'lodash/map'
3
+ import each from 'lodash/each'
3
4
  import keys from 'lodash/keys'
4
- import cloneDeep from 'lodash/cloneDeep'
5
+ // import cloneDeep from 'lodash/cloneDeep'
5
6
  import j2o from 'wsemi/src/j2o.mjs'
6
7
  import iseobj from 'wsemi/src/iseobj'
7
8
  import isestr from 'wsemi/src/isestr'
8
9
  import ispint from 'wsemi/src/ispint'
9
10
  import isfun from 'wsemi/src/isfun'
10
- import fsIsFolder from 'wsemi/src/fsIsFolder'
11
11
  import cint from 'wsemi/src/cint'
12
+ import strleft from 'wsemi/src/strleft'
13
+ import strdelleft from 'wsemi/src/strdelleft'
14
+ import b642str from 'wsemi/src/b642str'
15
+ import fsIsFolder from 'wsemi/src/fsIsFolder'
12
16
  import WServHapiServer from 'w-serv-hapi/src/WServHapiServer.mjs'
13
17
  import ds from '../src/schema/index.mjs'
14
18
  import WServOrm from 'w-serv-orm/src/WServOrm.mjs'
@@ -109,6 +113,14 @@ async function WWebApi(WOrm, url, db, opt = {}) {
109
113
  let webName = get(opt, 'webName', {})
110
114
 
111
115
 
116
+ //webDescription
117
+ let webDescription = get(opt, 'webDescription', {})
118
+
119
+
120
+ //webLogo
121
+ let webLogo = get(opt, 'webLogo', {})
122
+
123
+
112
124
  //WServOrm
113
125
  let optWServOrm = {
114
126
  bCheckUser,
@@ -129,6 +141,8 @@ async function WWebApi(WOrm, url, db, opt = {}) {
129
141
  let getWebInfor = (userId) => {
130
142
  return {
131
143
  webName,
144
+ webDescription,
145
+ webLogo,
132
146
  }
133
147
  }
134
148
 
@@ -143,12 +157,44 @@ async function WWebApi(WOrm, url, db, opt = {}) {
143
157
  //parsePayload
144
158
  let parsePayload = (req) => {
145
159
  let inp = get(req, 'payload')
160
+
161
+ //to obj
146
162
  if (isestr(inp)) {
147
163
  inp = j2o(inp)
148
164
  }
149
- if (!iseobj(inp)) {
165
+
166
+ //cv apis for base64
167
+ if (iseobj(inp)) {
168
+
169
+ //spread
170
+ let { levels, apis } = inp
171
+
172
+ //apis
173
+ each(apis, (api, kapi) => {
174
+ console.log(kapi, api.name)
175
+ each(api, (v, k) => {
176
+ console.log(k, v)
177
+ if (isestr(v)) {
178
+ console.log('b1')
179
+ if (strleft(v, 7) === 'base64:') {
180
+ console.log('b2')
181
+ v = strdelleft(v, 7)
182
+ v = b642str(v)
183
+ console.log('bbb inv base64', v)
184
+ apis[kapi][k] = v
185
+ }
186
+ }
187
+ })
188
+ })
189
+
190
+ //resave
191
+ inp = { levels, apis }
192
+
193
+ }
194
+ else {
150
195
  inp = null
151
196
  }
197
+
152
198
  return inp
153
199
  }
154
200
 
@@ -179,15 +225,8 @@ async function WWebApi(WOrm, url, db, opt = {}) {
179
225
  //delAll levels
180
226
  await woItems.apis.delAll({ levels })
181
227
 
182
- //rsApisTemp
183
- let rsApisTemp = cloneDeep(rsApis)
184
- rsApisTemp = map(rsApisTemp, (v) => {
185
- v.levels = levels
186
- return v
187
- })
188
-
189
228
  //insert
190
- let r = await woItems.apis.insert(rsApisTemp)
229
+ let r = await woItems.apis.insert(rsApis)
191
230
 
192
231
  return r
193
232
  }
@@ -0,0 +1,9 @@
1
+ function filePathToCode(c) {
2
+ if (c.indexOf('\\\\') >= 0) {
3
+ return '```' + c + '```'
4
+ }
5
+ return c
6
+ }
7
+
8
+
9
+ export default filePathToCode
@@ -1,5 +1,4 @@
1
1
  import axios from 'axios'
2
- import map from 'lodash/map'
3
2
  import ltdtpick from 'wsemi/src/ltdtpick.mjs'
4
3
 
5
4
 
@@ -26,12 +25,6 @@ async function provideApis(url, levels, apis) {
26
25
  //ltdtpick
27
26
  apis = ltdtpick(apis, ks)
28
27
 
29
- //update levels
30
- apis = map(apis, (v) => {
31
- v.levels = levels
32
- return v
33
- })
34
-
35
28
  //rin
36
29
  let rin = {
37
30
  levels,
package/src/App.vue CHANGED
@@ -28,6 +28,15 @@ export default {
28
28
 
29
29
  }
30
30
  },
31
+ mounted: function() {
32
+ // console.log('mounted')
33
+
34
+ let vo = this
35
+
36
+ //setVo, 更換ui內vo, 才能使用廣播技術, 更換語系才能用廣播通知全部組件forceUpdate
37
+ vo.$ui.setVo(vo)
38
+
39
+ },
31
40
  methods: {
32
41
 
33
42
  resize: function(msg) {
@@ -11,24 +11,20 @@
11
11
  v-if="false"
12
12
  ></WButtonCircle>
13
13
 
14
- <WButtonCircle
15
- :icon="'mdi-menu'"
16
- :tooltip="'cht'"
17
- :shadow="false"
18
- @click="$store.commit($store.types.UpdateLang, 'cht')"
19
- v-if="false"
20
- ></WButtonCircle>
14
+ <div style="padding-left:5px; white-space:nowrap">
15
+ <div style="display:flex; align-items:center;">
21
16
 
22
- <WButtonCircle
23
- :icon="'mdi-menu'"
24
- :tooltip="'eng'"
25
- :shadow="false"
26
- @click="$store.commit($store.types.UpdateLang, 'eng')"
27
- v-if="false"
28
- ></WButtonCircle>
17
+ <div style="padding-right:10px; display:flex; align-items:center;" v-if="webLogo">
18
+ <img style="width:36px; height:36px;" :src="webLogo" />
19
+ </div>
20
+
21
+ <div>
22
+ <div style="font-size:1.2rem; color:#000;">{{webName}}</div>
23
+ <div style="font-size:0.8rem; color:#666;">{{$t('webDescription')}}</div>
24
+ </div>
25
+
26
+ </div>
29
27
 
30
- <div style="padding-left:10px; font-size:1.2rem; color:#000; white-space:nowrap">
31
- <div>{{webName}}</div>
32
28
  </div>
33
29
 
34
30
  <div style="width:100%;"></div>
@@ -54,6 +50,7 @@
54
50
  <script>
55
51
  import get from 'lodash/get'
56
52
  // import cloneDeep from 'lodash/cloneDeep'
53
+ import isestr from 'wsemi/src/isestr.mjs'
57
54
  import WButtonCircle from 'w-component-vue/src/components/WButtonCircle.vue'
58
55
  import WTextSelect from 'w-component-vue/src/components/WTextSelect.vue'
59
56
  import LayoutContent from './LayoutContent.vue'
@@ -89,28 +86,44 @@ export default {
89
86
 
90
87
  }
91
88
  },
92
- computed: {
89
+ beforeMount: function() {
90
+ // console.log('beforeMount')
93
91
 
94
- heightToolbar: function() {
95
- return get(this, `$store.state.heightToolbar`)
96
- },
92
+ let vo = this
97
93
 
98
- kpTexts: function() {
99
- return this.$ui.getKpLang()
94
+ //setLang
95
+ vo.$ui.setLang(vo.tgLangSelect.id)
96
+
97
+ },
98
+ computed: {
99
+
100
+ viewState: function() {
101
+ return get(this, `$store.state.viewState`)
100
102
  },
101
103
 
102
- webName: function() {
103
- let name = get(this, 'kpTexts.webName', this.kpTexts.waitingData)
104
- document.title = name //更換網頁title
105
- return name
104
+ heightToolbar: function() {
105
+ return get(this, `$store.state.heightToolbar`)
106
106
  },
107
107
 
108
- lang: function() {
109
- return get(this, `$store.state.lang`)
108
+ webName: {
109
+ get() {
110
+ let vo = this
111
+ let c = vo.$t('webName')
112
+ // console.log('get webName1', c)
113
+ if (!isestr(c)) {
114
+ c = vo.$t('waitingData')
115
+ }
116
+ // console.log('get webName2', c)
117
+ document.title = c //更換網頁title
118
+ return c
119
+ },
120
+ // set(value) {
121
+ // return value
122
+ // },
110
123
  },
111
124
 
112
- viewState: function() {
113
- return get(this, `$store.state.viewState`)
125
+ webLogo: function() {
126
+ return get(this, `$store.state.webInfor.webLogo`)
114
127
  },
115
128
 
116
129
  },
@@ -120,7 +133,7 @@ export default {
120
133
  // console.log('methods changeLang', msg)
121
134
  let vo = this
122
135
  let lang = msg.id
123
- vo.$store.commit(vo.$store.types.UpdateLang, lang)
136
+ vo.$ui.setLang(lang)
124
137
  },
125
138
 
126
139
  }
@@ -11,7 +11,7 @@
11
11
  style="padding:20px; font-size:0.9rem;"
12
12
  v-else
13
13
  >
14
- {{kpTexts.waitingData}}
14
+ {{$t('waitingData')}}
15
15
  </div>
16
16
 
17
17
  </div>
@@ -49,10 +49,6 @@ export default {
49
49
  },
50
50
  computed: {
51
51
 
52
- kpTexts: function() {
53
- return this.$ui.getKpLang()
54
- },
55
-
56
52
  syncState: function() {
57
53
  return get(this, '$store.state.syncState')
58
54
  },