w-web-api 1.0.39 → 1.0.41

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 (42) hide show
  1. package/README.md +2 -2
  2. package/db/wapis/apis/data.mdb +0 -0
  3. package/db/wapis/apis/lock.mdb +0 -0
  4. package/dist/css/{app.99a58617.css → app.02bbf3c6.css} +1 -1
  5. package/dist/index.tmp +2 -2
  6. package/dist/js/app-legacy.d2226e7d.js +2 -0
  7. package/dist/js/app-legacy.d2226e7d.js.map +1 -0
  8. package/dist/js/app.d2226e7d.js +2 -0
  9. package/dist/js/app.d2226e7d.js.map +1 -0
  10. package/dist/js/{chunk-vendors.767ef893.js → chunk-vendors-legacy.10dbc55a.js} +3 -3
  11. package/dist/js/chunk-vendors-legacy.10dbc55a.js.map +1 -0
  12. package/dist/js/{chunk-vendors-legacy.767ef893.js → chunk-vendors.10dbc55a.js} +3 -3
  13. package/dist/js/chunk-vendors.10dbc55a.js.map +1 -0
  14. package/dist/w-web-api.umd.js +2 -2
  15. package/dist/w-web-api.umd.js.map +1 -1
  16. package/docs/WWebApi.html +3 -3
  17. package/docs/WWebApi.mjs.html +108 -22
  18. package/docs/index.html +1 -1
  19. package/package.json +6 -6
  20. package/public/index.html +1 -1
  21. package/script.txt +0 -1
  22. package/server/WWebApi.mjs +107 -21
  23. package/server/provideApis.mjs +15 -12
  24. package/src/App.vue +25 -4
  25. package/src/components/Layout.vue +56 -26
  26. package/src/components/LayoutContent.vue +51 -37
  27. package/src/components/LayoutState.vue +20 -8
  28. package/src/main.js +17 -20
  29. package/src/plugins/mLang.mjs +250 -0
  30. package/src/plugins/mUI.mjs +140 -51
  31. package/src/schema/tables/apis.mjs +6 -8
  32. package/src/store/mutations.mjs +8 -102
  33. package/src/store/types.mjs +1 -1
  34. package/srv.mjs +2 -2
  35. package/tableTags.json +1 -1
  36. package/dist/js/app-legacy.f7e293ef.js +0 -2
  37. package/dist/js/app-legacy.f7e293ef.js.map +0 -1
  38. package/dist/js/app.f7e293ef.js +0 -2
  39. package/dist/js/app.f7e293ef.js.map +0 -1
  40. package/dist/js/chunk-vendors-legacy.767ef893.js.map +0 -1
  41. package/dist/js/chunk-vendors.767ef893.js.map +0 -1
  42. package/src/plugins/mDataSupport.mjs +0 -66
@@ -1,4 +1,5 @@
1
1
  import axios from 'axios'
2
+ import get from 'lodash-es/get.js'
2
3
  import ltdtpick from 'wsemi/src/ltdtpick.mjs'
3
4
  import genPm from 'wsemi/src/genPm.mjs'
4
5
 
@@ -32,13 +33,14 @@ async function provideApis(url, group, apis) {
32
33
 
33
34
  //ltdtpick
34
35
  apis = ltdtpick(apis, ks)
36
+ // console.log('apis', apis)
35
37
 
36
38
  //rin
37
39
  let rin = {
38
40
  group,
39
41
  apis,
40
42
  }
41
- // rin = JSON.stringify(rin)
43
+ // console.log('rin', rin)
42
44
 
43
45
  //axios
44
46
  await axios({
@@ -48,20 +50,21 @@ async function provideApis(url, group, apis) {
48
50
  data: rin,
49
51
  })
50
52
  .then((res) => {
51
- // console.log(res)
52
- let r = {
53
- msg: '成功傳輸API清單',
54
- res,
53
+ // console.log('then', res)
54
+ let data = get(res, 'data')
55
+ let state = get(data, 'state')
56
+ let msg = get(data, 'msg', '')
57
+ if (state === 'success') {
58
+ pm.resolve(msg)
55
59
  }
56
- pm.resolve(r)
60
+ else {
61
+ pm.reject(msg)
62
+ }
63
+
57
64
  })
58
65
  .catch((err) => {
59
- // console.log(err)
60
- let r = {
61
- msg: '無法傳輸API清單',
62
- res: err,
63
- }
64
- pm.reject(r)
66
+ // console.log('catch', err)
67
+ pm.reject(err)
65
68
  })
66
69
 
67
70
  return pm
package/src/App.vue CHANGED
@@ -10,6 +10,11 @@
10
10
  <Layout v-if="ready"></Layout>
11
11
  </transition>
12
12
 
13
+ <!--
14
+ <LoadingWinBar></LoadingWinBar>
15
+ <CheckYesNo></CheckYesNo>
16
+ <CheckYes></CheckYes> -->
17
+
13
18
  </div>
14
19
  </template>
15
20
 
@@ -17,6 +22,7 @@
17
22
  import get from 'lodash-es/get.js'
18
23
  import cloneDeep from 'lodash-es/cloneDeep.js'
19
24
  import isestr from 'wsemi/src/isestr.mjs'
25
+ import iseobj from 'wsemi/src/iseobj.mjs'
20
26
  import isDev from 'wsemi/src/isDev.mjs'
21
27
  import wui from 'w-ui-loginout/src/WUiLoginout.mjs'
22
28
  import Layout from './components/Layout.vue'
@@ -41,16 +47,21 @@ export default {
41
47
  //setVo, 更換ui內vo, 才能使用廣播技術, 更換語系才能用廣播通知全部組件forceUpdate
42
48
  vo.$ui.setVo(vo)
43
49
 
50
+ //setLang
51
+ let lang = get(window, '___pmwperm___.language', '')
52
+ vo.$ui.setLang(lang, 'app init') //初始化先讀取html內語系設定進行變更
53
+ // console.log('lang', lang)
54
+
44
55
  function loginSuccess(data) {
45
56
  console.log('login success', cloneDeep(data.user))
46
- vo.$ui.updateConnState('已連線')
57
+ vo.$ui.updateConnState('csLogin')
47
58
  vo.$ui.updateUserToken(data.token)
48
59
  vo.$ui.updateUserSelf(data.user)
49
60
  }
50
61
 
51
62
  function loginError(data) {
52
63
  console.log('login error', cloneDeep(data))
53
- vo.$ui.updateConnState(data.text)
64
+ vo.$ui.updateConnState('csErrLogin')
54
65
  vo.$ui.updateUserToken('')
55
66
  let urlRedirect = get(window, '___pmwapi___.urlRedirect', '')
56
67
  if (!isestr(urlRedirect)) {
@@ -86,8 +97,18 @@ export default {
86
97
  computed: {
87
98
 
88
99
  ready: function() {
89
- let connState = get(this, `$store.state.connState`)
90
- return connState === '已連線'
100
+ //console.log('computed ready')
101
+
102
+ let vo = this
103
+
104
+ let connState = get(vo, `$store.state.connState`)
105
+ let webInfor = get(vo, `$store.state.webInfor`)
106
+
107
+ let b1 = connState === 'csLogin'
108
+ let b2 = iseobj(webInfor)
109
+ let b = b1 && b2
110
+
111
+ return b
91
112
  },
92
113
 
93
114
  },
@@ -16,7 +16,7 @@
16
16
  <div style="display:flex; align-items:center;">
17
17
 
18
18
  <div style="padding-right:10px; display:flex; align-items:center;" v-if="webLogo">
19
- <img style="width:36px; height:36px;" :src="webLogo" />
19
+ <img style="width:36px; _min-width:36px; height:36px;" :src="webLogo" />
20
20
  </div>
21
21
 
22
22
  <div>
@@ -29,13 +29,23 @@
29
29
 
30
30
  <div style="width:100%;"></div>
31
31
 
32
- <div style="padding-right:10px; white-space:nowrap">
32
+ <div
33
+ style="padding-right:10px; white-space:nowrap;"
34
+ v-if="showLangSelect"
35
+ >
33
36
  <WTextSelect
34
37
  style="width:100px;"
35
- :items="tgLangs"
36
- v-model="tgLangSelect"
37
- @input="changeLang"
38
- ></WTextSelect>
38
+ :items="keysLang"
39
+ :value="lang"
40
+ @input="toggleLang"
41
+ >
42
+ <template v-slot:select="props">
43
+ {{getLangText(props.item)}}
44
+ </template>
45
+ <template v-slot:item="props">
46
+ {{getLangText(props.item)}}
47
+ </template>
48
+ </WTextSelect>
39
49
  </div>
40
50
 
41
51
  </div>
@@ -70,30 +80,37 @@ export default {
70
80
 
71
81
  drawer: false, //null,
72
82
 
73
- tgLangs: [
74
- {
75
- id: 'cht',
76
- text: '中文',
77
- },
78
- {
79
- id: 'eng',
80
- text: 'English',
81
- },
83
+ firstSetting: true,
84
+
85
+ showLangSelect: false,
86
+
87
+ keysLang: [
88
+ 'eng',
89
+ 'cht',
82
90
  ],
83
- tgLangSelect: {
84
- id: 'cht',
85
- text: '中文',
91
+ kpLangSelect: {
92
+ 'eng': 'English',
93
+ 'cht': '中文',
86
94
  },
87
95
 
88
96
  }
89
97
  },
90
- beforeMount: function() {
91
- // console.log('beforeMount')
98
+ mounted: function() {
99
+ // console.log('mounted')
92
100
 
93
101
  let vo = this
94
102
 
95
- //setLang
96
- vo.$ui.setLang(vo.tgLangSelect.id)
103
+ //firstSetting
104
+ if (vo.firstSetting) {
105
+ // console.log('webInfor', vo.webInfor)
106
+ let showLanguage = get(vo, 'webInfor.showLanguage', '')
107
+ // console.log('showLanguage', showLanguage)
108
+ vo.showLangSelect = showLanguage === 'y'
109
+ let language = get(vo, 'webInfor.language', '')
110
+ // console.log('language', language)
111
+ vo.$ui.setLang(language, 'layout mounted')
112
+ vo.firstSetting = false
113
+ }
97
114
 
98
115
  },
99
116
  computed: {
@@ -138,11 +155,24 @@ export default {
138
155
  },
139
156
  methods: {
140
157
 
141
- changeLang: function(msg) {
142
- // console.log('methods changeLang', msg)
158
+ getLangText: function(lang) {
159
+ // console.log('methods getLangText', lang)
160
+
161
+ let vo = this
162
+
163
+ let t = get(vo, `kpLangSelect.${lang}`, '')
164
+
165
+ return t
166
+ },
167
+
168
+ toggleLang: function(lang) {
169
+ // console.log('methods toggleLang', lang)
170
+
143
171
  let vo = this
144
- let lang = msg.id
145
- vo.$ui.setLang(lang)
172
+
173
+ //setLang
174
+ vo.$ui.setLang(lang, 'toggle')
175
+
146
176
  },
147
177
 
148
178
  }
@@ -1,9 +1,9 @@
1
1
  <template>
2
2
  <div
3
3
  style="height:100%; width:100%;"
4
- :changeApis="changeApis"
5
4
  v-domresize
6
5
  @domresize="resize"
6
+ :changeApis="changeApis"
7
7
  >
8
8
 
9
9
  <template v-if="syncState">
@@ -25,47 +25,55 @@
25
25
  <template v-slot:drawer="props">
26
26
  <div :style="`height:${props.height}px; background:#fff; position:relative;`">
27
27
 
28
- <WTree
29
- :style="`height:${props.height}px;`"
30
- :viewHeightMax="props.height"
31
- :data="apisTree"
32
- :iconHeight="lineHeightTree"
33
- :defItemHeight="lineHeightTree"
34
- :activable="true"
35
- :itemActive="apiActive"
36
- :funActive="funActive"
37
- :itemTextColorActive="'#000'"
38
- :itemBackgroundColorActive ="'rgba(100,100,100,0.15)'"
39
- >
40
- <template v-slot:item="props">
28
+ <template v-if="apisTree.length>0">
29
+ <WTree
30
+ :style="`height:${props.height}px;`"
31
+ :viewHeightMax="props.height"
32
+ :data="apisTree"
33
+ :iconHeight="lineHeightTree"
34
+ :defItemHeight="lineHeightTree"
35
+ :activable="true"
36
+ :itemActive="apiActive"
37
+ :funActive="funActive"
38
+ :itemTextColorActive="'#000'"
39
+ :itemBackgroundColorActive ="'rgba(100,100,100,0.15)'"
40
+ >
41
+ <template v-slot:item="props">
41
42
 
42
- <div
43
- :style="`display:flex; align-items:center; min-height:${lineHeightTree}px;`"
44
- v-if="props.data.type!=='node'"
45
- >
46
- {{props.data.key}}
47
- </div>
43
+ <div
44
+ :style="`display:flex; align-items:center; min-height:${lineHeightTree}px;`"
45
+ v-if="props.data.type!=='node'"
46
+ >
47
+ {{props.data.key}}
48
+ </div>
48
49
 
49
- <div
50
- :style="`display:flex; align-items:center; min-height:${lineHeightTree}px; cursor:pointer;`"
51
- @click="ckItem(getItemByKey(props.data.text))"
52
- v-else
53
- >
50
+ <div
51
+ :style="`display:flex; align-items:center; min-height:${lineHeightTree}px; cursor:pointer;`"
52
+ @click="ckItem(getItemByKey(props.data.text))"
53
+ v-else
54
+ >
54
55
 
55
- <div style="padding-right:5px;">
56
- <div :style="`padding:0px 6px; font-size:0.7rem; border-radius:10px; border:1px solid #ddd; color:#fff; background:${getMethodColorByKey(props.data.text)};`">
57
- {{getMethodByKey(props.data.text)}}
56
+ <div style="padding-right:5px;">
57
+ <div :style="`padding:0px 6px; font-size:0.7rem; border-radius:10px; border:1px solid #ddd; color:#fff; background:${getMethodColorByKey(props.data.text)};`">
58
+ {{getMethodByKey(props.data.text)}}
59
+ </div>
58
60
  </div>
59
- </div>
60
61
 
61
- <div>
62
- {{$ui.gv(getItemByKey(props.data.text),'name')}}
63
- </div>
62
+ <div>
63
+ {{$ui.gv(getItemByKey(props.data.text),'name')}}
64
+ </div>
64
65
 
65
- </div>
66
+ </div>
66
67
 
67
- </template>
68
- </WTree>
68
+ </template>
69
+ </WTree>
70
+ </template>
71
+ <div
72
+ style="padding:20px; font-size:0.9rem;"
73
+ v-else
74
+ >
75
+ {{$t('waitingData')}}
76
+ </div>
69
77
 
70
78
  <div
71
79
  :style="`position:absolute; top:1px; right:12px;`"
@@ -405,6 +413,7 @@
405
413
  import get from 'lodash-es/get.js'
406
414
  import set from 'lodash-es/set.js'
407
415
  import each from 'lodash-es/each.js'
416
+ import size from 'lodash-es/size.js'
408
417
  import trim from 'lodash-es/trim.js'
409
418
  import find from 'lodash-es/find.js'
410
419
  import cloneDeep from 'lodash-es/cloneDeep.js'
@@ -522,9 +531,16 @@ export default {
522
531
  let vo = this
523
532
 
524
533
  //default
534
+ vo.apiActive = null
535
+ vo.apiSelect = null
525
536
  vo.apisTree = []
526
537
  vo.kpApisTree = {}
527
538
 
539
+ //check
540
+ if (size(vo.apis) === 0) {
541
+ return
542
+ }
543
+
528
544
  //cloneDeep
529
545
  let apis = cloneDeep(vo.apis)
530
546
  // console.log('apis', cloneDeep(apis))
@@ -554,8 +570,6 @@ export default {
554
570
  let tree = convertToTree(tr, { bindRoot: '全部' })
555
571
  // console.log('tree', cloneDeep(tree))
556
572
 
557
- //filepathToTree
558
-
559
573
  //apiSelect, 預先選定api項目, 非tree選單active物件, 因id由convertToTree轉換提供, 故不能直接算得active選單物件id
560
574
  let apiSelect = get(apis, 0, null)
561
575
  // console.log('apiSelect', cloneDeep(apiSelect))
@@ -3,37 +3,49 @@
3
3
  :style="`position:absolute; top:0px; left:0px; width:100%; height:100%; transition:all 0.5s linear; display:flex; align-items:center; justify-content:center;`"
4
4
  >
5
5
 
6
- <template v-if="connState==='已連線' || connState==='連線中...'">
6
+ <template v-if="connState==='csIng'">
7
7
 
8
8
  <img style="width:100px; height:100px;" :src="img_connection">
9
9
 
10
10
  <div style="margin-left:10px;">
11
11
  <div style="color:#aaa;">
12
- {{connState}}
12
+ {{$t('csIng')}}
13
13
  </div>
14
14
  </div>
15
15
 
16
16
  </template>
17
17
 
18
- <template v-else-if="connState==='已登出'">
18
+ <template v-else-if="connState==='csLogin'">
19
+
20
+ <img style="width:100px; height:100px;" :src="img_connection">
21
+
22
+ <div style="margin-left:10px;">
23
+ <div style="color:#aaa;">
24
+ {{$t('csLogin')}}
25
+ </div>
26
+ </div>
27
+
28
+ </template>
29
+
30
+ <template v-else-if="connState==='csLogout'">
19
31
 
20
32
  <img style="width:75px; height:75px;" :src="img_logout">
21
33
 
22
34
  <div style="margin-left:10px;">
23
35
  <div style="color:#aaa;">
24
- {{connState}}
36
+ {{$t('csLogout')}}
25
37
  </div>
26
38
  </div>
27
39
 
28
40
  </template>
29
41
 
30
- <template v-else-if="connState==='無法連線'">
42
+ <template v-else-if="connState==='csErrConn'">
31
43
 
32
44
  <img style="width:75px; height:75px;" :src="img_dissconnection">
33
45
 
34
46
  <div style="margin-left:10px;">
35
47
  <div style="color:#aaa;">
36
- {{connState}}
48
+ {{$t('csErrConn')}}
37
49
  </div>
38
50
  </div>
39
51
 
@@ -45,7 +57,7 @@
45
57
 
46
58
  <div style="margin-left:10px;">
47
59
  <div style="color:#aaa;">
48
- {{connState}}
60
+ {{$t('csErrLogin')}}
49
61
  </div>
50
62
  </div>
51
63
 
@@ -55,7 +67,7 @@
55
67
  </template>
56
68
 
57
69
  <script>
58
- import get from 'lodash-es/get.js'
70
+ import get from 'lodash-es/get.js'
59
71
 
60
72
 
61
73
  export default {
package/src/main.js CHANGED
@@ -13,7 +13,6 @@ import App from './App.vue'
13
13
  import store from './store/index.mjs'
14
14
  import ui from './plugins/mUI.mjs'
15
15
  import mDataSelectorSchema from './plugins/mDataSelectorSchema.mjs'
16
- import mDataSupport from './plugins/mDataSupport.mjs'
17
16
  import * as s from './plugins/mShare.mjs'
18
17
  import ds from './schema/index.mjs'
19
18
  // console.log('globalState', globalState)
@@ -35,16 +34,12 @@ Vue.prototype.$alert = function() {
35
34
  //dssm
36
35
  let dssm = mDataSelectorSchema(ds)
37
36
 
38
- //dspt
39
- let dspt = mDataSupport(Vue.prototype)
40
-
41
37
  //prototype
42
38
  Vue.prototype.$ui = ui
43
39
  Vue.prototype.$t = ui.getKpText
44
40
  Vue.prototype.$s = s
45
41
  Vue.prototype.$dssm = dssm
46
- Vue.prototype.$dspt = dspt
47
- // Vue.prototype.$ds = ds
42
+ Vue.prototype.$ds = ds
48
43
  Vue.prototype.$dg = {}
49
44
 
50
45
  //directive
@@ -53,43 +48,45 @@ Vue.directive('dommutation', domMutation())
53
48
  Vue.directive('domdragdrop', domDragDrop())
54
49
 
55
50
  //WServHapiClient
56
- let bFirstSync = false
51
+ // let bFirstSync = false //不需要bFirstSync, 由getWebInfor結束代表第1次完成同步
57
52
  WServHapiClient({
58
53
  showLog: false,
59
54
  url: window.location.origin + window.location.pathname,
60
55
  useWaitToken: true,
61
56
  apiName: 'api',
57
+ tokenType: 'Bearer',
62
58
  getToken: () => {
63
59
  let token = get(Vue.prototype, `$store.state.userToken`, '')
64
60
  // console.log('getToken', token)
65
61
  return token
66
62
  },
67
63
  getServerMethods: (_fapi) => {
68
- console.log('$fapi', _fapi)
64
+ // console.log('$fapi', _fapi)
65
+
66
+ //save $fapi
69
67
  Vue.prototype.$fapi = _fapi
68
+
69
+ //getWebInfor
70
70
  _fapi.getWebInfor() //已有fapi時優先取得web資訊
71
71
  .then((wi) => {
72
- console.log('$fapi getWebInfor', wi)
72
+ // console.log('$fapi getWebInfor', wi)
73
+
73
74
  Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateWebInfor, wi)
74
- ui.setLang() //因更新webInfor得要重刷語系才能依照語言取得顯示文字
75
+ ui.setLang(null, 'get webInfor') //因更新webInfor可取得webName與webDescription, 得要重刷語系才能依照語言取得顯示文字
76
+
77
+ //commit syncState
78
+ Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateSyncState, true)
79
+
75
80
  })
76
81
  .catch((err) => {
77
82
  console.log(err)
78
83
  })
84
+
79
85
  },
80
86
  recvData: (r) => {
81
- console.log('sync data', r.tableName, r.data)
87
+ // console.log('sync data', r.tableName, r.data)
82
88
  Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateTableData, r)
83
89
  },
84
- getAfterUpdateTableTags: (r) => {
85
- // console.log('getAfterUpdateTableTags', r, 'needToRefresh', JSON.stringify(r.oldTableTags) !== JSON.stringify(r.newTableTags))
86
- if (bFirstSync) {
87
- return
88
- }
89
- bFirstSync = true
90
- console.log('first-sync')
91
- Vue.prototype.$store.commit(Vue.prototype.$store.types.UpdateSyncState, true)
92
- },
93
90
  })
94
91
 
95
92
  //new