vue2-client 1.10.33 → 1.11.1

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 (29) hide show
  1. package/package.json +107 -107
  2. package/src/App.vue +196 -196
  3. package/src/base-client/components/common/XAddNativeForm/demo.vue +43 -43
  4. package/src/base-client/components/common/XAddReport/XAddReport.vue +207 -207
  5. package/src/base-client/components/common/XConversation/XConversation.vue +275 -263
  6. package/src/base-client/components/common/XForm/XForm.vue +393 -393
  7. package/src/base-client/components/common/XForm/XFormItem.vue +1248 -1248
  8. package/src/base-client/components/common/XFormCol/XFormCol.vue +157 -157
  9. package/src/base-client/components/common/XFormTable/XFormTable.vue +868 -856
  10. package/src/base-client/components/common/XIntervalPicker/XIntervalPicker.vue +121 -121
  11. package/src/base-client/components/common/XReportDrawer/XReportDrawer.vue +201 -201
  12. package/src/base-client/components/common/XReportGrid/XReport.vue +1079 -1070
  13. package/src/base-client/components/common/XReportGrid/XReportDemo.vue +46 -47
  14. package/src/base-client/components/common/XReportGrid/XReportDesign.vue +628 -628
  15. package/src/base-client/components/common/XReportGrid/XReportJsonRender.vue +380 -380
  16. package/src/base-client/components/common/XReportGrid/XReportTrGroup.vue +1104 -1104
  17. package/src/base-client/components/common/XReportGrid/print.js +184 -184
  18. package/src/base-client/components/common/XTab/XTab.vue +233 -201
  19. package/src/base-client/components/common/XTable/XTable.vue +114 -195
  20. package/src/base-client/components/common/XTable/XTableWrapper.vue +240 -0
  21. package/src/base-client/components/layout/XPageView/RenderRow.vue +12 -11
  22. package/src/components/STable/index.js +12 -12
  23. package/src/components/cache/AKeepAlive.js +179 -179
  24. package/src/layouts/BlankView.vue +78 -78
  25. package/src/pages/ReportGrid/index.vue +76 -76
  26. package/src/router/async/router.map.js +148 -95
  27. package/src/utils/indexedDB.js +167 -216
  28. package/src/utils/microAppUtils.js +49 -49
  29. package/vue.config.js +6 -5
@@ -1,256 +1,205 @@
1
- // indexDB 存储
2
1
  import { post } from '@vue2-client/services/api'
3
2
 
4
- // 避免重复请求相同配置key的锁
5
- const locks = {}
6
- let currentDbVersion = 1
3
+ const DB_CONFIG = {
4
+ NAME: window.__MICRO_APP_NAME__ ? `view_${window.__MICRO_APP_NAME__}` : 'view',
5
+ STORE_NAME: 'metaCache',
6
+ VERSION: 1,
7
+ CURRENT_VERSION: 1
8
+ }
7
9
 
8
- export const indexedDB = {
9
- db: undefined,
10
- indexedDB: window?.rawWindow?.indexedDB || window.indexedDB || window.webkitindexedDB,
11
- IDBKeyRange: window?.rawWindow?.IDBKeyRange || window.IDBKeyRange || window.webkitIDBKeyRange, // 键范围
12
- openDB: function (callback) {
13
- const self = this
14
- if (self.db) {
15
- try {
16
- const transaction = self.db.transaction(['metaCache'], 'readwrite')
17
- const objectStore = transaction.objectStore('metaCache')
18
- const request = objectStore.add({ key: 'alive', data: true })
10
+ class IndexedDBManager {
11
+ constructor () {
12
+ this.db = undefined
13
+ this.locks = {}
14
+ this.isInMicroApp = !!window.__MICRO_APP_NAME__
15
+ this.microAppName = window.__MICRO_APP_NAME__ || ''
16
+ this.indexedDB = window?.rawWindow?.indexedDB || window.indexedDB || window.webkitindexedDB
17
+ this.IDBKeyRange = window?.rawWindow?.IDBKeyRange || window.IDBKeyRange || window.webkitIDBKeyRange
18
+ }
19
19
 
20
- request.onerror = function (e) {
21
- self.openDatabase().then(db => {
22
- self.db = db
23
- callback(db)
24
- }).catch(e => {
25
- console.error(e)
26
- })
27
- }
20
+ async openDatabase () {
21
+ try {
22
+ return await new Promise((resolve, reject) => {
23
+ const checkRequest = this.indexedDB.open(DB_CONFIG.NAME)
28
24
 
29
- request.onsuccess = function () {
30
- callback(self.db)
31
- }
32
- } catch (e) {
33
- self.deleteDB('view')
34
- // 重新创建数据库
35
- self.openDatabase().then(db => {
36
- self.db = db
37
- callback(self.db)
38
- }).catch(e => {
39
- console.error('重新创建数据库:' + e.message)
40
- })
41
- }
42
- } else {
43
- self.openDatabase().then(db => {
44
- self.db = db
45
- callback(self.db)
46
- }).catch(e => {
47
- console.error('打开数据库失败:' + e.message)
48
- if (e.message === 'The requested version (1) is less than the existing version (2).') {
49
- self.deleteDB('view')
50
- self.openDatabase().then(db => {
51
- self.db = db
52
- callback(self.db)
53
- }).catch(e => {
54
- console.error('重新创建数据库:' + e.message)
55
- })
25
+ checkRequest.onsuccess = (e) => {
26
+ const db = e.target.result
27
+ const currentVersion = db.version
28
+ db.close()
29
+
30
+ DB_CONFIG.CURRENT_VERSION = Math.max(currentVersion, DB_CONFIG.VERSION)
31
+ const request = this.indexedDB.open(DB_CONFIG.NAME, DB_CONFIG.CURRENT_VERSION)
32
+
33
+ request.onerror = (e) => reject(e.currentTarget.error)
34
+
35
+ request.onsuccess = (e) => {
36
+ const db = e.target.result
37
+ if (!db.objectStoreNames.contains(DB_CONFIG.STORE_NAME)) {
38
+ db.close()
39
+ DB_CONFIG.CURRENT_VERSION++
40
+ this.upgradeDatabase(resolve, reject)
41
+ } else {
42
+ resolve(db)
43
+ }
44
+ }
45
+
46
+ request.onupgradeneeded = (e) => {
47
+ const db = e.target.result
48
+ if (!db.objectStoreNames.contains(DB_CONFIG.STORE_NAME)) {
49
+ db.createObjectStore(DB_CONFIG.STORE_NAME, { keyPath: 'key' })
50
+ }
51
+ }
56
52
  }
53
+
54
+ checkRequest.onerror = (e) => reject(e.currentTarget.error)
57
55
  })
56
+ } catch (error) {
57
+ console.error('打开数据库失败:', error)
58
+ throw error
58
59
  }
59
- },
60
- openDatabase () {
61
- const self = this
60
+ }
62
61
 
63
- return new Promise((resolve, reject) => {
64
- const request = self.indexedDB.open('view', currentDbVersion)
62
+ async upgradeDatabase (resolve, reject) {
63
+ const request = this.indexedDB.open(DB_CONFIG.NAME, DB_CONFIG.CURRENT_VERSION)
65
64
 
66
- request.onerror = function (e) {
67
- reject(e.currentTarget.error)
65
+ request.onupgradeneeded = (e) => {
66
+ const db = e.target.result
67
+ if (!db.objectStoreNames.contains(DB_CONFIG.STORE_NAME)) {
68
+ db.createObjectStore(DB_CONFIG.STORE_NAME, { keyPath: 'key' })
68
69
  }
70
+ }
69
71
 
70
- request.onsuccess = function (e) {
71
- const db = e.target.result
72
- if (!db.objectStoreNames.contains('metaCache')) {
73
- db.close()
74
- currentDbVersion = db.version + 1
75
- const upgradeRequest = self.indexedDB.open('view', currentDbVersion)
76
- upgradeRequest.onupgradeneeded = function (event) {
77
- const upgradeDb = event.target.result
78
- upgradeDb.createObjectStore('metaCache', { keyPath: 'key' })
79
- }
80
- upgradeRequest.onsuccess = function (event) {
81
- resolve(event.target.result)
82
- }
83
- upgradeRequest.onerror = function (event) {
84
- reject(event.currentTarget.error)
85
- }
86
- } else {
87
- resolve(db)
72
+ request.onsuccess = (e) => resolve(e.target.result)
73
+ request.onerror = (e) => reject(e.currentTarget.error)
74
+ }
75
+
76
+ async openDB (callback) {
77
+ try {
78
+ if (this.db) {
79
+ const isAlive = await this.checkConnection()
80
+ if (isAlive) {
81
+ callback(this.db)
82
+ return
88
83
  }
89
84
  }
90
85
 
91
- request.onupgradeneeded = function (e) {
92
- const db = e.target.result
93
- if (!db.objectStoreNames.contains('metaCache')) {
94
- db.createObjectStore('metaCache', { keyPath: 'key' })
95
- }
86
+ this.db = await this.openDatabase()
87
+ callback(this.db)
88
+ } catch (error) {
89
+ console.error('数据库操作失败:', error)
90
+ if (error.message?.includes('version')) {
91
+ await this.recreateDatabase()
92
+ callback(this.db)
96
93
  }
97
- })
98
- },
99
- deleteDB: function (dbname) {
100
- // 删除数据库
101
- const self = this
102
- self.indexedDB.deleteDatabase(dbname)
103
- },
104
- closeDB: function () {
105
- const self = this
106
- if (self.db) {
107
- self.db.close()
108
94
  }
109
- },
110
- add: function (key, data) {
111
- const self = this
112
- self.openDB((res) => {
113
- const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').add({
114
- key: key,
115
- data: data
116
- })
117
- request.onerror = function () {
118
- self.update(key, data)
119
- }
120
- request.onsuccess = function () {
121
- }
122
- })
123
- },
124
- update: function (key, data) {
125
- const self = this
126
- self.openDB((res) => {
127
- const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').put({
128
- key: key,
129
- data: data
130
- })
131
- request.onerror = function () {
132
- console.error('数据更新失败')
133
- }
134
- request.onsuccess = function () {
135
- }
95
+ }
96
+
97
+ async checkConnection () {
98
+ try {
99
+ const transaction = this.db.transaction([DB_CONFIG.STORE_NAME], 'readwrite')
100
+ const store = transaction.objectStore(DB_CONFIG.STORE_NAME)
101
+ await this.promisifyRequest(store.add({ key: 'alive', data: true }))
102
+ return true
103
+ } catch {
104
+ return false
105
+ }
106
+ }
107
+
108
+ promisifyRequest (request) {
109
+ return new Promise((resolve, reject) => {
110
+ request.onsuccess = () => resolve(request.result)
111
+ request.onerror = () => reject(request.error)
136
112
  })
137
- },
138
- get: function (key, callback) {
139
- const self = this
140
- self.openDB((res) => {
141
- // 根据存储空间的键找到对应数据
142
- const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
143
- const request = store.get(key)
144
- request.onerror = function () {
145
- }
146
- request.onsuccess = function (e) {
147
- const result = e.target.result
148
- if (typeof (callback) === 'function') {
149
- callback(result.data)
113
+ }
114
+
115
+ async getByWeb (key, url, params, callback, processFun) {
116
+ if (this.locks[key]) {
117
+ await this.locks[key]
118
+ return this.getByWeb(key, url, params, callback, processFun)
119
+ }
120
+
121
+ this.locks[key] = (async () => {
122
+ try {
123
+ const data = await this.getData(key)
124
+ if (!data && url) {
125
+ const res = await post(url, params)
126
+ const processedData = processFun ? processFun(res) : res
127
+
128
+ if (process.env.NODE_ENV === 'production' || key !== 'webMobileConfig') {
129
+ await this.add(key, processedData)
130
+ }
131
+
132
+ callback(processedData)
133
+ } else {
134
+ callback(data)
150
135
  }
151
- }
152
- })
153
- },
154
- getAll: function (callback) {
155
- const self = this
156
- self.openDB((res) => {
157
- const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
158
- const request = store.getAll()
159
- request.onerror = function () {
160
- }
161
- request.onsuccess = function (e) {
162
- const result = e.target.result
163
- if (typeof (callback) === 'function') {
164
- callback(result)
136
+ } catch (error) {
137
+ console.error('获取数据失败:', error)
138
+ if (process.env.NODE_ENV === 'production' && key !== 'webMobileConfig') {
139
+ await this.add(key, null)
165
140
  }
141
+ callback(null)
166
142
  }
167
- })
168
- },
169
- getByWeb: function (key, url, params, callback, processFun) {
170
- // 如果这个键正在被使用,等待它完成
171
- if (locks[key]) {
172
- locks[key].then(() => {
173
- this.getByWeb(key, url, params, callback, processFun)
174
- })
175
- return
143
+ })()
144
+
145
+ try {
146
+ await this.locks[key]
147
+ } finally {
148
+ delete this.locks[key]
176
149
  }
150
+ }
177
151
 
178
- // 创建一个新的 Promise
179
- locks[key] = new Promise((resolve, reject) => {
180
- const self = this
152
+ async getData (key) {
153
+ return new Promise((resolve) => {
154
+ this.openDB((db) => {
155
+ const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
156
+ const request = store.get(key)
157
+ request.onsuccess = (e) => resolve(e.target.result?.data)
158
+ request.onerror = () => resolve(null)
159
+ })
160
+ })
161
+ }
181
162
 
182
- const handlePostRequest = () => {
183
- post(url, params).then((res) => {
184
- if (processFun) { res = processFun(res) }
185
- if (process.env.NODE_ENV === 'production' || key !== 'webMobileConfig') { self.add(key, res) }
186
- try {
187
- callback(res)
188
- } catch (e) {
189
- console.error(e)
190
- }
191
- resolve()
192
- }).catch((e) => {
193
- if (process.env.NODE_ENV === 'production' && key !== 'webMobileConfig') { self.add(key, null) }
194
- callback(null)
195
- resolve()
196
- })
197
- }
163
+ async add (key, data) {
164
+ this.openDB((db) => {
165
+ const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
166
+ const request = store.add({ key, data })
167
+ request.onerror = () => this.update(key, data)
168
+ })
169
+ }
198
170
 
199
- try {
200
- self.openDB((res) => {
201
- const store = res.transaction('metaCache', 'readwrite').objectStore('metaCache')
202
- const request = store.get(key)
203
- request.onerror = function (e) {
204
- reject(e)
205
- }
206
- request.onsuccess = function (e) {
207
- const result = e.target.result
208
- if (!result && url) {
209
- handlePostRequest()
210
- } else {
211
- callback(result.data)
212
- resolve()
213
- }
214
- }
215
- })
216
- } catch (e) {
217
- console.error('indexDb数据库操作错误', e)
218
- handlePostRequest()
219
- }
220
- }).finally(() => {
221
- delete locks[key]
171
+ async update (key, data) {
172
+ this.openDB((db) => {
173
+ const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
174
+ const request = store.put({ key, data })
175
+ request.onerror = () => console.error('数据更新失败')
222
176
  })
223
- },
224
- delete: function (key) {
225
- const self = this
226
- self.openDB((res) => {
227
- // 删除某一条记录
228
- const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').delete(key)
177
+ }
229
178
 
230
- request.onerror = function () {
231
- console.error('数据删除失败')
232
- }
233
- request.onsuccess = function (event) {
234
- }
179
+ async delete (key) {
180
+ this.openDB((db) => {
181
+ const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
182
+ const request = store.delete(key)
183
+ request.onerror = () => console.error('数据删除失败')
235
184
  })
236
- },
237
- clear: function (callback) {
238
- const self = this
239
- self.openDB((res) => {
240
- // 删除存储空间全部记录
241
- const request = res.transaction('metaCache', 'readwrite').objectStore('metaCache').clear()
185
+ }
242
186
 
243
- request.onerror = function () {
187
+ async clear (callback) {
188
+ this.openDB((db) => {
189
+ const store = db.transaction(DB_CONFIG.STORE_NAME, 'readwrite').objectStore(DB_CONFIG.STORE_NAME)
190
+ const request = store.clear()
191
+ request.onerror = () => {
244
192
  console.error('数据删除失败')
245
193
  callback()
246
194
  }
247
- request.onsuccess = function (event) {
195
+ request.onsuccess = () => {
248
196
  if (typeof callback === 'function') {
249
197
  callback()
250
198
  }
251
199
  }
252
200
  })
253
- },
201
+ }
202
+
254
203
  clearCache () {
255
204
  if (this.indexedDB) {
256
205
  this.clear(() => {
@@ -261,3 +210,5 @@ export const indexedDB = {
261
210
  }
262
211
  }
263
212
  }
213
+
214
+ export const indexedDB = new IndexedDBManager()
@@ -1,49 +1,49 @@
1
- /**
2
- * 获取 window 对象
3
- * @returns {Window} window 对象
4
- */
5
- export function getWindow () {
6
- return window
7
- }
8
-
9
- /**
10
- * 获取当前子应用的 name
11
- * @returns {string} 子应用的 name
12
- */
13
- export function getMicroAppName () {
14
- // 如果在微前端环境中运行,返回应用名称,否则返回 undefined
15
- return window.__MICRO_APP_ENVIRONMENT__ ? window.__MICRO_APP_NAME__ : undefined
16
- }
17
-
18
- /**
19
- * 判断是否处于 microApp 环境
20
- * @returns {boolean} 如果在 microApp 环境下返回 true,否则返回 false
21
- */
22
- export function isMicroAppEnv () {
23
- return window.__MICRO_APP_ENVIRONMENT__
24
- }
25
-
26
- /**
27
- * 发送事件给基座应用
28
- * @param {Object} data 要传递的数据
29
- * @param {Function} callBack 如果不是 microApp 环境时的回调函数
30
- * @returns {*} 在 microApp 环境下返回 dispatch 的结果,否则执行 callBack
31
- */
32
- export function microDispatch (data, callBack) {
33
- if (window.__MICRO_APP_ENVIRONMENT__) {
34
- return window.microApp.dispatch(data)
35
- }
36
- if (callBack) {
37
- return callBack()
38
- }
39
- }
40
-
41
- /**
42
- * 获取 microApp 的数据
43
- * @returns {*} microApp 的数据,如果不在 microApp 环境下返回 undefined
44
- */
45
- export function getMicroData () {
46
- if (window.__MICRO_APP_ENVIRONMENT__) {
47
- return window.microApp.getData()
48
- }
49
- }
1
+ /**
2
+ * 获取 window 对象
3
+ * @returns {Window} window 对象
4
+ */
5
+ export function getWindow () {
6
+ return window
7
+ }
8
+
9
+ /**
10
+ * 获取当前子应用的 name
11
+ * @returns {string} 子应用的 name
12
+ */
13
+ export function getMicroAppName () {
14
+ // 如果在微前端环境中运行,返回应用名称,否则返回 undefined
15
+ return window.__MICRO_APP_ENVIRONMENT__ ? window.__MICRO_APP_NAME__ : undefined
16
+ }
17
+
18
+ /**
19
+ * 判断是否处于 microApp 环境
20
+ * @returns {boolean} 如果在 microApp 环境下返回 true,否则返回 false
21
+ */
22
+ export function isMicroAppEnv () {
23
+ return window.__MICRO_APP_ENVIRONMENT__
24
+ }
25
+
26
+ /**
27
+ * 发送事件给基座应用
28
+ * @param {Object} data 要传递的数据
29
+ * @param {Function} callBack 如果不是 microApp 环境时的回调函数
30
+ * @returns {*} 在 microApp 环境下返回 dispatch 的结果,否则执行 callBack
31
+ */
32
+ export function microDispatch (data, callBack) {
33
+ if (window.__MICRO_APP_ENVIRONMENT__) {
34
+ return window.microApp.dispatch(data)
35
+ }
36
+ if (callBack) {
37
+ return callBack()
38
+ }
39
+ }
40
+
41
+ /**
42
+ * 获取 microApp 的数据
43
+ * @returns {*} microApp 的数据,如果不在 microApp 环境下返回 undefined
44
+ */
45
+ export function getMicroData () {
46
+ if (window.__MICRO_APP_ENVIRONMENT__) {
47
+ return window.microApp.getData()
48
+ }
49
+ }
package/vue.config.js CHANGED
@@ -48,8 +48,8 @@ module.exports = {
48
48
  // changeOrigin: true
49
49
  // },
50
50
  '/api/af-revenue/logic/openapi/': {
51
- pathRewrite: { '^/api/af-revenue/logic/openapi/': '/logic/' },
52
- target: 'http://127.0.0.1:9026',
51
+ // pathRewrite: { '^/api/af-revenue/logic/openapi/': '/logic/' },
52
+ target: revenue,
53
53
  changeOrigin: true
54
54
  },
55
55
  '/api/af-scada': {
@@ -57,8 +57,8 @@ module.exports = {
57
57
  changeOrigin: true
58
58
  },
59
59
  '/api/af-revenue': {
60
- pathRewrite: { '^/api/af-revenue/': '/' },
61
- target: 'http://127.0.0.1:9026',
60
+ // pathRewrite: { '^/api/af-revenue/': '/' },
61
+ target: revenue,
62
62
  changeOrigin: true
63
63
  },
64
64
  '/api/af-liuli': {
@@ -183,7 +183,8 @@ module.exports = {
183
183
  discardComments: { removeAll: true },
184
184
  colormin: false,
185
185
  }
186
- ]
186
+ ],
187
+ ignoreOrder: true
187
188
  }
188
189
  }])
189
190
  }