cloudcc-ccdk 0.9.29 → 0.9.30

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 (4) hide show
  1. package/README.md +762 -756
  2. package/lib/ccdk.js +2043 -2043
  3. package/lib/ccdk.min.js +1 -1
  4. package/package.json +34 -34
package/lib/ccdk.js CHANGED
@@ -7,71 +7,71 @@ import Jwt from 'jsonwebtoken';
7
7
  import { Message, MessageBox, Notification } from 'element-ui';
8
8
  import CryptoJS from 'crypto-js';
9
9
 
10
- /**
11
- * 数据库操作
12
- */
13
- const db = new Dexie("cloudcc-ltn-main-web");
14
-
15
- /**
16
- * 初始化表,默认使用id自增长
17
- * @param {string} tablename 表名
18
- * @param {number} version 版本号
19
- * @param {...any} fields 字段集合
20
- */
21
- function init$2(tablename, version = 1, ...fields) {
22
- return db.version(version).stores({
23
- [tablename]: `++id, ${fields}`,
24
- });
25
- }
26
-
27
- /**
28
- * 新建数据,如果设置了ID,那么是更新,否则新建
29
- * @param {string} tableName 表名
30
- * @param {array} data 存储的数据集合
31
- * @returns
32
- */
33
- async function create(tableName, data = []) {
34
- return await db[tableName].bulkPut(data);
35
- }
36
-
37
- /**
38
- * 根据ID删除数据
39
- * @param {string} tableName 表名
40
- * @param {array} ids 数据id集合
41
- * @returns 删除数据的id集合
42
- */
43
- async function deleteCC(tableName, ids = []) {
44
- return await db[tableName].bulkDelete(ids);
45
- }
46
-
47
-
48
- /**
49
- * 根据过滤条件查询数据集合
50
- * @param {string} tableName 表名
51
- * @param {object} condition 查询条件
52
- * @returns 集合
53
- */
54
- async function list(tableName, condition) {
55
- return await db[tableName].where(condition).toArray();
56
- }
57
-
58
- /**
59
- * 根据ID精确查找某条数据
60
- * @param {string} tableName 表名
61
- * @param {string} id
62
- * @returns 详情
63
- */
64
- async function detail(tableName, id) {
65
- return await db[tableName].get(id);
66
- }
67
- /**
68
- * 事务
69
- * @param {string} tableName 表名
70
- * @param {function} id 事务方法
71
- * @returns 详情
72
- */
73
- async function transaction(tableName, transaction) {
74
- await db.transaction('rw', [db[tableName]], transaction);
10
+ /**
11
+ * 数据库操作
12
+ */
13
+ const db = new Dexie("cloudcc-ltn-main-web");
14
+
15
+ /**
16
+ * 初始化表,默认使用id自增长
17
+ * @param {string} tablename 表名
18
+ * @param {number} version 版本号
19
+ * @param {...any} fields 字段集合
20
+ */
21
+ function init$2(tablename, version = 1, ...fields) {
22
+ return db.version(version).stores({
23
+ [tablename]: `++id, ${fields}`,
24
+ });
25
+ }
26
+
27
+ /**
28
+ * 新建数据,如果设置了ID,那么是更新,否则新建
29
+ * @param {string} tableName 表名
30
+ * @param {array} data 存储的数据集合
31
+ * @returns
32
+ */
33
+ async function create(tableName, data = []) {
34
+ return await db[tableName].bulkPut(data);
35
+ }
36
+
37
+ /**
38
+ * 根据ID删除数据
39
+ * @param {string} tableName 表名
40
+ * @param {array} ids 数据id集合
41
+ * @returns 删除数据的id集合
42
+ */
43
+ async function deleteCC(tableName, ids = []) {
44
+ return await db[tableName].bulkDelete(ids);
45
+ }
46
+
47
+
48
+ /**
49
+ * 根据过滤条件查询数据集合
50
+ * @param {string} tableName 表名
51
+ * @param {object} condition 查询条件
52
+ * @returns 集合
53
+ */
54
+ async function list(tableName, condition) {
55
+ return await db[tableName].where(condition).toArray();
56
+ }
57
+
58
+ /**
59
+ * 根据ID精确查找某条数据
60
+ * @param {string} tableName 表名
61
+ * @param {string} id
62
+ * @returns 详情
63
+ */
64
+ async function detail(tableName, id) {
65
+ return await db[tableName].get(id);
66
+ }
67
+ /**
68
+ * 事务
69
+ * @param {string} tableName 表名
70
+ * @param {function} id 事务方法
71
+ * @returns 详情
72
+ */
73
+ async function transaction(tableName, transaction) {
74
+ await db.transaction('rw', [db[tableName]], transaction);
75
75
  }
76
76
 
77
77
  var CCDB = /*#__PURE__*/Object.freeze({
@@ -85,31 +85,31 @@ var CCDB = /*#__PURE__*/Object.freeze({
85
85
  transaction: transaction
86
86
  });
87
87
 
88
- // 当前应用存储标识
89
- // const APPLICATION_DETAIL = 'applicaton_current'
90
-
91
- const APPLICATION_DETAIL = () => {
92
- return window.$CCDK.CCUser.getUserInfo().userId + "-currentApp"
93
- };
94
- /**
95
- * 获得当前访问的应用对象
96
- */
97
- function getApplicaton() {
98
- let detail = localStorage.getItem(APPLICATION_DETAIL());
99
- if (detail) {
100
- return JSON.parse(detail)
101
- }
102
- return ''
103
- }
104
-
105
- /**
106
- * 设置应用对象信息
107
- * @param {object} detail 应用对象
108
- */
109
- function setApplication(detail = '') {
110
- if (detail) {
111
- localStorage.setItem(APPLICATION_DETAIL(), JSON.stringify(detail));
112
- }
88
+ // 当前应用存储标识
89
+ // const APPLICATION_DETAIL = 'applicaton_current'
90
+
91
+ const APPLICATION_DETAIL = () => {
92
+ return window.$CCDK.CCUser.getUserInfo().userId + "-currentApp"
93
+ };
94
+ /**
95
+ * 获得当前访问的应用对象
96
+ */
97
+ function getApplicaton() {
98
+ let detail = localStorage.getItem(APPLICATION_DETAIL());
99
+ if (detail) {
100
+ return JSON.parse(detail)
101
+ }
102
+ return ''
103
+ }
104
+
105
+ /**
106
+ * 设置应用对象信息
107
+ * @param {object} detail 应用对象
108
+ */
109
+ function setApplication(detail = '') {
110
+ if (detail) {
111
+ localStorage.setItem(APPLICATION_DETAIL(), JSON.stringify(detail));
112
+ }
113
113
  }
114
114
 
115
115
  var CCApplication = /*#__PURE__*/Object.freeze({
@@ -118,124 +118,124 @@ var CCApplication = /*#__PURE__*/Object.freeze({
118
118
  setApplication: setApplication
119
119
  });
120
120
 
121
- /**
122
- * 获得一级域名
123
- * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
124
- */
125
- function getDomain() {
126
- let domain = document.domain;
127
- if (isValidIP(domain)) {
128
- return domain
129
- } else {
130
- // 倒数第二位域名
131
- let lastTow = document.domain.split('.').slice(-2, -1)[0];
132
- // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
133
- if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
134
- return "." + document.domain.split('.').slice(-3).join('.')
135
- } else {
136
- return "." + document.domain.split('.').slice(-2).join('.')
137
- }
138
- }
139
- }
140
- /**
141
- * 检测是否为有效IP
142
- * @param {string} ip ip地址
143
- * @returns 是否为ip地址
144
- */
145
- function isValidIP(ip) {
146
- var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
147
- return reg.test(ip);
148
- }
149
- /**
150
- * 校验token是否有效
151
- * {
152
- "versionType": "Unlimited",
153
- "loginName": "admin@cloudcc.com",
154
- "binding": "1eaabe2e24844904b443308f48fb0dee",
155
- "userId": "0052017BE8702F1PIi4j",
156
- "orgId": "exorg20235419690prod"
157
- }
158
- * @param {string} token 认证信息
159
- */
160
- function verifyToken(token) {
161
- let j = Jwt.decode(token);
162
- return { result: j && j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
163
- }
164
-
165
- /**
166
- * 格式化时间:yyyy-MM-dd HH:mm:ss
167
- * @returns
168
- */
169
- function getNowFormatDate() {
170
- var myDate = new Date;
171
- var year = myDate.getFullYear(); //获取当前年
172
- var mon = myDate.getMonth() + 1; //获取当前月
173
- if (mon < 10) {
174
- mon = "0" + mon;
175
- }
176
- var date = myDate.getDate(); //获取当前日
177
- if (date < 10) {
178
- date = "0" + date;
179
- }
180
- var hours = myDate.getHours(); //获取当前小时
181
- if (hours < 10) {
182
- hours = "0" + hours;
183
- }
184
- var minutes = myDate.getMinutes(); //获取当前分钟
185
- if (minutes < 10) {
186
- minutes = "0" + minutes;
187
- }
188
- var seconds = myDate.getSeconds(); //获取当前秒
189
- if (seconds < 10) {
190
- seconds = "0" + seconds;
191
- }
192
- var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
193
- return now;
194
- }
195
-
196
- /**
197
- * 获得16位标识
198
- * @returns 16位标识
199
- */
200
- function getUuid() {
201
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
202
- var r = (Math.random() * 16) | 0,
203
- v = c == 'x' ? r : (r & 0x3) | 0x8;
204
- return v.toString(16);
205
- });
206
- }
207
-
208
- function getBinding() {
209
- let binding = window.$CCDK.CCToken.getToken();
210
- if (!binding) {
211
- window.open(window.Glod.LOGIN_URL, '_self');
212
- // this.reLogin();
213
- } else {
214
- // 刷新有效期,而且有的老功能,依赖这个binding了
215
- Cookies.set('binding', binding, { expires: 1 / 12 });
216
- Cookies.set('JSESSIONID', binding, { expires: 1 / 12 });
217
- }
218
- return binding
219
- }
220
- /**
221
- * 用于获取当前页位置,暂时仅支持视图和详情页说明
222
- * view:视图页
223
- * detail:详情页
224
- * @returns {string} 返回值:当前页位置
225
- */
226
- function getCurrentPageType() {
227
- let currentPage;
228
- let currentHref = window.location.hash || '';
229
- currentHref = currentHref.split('?')[0] || '';
230
- const lastHref = currentHref.split('/').pop();
231
- if(currentHref.includes('#/commonObjects/views/table')){
232
- // 当前是视图页
233
- currentPage = 'view';
234
- }else if(lastHref === 'DETAIL'){
235
- // 当前是视图页
236
- currentPage = 'detail';
237
- }
238
- return currentPage
121
+ /**
122
+ * 获得一级域名
123
+ * 比如:xx.com、xx.cn、xx.com.cn、xx.net.cn、xx.org.cn
124
+ */
125
+ function getDomain() {
126
+ let domain = document.domain;
127
+ if (isValidIP(domain)) {
128
+ return domain
129
+ } else {
130
+ // 倒数第二位域名
131
+ let lastTow = document.domain.split('.').slice(-2, -1)[0];
132
+ // 如果倒数第二位是这些关键字,那么需要取倒数三位域名
133
+ if (lastTow == 'com' || lastTow == 'org' || lastTow == 'net') {
134
+ return "." + document.domain.split('.').slice(-3).join('.')
135
+ } else {
136
+ return "." + document.domain.split('.').slice(-2).join('.')
137
+ }
138
+ }
139
+ }
140
+ /**
141
+ * 检测是否为有效IP
142
+ * @param {string} ip ip地址
143
+ * @returns 是否为ip地址
144
+ */
145
+ function isValidIP(ip) {
146
+ var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
147
+ return reg.test(ip);
148
+ }
149
+ /**
150
+ * 校验token是否有效
151
+ * {
152
+ "versionType": "Unlimited",
153
+ "loginName": "admin@cloudcc.com",
154
+ "binding": "1eaabe2e24844904b443308f48fb0dee",
155
+ "userId": "0052017BE8702F1PIi4j",
156
+ "orgId": "exorg20235419690prod"
157
+ }
158
+ * @param {string} token 认证信息
159
+ */
160
+ function verifyToken(token) {
161
+ let j = Jwt.decode(token);
162
+ return { result: j && j.versionType && j.loginName && j.binding && j.userId && j.orgId, jwt: j }
163
+ }
164
+
165
+ /**
166
+ * 格式化时间:yyyy-MM-dd HH:mm:ss
167
+ * @returns
168
+ */
169
+ function getNowFormatDate() {
170
+ var myDate = new Date;
171
+ var year = myDate.getFullYear(); //获取当前年
172
+ var mon = myDate.getMonth() + 1; //获取当前月
173
+ if (mon < 10) {
174
+ mon = "0" + mon;
175
+ }
176
+ var date = myDate.getDate(); //获取当前日
177
+ if (date < 10) {
178
+ date = "0" + date;
179
+ }
180
+ var hours = myDate.getHours(); //获取当前小时
181
+ if (hours < 10) {
182
+ hours = "0" + hours;
183
+ }
184
+ var minutes = myDate.getMinutes(); //获取当前分钟
185
+ if (minutes < 10) {
186
+ minutes = "0" + minutes;
187
+ }
188
+ var seconds = myDate.getSeconds(); //获取当前秒
189
+ if (seconds < 10) {
190
+ seconds = "0" + seconds;
191
+ }
192
+ var now = year + "-" + mon + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
193
+ return now;
194
+ }
195
+
196
+ /**
197
+ * 获得16位标识
198
+ * @returns 16位标识
199
+ */
200
+ function getUuid() {
201
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
202
+ var r = (Math.random() * 16) | 0,
203
+ v = c == 'x' ? r : (r & 0x3) | 0x8;
204
+ return v.toString(16);
205
+ });
206
+ }
207
+
208
+ function getBinding() {
209
+ let binding = window.$CCDK.CCToken.getToken();
210
+ if (!binding) {
211
+ window.open(window.Glod.LOGIN_URL, '_self');
212
+ // this.reLogin();
213
+ } else {
214
+ // 刷新有效期,而且有的老功能,依赖这个binding了
215
+ Cookies.set('binding', binding, { expires: 1 / 12, sameSite: 'Lax' });
216
+ Cookies.set('JSESSIONID', binding, { expires: 1 / 12, sameSite: 'Lax' });
217
+ }
218
+ return binding
219
+ }
220
+ /**
221
+ * 用于获取当前页位置,暂时仅支持视图和详情页说明
222
+ * view:视图页
223
+ * detail:详情页
224
+ * @returns {string} 返回值:当前页位置
225
+ */
226
+ function getCurrentPageType() {
227
+ let currentPage;
228
+ let currentHref = window.location.hash || '';
229
+ currentHref = currentHref.split('?')[0] || '';
230
+ const lastHref = currentHref.split('/').pop();
231
+ if (currentHref.includes('#/commonObjects/views/table')) {
232
+ // 当前是视图页
233
+ currentPage = 'view';
234
+ } else if (lastHref === 'DETAIL') {
235
+ // 当前是视图页
236
+ currentPage = 'detail';
237
+ }
238
+ return currentPage
239
239
  }
240
240
 
241
241
  var CCUtils = /*#__PURE__*/Object.freeze({
@@ -248,453 +248,453 @@ var CCUtils = /*#__PURE__*/Object.freeze({
248
248
  getCurrentPageType: getCurrentPageType
249
249
  });
250
250
 
251
- const toStr = Object.prototype.toString;
252
-
253
- const TypeEnum = {
254
- 'FUNCTION': '[object Function]',
255
- 'ARRAY': '[object Array]',
251
+ const toStr = Object.prototype.toString;
252
+
253
+ const TypeEnum = {
254
+ 'FUNCTION': '[object Function]',
255
+ 'ARRAY': '[object Array]',
256
+ };
257
+
258
+ // 是否是一个函数
259
+ const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
260
+
261
+ // 是否是生产环境
262
+ const isProduction = () => true ;
263
+
264
+ // 延时
265
+ const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
266
+
267
+ // 是否是超时请求
268
+ const isTimeout = (error = {
269
+ code: '',
270
+ message: ''
271
+ }) => {
272
+ return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
273
+ };
274
+
275
+ // 格式换请求体
276
+ const formateData = data => {
277
+ return {
278
+ head: {
279
+ appType: "lightning-main",
280
+ appVersion: "1.1.1",
281
+ accessToken: getBinding(),
282
+ source: "lightning-main"
283
+ },
284
+ body: {
285
+ ...data
286
+ }
287
+ }
288
+ };
289
+ /**
290
+ * 深度合并
291
+ * @param {object} source 合并的基础对象
292
+ * @param {object} target 新的数据
293
+ */
294
+ const deepMerge = (source, target) => {
295
+ const res = cloneDeep(source);
296
+ for (let key in target) {
297
+ if (target.hasOwnProperty(key)) {
298
+ res[key] = isObject(target[key])
299
+ ? deepMerge(res[key], target[key])
300
+ : target[key];
301
+ }
302
+ }
303
+ return res
256
304
  };
257
305
 
258
- // 是否是一个函数
259
- const isFn = (value) => toStr.call(value) === TypeEnum.FUNCTION;
260
-
261
- // 是否是生产环境
262
- const isProduction = () => true ;
263
-
264
- // 延时
265
- const delay = (waitTime = 1000) => new Promise(resolve => setTimeout(resolve, waitTime));
266
-
267
- // 是否是超时请求
268
- const isTimeout = (error = {
269
- code: '',
270
- message: ''
271
- }) => {
272
- return error.code === AxiosError.ECONNABORTED && error.message.includes('timeout')
273
- };
274
-
275
- // 格式换请求体
276
- const formateData = data => {
277
- return {
278
- head: {
279
- appType: "lightning-main",
280
- appVersion: "1.1.1",
281
- accessToken: getBinding(),
282
- source: "lightning-main"
283
- },
284
- body: {
285
- ...data
286
- }
287
- }
288
- };
289
- /**
290
- * 深度合并
291
- * @param {object} source 合并的基础对象
292
- * @param {object} target 新的数据
293
- */
294
- const deepMerge = (source, target) => {
295
- const res = cloneDeep(source);
296
- for (let key in target) {
297
- if (target.hasOwnProperty(key)) {
298
- res[key] = isObject(target[key])
299
- ? deepMerge(res[key], target[key])
300
- : target[key];
301
- }
302
- }
303
- return res
304
- };
305
-
306
- /**
307
- * LRU算法
308
- * @param {number} capacity 最大缓存容量
309
- */
310
- const LRUCache = function (capacity) {
311
- this.capacity = capacity;
312
- this.cache = new Map();
313
- };
314
-
315
- /**
316
- * 获取指定key的缓存
317
- * @param {string} key 缓存的key
318
- */
319
- LRUCache.prototype.get = function (key) {
320
- var cacheTemp = this.cache,
321
- curTemp = cacheTemp.get(key);
322
- if (curTemp || curTemp === 0) {
323
- cacheTemp.delete(key);
324
- cacheTemp.set(key, curTemp);
325
- return curTemp
326
- }
327
- return null
328
- };
329
-
330
- /**
331
- * 指定key添加缓存
332
- * @param {string} key 缓存的key
333
- * @param {object} value 缓存的值
334
- */
335
- LRUCache.prototype.put = function (key, value) {
336
- var cacheTemp = this.cache;
337
- if (cacheTemp.get(key)) {
338
- cacheTemp.delete(key);
339
- } else if (cacheTemp.size >= this.capacity) {
340
- cacheTemp.delete(cacheTemp.keys().next().value);
341
- }
342
- cacheTemp.set(key, value);
343
- };
344
-
345
- class CCAxios {
346
- constructor(opt) {
347
- this.options = opt;
348
- this.axiosInstance = axios.create(opt);
349
- this.setupInterceptors();
350
- this.cachePool = new LRUCache(20);
351
- // FIXME:区分构造函数参数和接口级别的参数
352
- }
353
-
354
- //获取拦截器
355
- getTransform() {
356
- const { transform } = this.options;
357
- return transform;
358
- }
359
-
360
- //准备拦截器
361
- setupInterceptors() {
362
- const transform = this.getTransform();
363
- if (!transform) {
364
- return;
365
- }
366
- const {
367
- requestInterceptors,
368
- requestInterceptorsCatch,
369
- responseInterceptors,
370
- responseInterceptorsCatch,
371
- } = transform;
372
- // 请求拦截器
373
- this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
374
- // 请求拦截器错误处理
375
- requestInterceptorsCatch
376
- && isFn(requestInterceptorsCatch)
377
- && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
378
-
379
- // 响应拦截器
380
- this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
381
- // 响应拦截器错误处理
382
- responseInterceptorsCatch
383
- && isFn(responseInterceptorsCatch)
384
- && this.axiosInstance.interceptors.response.use(undefined, (error) => {
385
- return responseInterceptorsCatch(this.axiosInstance, error)
386
- });
387
- }
388
- get(config, options = {}) {
389
- return this.request({ ...config, method: 'GET', }, options)
390
- }
391
- post(config, options = {}) {
392
- const { envType } = options;
393
- // 公有云专用接口,在私有云不请求
394
- if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
395
- return new Promise(() => { })
396
- }
397
- // 私有云专用接口,在公有云不请求
398
- if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
399
- return new Promise(() => { })
400
- }
401
- return this.request({ ...config, method: 'POST', }, options)
402
- }
403
- postFormat(config, options = {}) {
404
- return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
405
- }
406
- postParams(config, options = {}) {
407
- return this.request({ ...config, method: 'POST', params: config.data }, options)
408
- }
409
-
410
- // FIXME:如果初始化时配置了重试那么所有get接口都重试了
411
- // options是接口级定义的参数
412
- request(config, options) {
413
- const transform = this.getTransform();
414
- const conf = config,
415
- { requestOptions } = this.options;
416
- requestOptions.cache = false;
417
- requestOptions.cacheKey = '';
418
- requestOptions.retryRequest = {
419
- isOpenRetry: false,
420
- count: 5,
421
- waitTime: 1000
422
- };
423
-
424
- const opt = Object.assign({}, requestOptions, options);
425
- conf.requestOptions = opt;
426
-
427
- const retPromise = new Promise((resolve, reject) => {
428
- this.axiosInstance(conf)
429
- .then(res => {
430
- const { transformResponseHook } = transform;
431
- if (transformResponseHook && isFn(transformResponseHook)) {
432
- try {
433
- const ret = transformResponseHook(res, opt, this.cachePool);
434
- resolve(ret);
435
- } catch (err) {
436
- reject(err || new Error('request error!'));
437
- }
438
- return;
439
- }
440
- resolve(res);
441
- })
442
- .catch(err => {
443
- reject(err);
444
- });
445
- });
446
- // 缓存
447
- retPromise.cache = (callback) => {
448
- const { cache, cacheKey } = opt;
449
- const cacheData = (cache && this.cachePool.get([cacheKey]));
450
- callback(cacheData ? cacheData : null);
451
- return retPromise
452
- };
453
- return retPromise
454
- }
455
- }
456
-
457
- // 使用全局弹窗进行提示
458
- const createErrorModal = (response, options) => {
459
- const { message } = options;
460
- let temp;
461
- if (response.name === 'AxiosError') {
462
- temp = response.response;
463
- temp.data.returnInfo = response.returnInfo || message || temp.error || '';
464
- temp.data.returnCode = response.code || temp.status;
465
- temp.data.requestId = response.config.headers.requestId;
466
- } else {
467
- temp = response;
468
- temp.data.requestId = response.config.headers.requestId;
469
- }
470
- // 存在全局错误弹窗时才调用
471
- isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
472
- response: temp
473
- });
306
+ /**
307
+ * LRU算法
308
+ * @param {number} capacity 最大缓存容量
309
+ */
310
+ const LRUCache = function (capacity) {
311
+ this.capacity = capacity;
312
+ this.cache = new Map();
313
+ };
314
+
315
+ /**
316
+ * 获取指定key的缓存
317
+ * @param {string} key 缓存的key
318
+ */
319
+ LRUCache.prototype.get = function (key) {
320
+ var cacheTemp = this.cache,
321
+ curTemp = cacheTemp.get(key);
322
+ if (curTemp || curTemp === 0) {
323
+ cacheTemp.delete(key);
324
+ cacheTemp.set(key, curTemp);
325
+ return curTemp
326
+ }
327
+ return null
328
+ };
329
+
330
+ /**
331
+ * 指定key添加缓存
332
+ * @param {string} key 缓存的key
333
+ * @param {object} value 缓存的值
334
+ */
335
+ LRUCache.prototype.put = function (key, value) {
336
+ var cacheTemp = this.cache;
337
+ if (cacheTemp.get(key)) {
338
+ cacheTemp.delete(key);
339
+ } else if (cacheTemp.size >= this.capacity) {
340
+ cacheTemp.delete(cacheTemp.keys().next().value);
341
+ }
342
+ cacheTemp.set(key, value);
474
343
  };
475
344
 
345
+ class CCAxios {
346
+ constructor(opt) {
347
+ this.options = opt;
348
+ this.axiosInstance = axios.create(opt);
349
+ this.setupInterceptors();
350
+ this.cachePool = new LRUCache(20);
351
+ // FIXME:区分构造函数参数和接口级别的参数
352
+ }
353
+
354
+ //获取拦截器
355
+ getTransform() {
356
+ const { transform } = this.options;
357
+ return transform;
358
+ }
359
+
360
+ //准备拦截器
361
+ setupInterceptors() {
362
+ const transform = this.getTransform();
363
+ if (!transform) {
364
+ return;
365
+ }
366
+ const {
367
+ requestInterceptors,
368
+ requestInterceptorsCatch,
369
+ responseInterceptors,
370
+ responseInterceptorsCatch,
371
+ } = transform;
372
+ // 请求拦截器
373
+ this.axiosInstance.interceptors.request.use(requestInterceptors, undefined);
374
+ // 请求拦截器错误处理
375
+ requestInterceptorsCatch
376
+ && isFn(requestInterceptorsCatch)
377
+ && this.axiosInstance.interceptors.request.use(undefined, requestInterceptorsCatch);
378
+
379
+ // 响应拦截器
380
+ this.axiosInstance.interceptors.response.use(responseInterceptors, undefined);
381
+ // 响应拦截器错误处理
382
+ responseInterceptorsCatch
383
+ && isFn(responseInterceptorsCatch)
384
+ && this.axiosInstance.interceptors.response.use(undefined, (error) => {
385
+ return responseInterceptorsCatch(this.axiosInstance, error)
386
+ });
387
+ }
388
+ get(config, options = {}) {
389
+ return this.request({ ...config, method: 'GET', }, options)
390
+ }
391
+ post(config, options = {}) {
392
+ const { envType } = options;
393
+ // 公有云专用接口,在私有云不请求
394
+ if ("public" == envType && "private" == window.Glod["ENV_TYPE"]) {
395
+ return new Promise(() => { })
396
+ }
397
+ // 私有云专用接口,在公有云不请求
398
+ if ("private" == envType && "private" != window.Glod["ENV_TYPE"]) {
399
+ return new Promise(() => { })
400
+ }
401
+ return this.request({ ...config, method: 'POST', }, options)
402
+ }
403
+ postFormat(config, options = {}) {
404
+ return this.request({ ...config, method: 'POST', data: formateData(config.data) }, options)
405
+ }
406
+ postParams(config, options = {}) {
407
+ return this.request({ ...config, method: 'POST', params: config.data }, options)
408
+ }
409
+
410
+ // FIXME:如果初始化时配置了重试那么所有get接口都重试了
411
+ // options是接口级定义的参数
412
+ request(config, options) {
413
+ const transform = this.getTransform();
414
+ const conf = config,
415
+ { requestOptions } = this.options;
416
+ requestOptions.cache = false;
417
+ requestOptions.cacheKey = '';
418
+ requestOptions.retryRequest = {
419
+ isOpenRetry: false,
420
+ count: 5,
421
+ waitTime: 1000
422
+ };
423
+
424
+ const opt = Object.assign({}, requestOptions, options);
425
+ conf.requestOptions = opt;
426
+
427
+ const retPromise = new Promise((resolve, reject) => {
428
+ this.axiosInstance(conf)
429
+ .then(res => {
430
+ const { transformResponseHook } = transform;
431
+ if (transformResponseHook && isFn(transformResponseHook)) {
432
+ try {
433
+ const ret = transformResponseHook(res, opt, this.cachePool);
434
+ resolve(ret);
435
+ } catch (err) {
436
+ reject(err || new Error('request error!'));
437
+ }
438
+ return;
439
+ }
440
+ resolve(res);
441
+ })
442
+ .catch(err => {
443
+ reject(err);
444
+ });
445
+ });
446
+ // 缓存
447
+ retPromise.cache = (callback) => {
448
+ const { cache, cacheKey } = opt;
449
+ const cacheData = (cache && this.cachePool.get([cacheKey]));
450
+ callback(cacheData ? cacheData : null);
451
+ return retPromise
452
+ };
453
+ return retPromise
454
+ }
455
+ }
456
+
457
+ // 使用全局弹窗进行提示
458
+ const createErrorModal = (response, options) => {
459
+ const { message } = options;
460
+ let temp;
461
+ if (response.name === 'AxiosError') {
462
+ temp = response.response;
463
+ temp.data.returnInfo = response.returnInfo || message || temp.error || '';
464
+ temp.data.returnCode = response.code || temp.status;
465
+ temp.data.requestId = response.config.headers.requestId;
466
+ } else {
467
+ temp = response;
468
+ temp.data.requestId = response.config.headers.requestId;
469
+ }
470
+ // 存在全局错误弹窗时才调用
471
+ isFn(Vue.prototype.$ErrorDialog) && Vue.prototype.$ErrorDialog({
472
+ response: temp
473
+ });
474
+ };
475
+
476
476
  const createMessage = Message;
477
477
 
478
- // 需要上报的errorType
478
+ // 需要上报的errorType
479
479
  const needReportErrorType = ['901', '999'];
480
480
 
481
- function checkStatus(error, status, msg, errorMessageMode = 'modal') {
482
- // const errorMsg = errorMsgMap[status] || {
483
- // label: "message.error.object.contactadministrators"
484
- // }
485
- // let errMessage = '',
486
- // label = '';
487
-
488
- // label = errorMsg.label;
489
- // [400, 401].includes(status) && msg && (label = msg)
490
- let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
491
-
492
- if (status === 401) {
493
- //重新登录相关逻辑
494
- window.open(window.Glod.LOGIN_URL, '_self');
495
- }
496
-
497
- {
498
- if (errorMessageMode === 'modal') {
499
- createErrorModal(error, { message: errMessage });
500
- } else if (errorMessageMode === 'message') {
501
- createMessage.error(errMessage);
502
- }
503
- }
504
- }
505
-
506
- /**
507
- * 接口请求重试
508
- * @param {object} AxiosInstance实例
509
- * @param {error} AxiosError对象
510
- */
511
- const retry = async (instance, error) => {
512
- const { config } = error,
513
- { waitTime, count = 5} = config.requestOptions || {};
514
- config.__retryCount = config.__retryCount || 0;
515
- if(count <= config.__retryCount ) {
516
- return Promise.reject(error)
517
- }
518
-
519
- config.__retryCount++;
520
-
521
- await delay(waitTime);
522
- //请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
523
- delete config.headers;
524
- return instance(config)
525
- };
526
-
527
- const transform = {
528
- // 请求拦截器
529
- requestInterceptors(config) {
530
- // 设置日志请求头信息
531
- config.headers.requestId = window.$CCDK.CCUtils.getUuid();
532
- config.headers.requestIdProducer = "browser";
533
- config.headers.accessToken = window.$CCDK.CCToken.getToken();
534
- return config
535
- },
536
- // 响应拦截器
537
- responseInterceptors(response) {
538
- const { data, config } = response,
539
- { errorType, result } = data;
540
- //失败
541
- if (!result) {
542
- if (needReportErrorType.includes(errorType) && isProduction()) {
543
- const { errorReporter } = config.requestOptions;
544
- //如果存在错误上报对象,则上报错误
545
- if (errorReporter && isFn(errorReporter)) {
546
- errorReporter(response);
547
- }
548
- }
549
- return response
550
- }
551
- // 成功
552
- // 生产环境上报日志
553
- const { infoReporter } = config.requestOptions;
554
- //如果存在日志上报对象,则上报日志
555
- if (infoReporter && isFn(infoReporter)) {
556
- infoReporter(response);
557
- }
558
- // 返回数据 外面处理
559
- return response
560
- },
561
- // 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
562
- async responseInterceptorsCatch(axiosInstance, error) {
563
- const { response, config } = error || {};
564
-
565
- let err = "",
566
- msg = "",
567
- mode = "modal";
568
- try {
569
- err = error.toString(),
570
- msg = response.data.error,
571
- mode = config.requestOptions.errorMessageMode;
572
- } catch (e) { }
573
-
574
- let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
575
- errMessage = '';
576
-
577
- // 是否是取消的请求
578
- if (axios.isCancel(error)) {
579
- return Promise.reject(error)
580
- }
581
-
582
- try {
583
- //如果存在错误上报对象,则上报错误
584
- if (isProduction()) {
585
- // 接口级的错误上报方式会覆盖实例初始化时的错误上报
586
- const { errorReporter } = config.requestOptions;
587
- if (errorReporter && isFn(errorReporter)) {
588
- errorReporter(error);
589
- }
590
- }
591
- // 处理超时
592
- if (isTimeout(error)) {
593
- errMessage = 'c2487';
594
- }
595
- // 处理网络错误
596
- if (err && err.includes('Network Error')) {
597
- errMessage = 'c929';
598
- }
599
-
600
- if (errMessage) {
601
- if (errorMessageMode === 'modal') {
602
- createErrorModal({
603
- ...error,
604
- response: {
605
- data: {
606
- returnInfo: error.message,
607
- returnCode: error.code,
608
- requestId: error.config.headers.requestId
609
- },
610
- config: error.config
611
- }
612
- }, { message: errMessage });
613
- } else if (errorMessageMode === 'message') {
614
- createMessage.error(errMessage);
615
- }
616
- return Promise.reject(error)
617
- }
618
- } catch (error) {
619
- throw new Error(error);
620
- }
621
- // 根据status处理其他类型错误
622
- checkStatus(error, error && error.response.status, msg, errorMessageMode);
623
-
624
- // 接口重试操作
625
- const { isOpenRetry } = config;
626
- isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
627
-
628
- return Promise.reject(error);
629
- },
630
- // 响应数据处理,包含解密和数据返回结构设置
631
- transformResponseHook(response, options, cachePool) {
632
- const { data } = response;
633
- const { errorType, result } = data;
634
- // 失败
635
- // 501异常处理
636
- const businessLogicError = (response) => {
637
- const { errorMessageMode, silent } = response.config.requestOptions;
638
- // 接口如果设置了出现异常不提醒,则不提醒
639
- if (silent) return;
640
- // 根据errorMessageMode来判断显示错误弹窗的ui
641
- if (errorMessageMode === 'modal') {
642
- createErrorModal(response, { message: '业务出错' });
643
- } else if (errorMessageMode === 'message') {
644
- createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
645
- }
646
- };
647
- if (!result) {
648
- switch (errorType) {
649
- case '901':
650
- createErrorModal(response, { message: '系统错误' });
651
- break;
652
- case '999':
653
- break;
654
- case '501':
655
- default:
656
- businessLogicError(response);
657
- break;
658
- }
659
- return Promise.reject(response)
660
- }
661
- // 成功
662
- const { isReturnNativeResponse, cache, cacheKey } = options;
663
- // 直接返回
664
- if (isReturnNativeResponse) {
665
- cache && cacheKey && (cachePool.put(cacheKey, response));
666
- return response
667
- }
668
- cache && cacheKey && (cachePool.put(cacheKey, data));
669
- return data
670
- }
481
+ function checkStatus(error, status, msg, errorMessageMode = 'modal') {
482
+ // const errorMsg = errorMsgMap[status] || {
483
+ // label: "message.error.object.contactadministrators"
484
+ // }
485
+ // let errMessage = '',
486
+ // label = '';
487
+
488
+ // label = errorMsg.label;
489
+ // [400, 401].includes(status) && msg && (label = msg)
490
+ let errMessage = "message.error.object.contactadministrators"; //系统异常,请联系系统管理员获取帮助。
491
+
492
+ if (status === 401) {
493
+ //重新登录相关逻辑
494
+ window.open(window.Glod.LOGIN_URL, '_self');
495
+ }
496
+
497
+ {
498
+ if (errorMessageMode === 'modal') {
499
+ createErrorModal(error, { message: errMessage });
500
+ } else if (errorMessageMode === 'message') {
501
+ createMessage.error(errMessage);
502
+ }
503
+ }
504
+ }
505
+
506
+ /**
507
+ * 接口请求重试
508
+ * @param {object} AxiosInstance实例
509
+ * @param {error} AxiosError对象
510
+ */
511
+ const retry = async (instance, error) => {
512
+ const { config } = error,
513
+ { waitTime, count = 5} = config.requestOptions || {};
514
+ config.__retryCount = config.__retryCount || 0;
515
+ if(count <= config.__retryCount ) {
516
+ return Promise.reject(error)
517
+ }
518
+
519
+ config.__retryCount++;
520
+
521
+ await delay(waitTime);
522
+ //请求返回后config的header不正确造成重试请求失败,删除返回headers采用默认headers
523
+ delete config.headers;
524
+ return instance(config)
671
525
  };
672
526
 
673
-
674
- function createAxios(opt) {
675
- return new CCAxios(deepMerge({
676
- timeout: 60 * 1000,
677
- headers: {
678
- 'Content-Type': 'application/json;charset=UTF-8',
679
- },
680
- transform: cloneDeep(transform),
681
- requestOptions: {
682
- envType: '',
683
- errorMessageMode: 'modal',
684
- //是否静默错误提示
685
- silent: false,
686
- // 接口是否需要缓存
687
- cache: false,
688
- // 接口重试相关
689
- retryRequest: {
690
- isOpenRetry: false,
691
- count: 5,
692
- waitTime: 100,
693
- },
694
- // 是否返回原生响应头 比如:需要获取响应头时使用该属性
695
- isReturnNativeResponse: false,
696
- }
697
- }, opt || {}))
527
+ const transform = {
528
+ // 请求拦截器
529
+ requestInterceptors(config) {
530
+ // 设置日志请求头信息
531
+ config.headers.requestId = window.$CCDK.CCUtils.getUuid();
532
+ config.headers.requestIdProducer = "browser";
533
+ config.headers.accessToken = window.$CCDK.CCToken.getToken();
534
+ return config
535
+ },
536
+ // 响应拦截器
537
+ responseInterceptors(response) {
538
+ const { data, config } = response,
539
+ { errorType, result } = data;
540
+ //失败
541
+ if (!result) {
542
+ if (needReportErrorType.includes(errorType) && isProduction()) {
543
+ const { errorReporter } = config.requestOptions;
544
+ //如果存在错误上报对象,则上报错误
545
+ if (errorReporter && isFn(errorReporter)) {
546
+ errorReporter(response);
547
+ }
548
+ }
549
+ return response
550
+ }
551
+ // 成功
552
+ // 生产环境上报日志
553
+ const { infoReporter } = config.requestOptions;
554
+ //如果存在日志上报对象,则上报日志
555
+ if (infoReporter && isFn(infoReporter)) {
556
+ infoReporter(response);
557
+ }
558
+ // 返回数据 外面处理
559
+ return response
560
+ },
561
+ // 响应拦截器异常处理,处理的错误类型包括: 服务器直接跑出异常、超时、网络错误
562
+ async responseInterceptorsCatch(axiosInstance, error) {
563
+ const { response, config } = error || {};
564
+
565
+ let err = "",
566
+ msg = "",
567
+ mode = "modal";
568
+ try {
569
+ err = error.toString(),
570
+ msg = response.data.error,
571
+ mode = config.requestOptions.errorMessageMode;
572
+ } catch (e) { }
573
+
574
+ let errorMessageMode = ['message', 'modal'].includes(mode) && mode || 'modal',
575
+ errMessage = '';
576
+
577
+ // 是否是取消的请求
578
+ if (axios.isCancel(error)) {
579
+ return Promise.reject(error)
580
+ }
581
+
582
+ try {
583
+ //如果存在错误上报对象,则上报错误
584
+ if (isProduction()) {
585
+ // 接口级的错误上报方式会覆盖实例初始化时的错误上报
586
+ const { errorReporter } = config.requestOptions;
587
+ if (errorReporter && isFn(errorReporter)) {
588
+ errorReporter(error);
589
+ }
590
+ }
591
+ // 处理超时
592
+ if (isTimeout(error)) {
593
+ errMessage = 'c2487';
594
+ }
595
+ // 处理网络错误
596
+ if (err && err.includes('Network Error')) {
597
+ errMessage = 'c929';
598
+ }
599
+
600
+ if (errMessage) {
601
+ if (errorMessageMode === 'modal') {
602
+ createErrorModal({
603
+ ...error,
604
+ response: {
605
+ data: {
606
+ returnInfo: error.message,
607
+ returnCode: error.code,
608
+ requestId: error.config.headers.requestId
609
+ },
610
+ config: error.config
611
+ }
612
+ }, { message: errMessage });
613
+ } else if (errorMessageMode === 'message') {
614
+ createMessage.error(errMessage);
615
+ }
616
+ return Promise.reject(error)
617
+ }
618
+ } catch (error) {
619
+ throw new Error(error);
620
+ }
621
+ // 根据status处理其他类型错误
622
+ checkStatus(error, error && error.response.status, msg, errorMessageMode);
623
+
624
+ // 接口重试操作
625
+ const { isOpenRetry } = config;
626
+ isOpenRetry && config.method && config.method.toUpperCase() === "GET" && retry(axiosInstance, error);
627
+
628
+ return Promise.reject(error);
629
+ },
630
+ // 响应数据处理,包含解密和数据返回结构设置
631
+ transformResponseHook(response, options, cachePool) {
632
+ const { data } = response;
633
+ const { errorType, result } = data;
634
+ // 失败
635
+ // 501异常处理
636
+ const businessLogicError = (response) => {
637
+ const { errorMessageMode, silent } = response.config.requestOptions;
638
+ // 接口如果设置了出现异常不提醒,则不提醒
639
+ if (silent) return;
640
+ // 根据errorMessageMode来判断显示错误弹窗的ui
641
+ if (errorMessageMode === 'modal') {
642
+ createErrorModal(response, { message: '业务出错' });
643
+ } else if (errorMessageMode === 'message') {
644
+ createMessage.error(response && response.data && response.data.returnInfo || '业务出错');
645
+ }
646
+ };
647
+ if (!result) {
648
+ switch (errorType) {
649
+ case '901':
650
+ createErrorModal(response, { message: '系统错误' });
651
+ break;
652
+ case '999':
653
+ break;
654
+ case '501':
655
+ default:
656
+ businessLogicError(response);
657
+ break;
658
+ }
659
+ return Promise.reject(response)
660
+ }
661
+ // 成功
662
+ const { isReturnNativeResponse, cache, cacheKey } = options;
663
+ // 直接返回
664
+ if (isReturnNativeResponse) {
665
+ cache && cacheKey && (cachePool.put(cacheKey, response));
666
+ return response
667
+ }
668
+ cache && cacheKey && (cachePool.put(cacheKey, data));
669
+ return data
670
+ }
671
+ };
672
+
673
+
674
+ function createAxios(opt) {
675
+ return new CCAxios(deepMerge({
676
+ timeout: 60 * 1000,
677
+ headers: {
678
+ 'Content-Type': 'application/json;charset=UTF-8',
679
+ },
680
+ transform: cloneDeep(transform),
681
+ requestOptions: {
682
+ envType: '',
683
+ errorMessageMode: 'modal',
684
+ //是否静默错误提示
685
+ silent: false,
686
+ // 接口是否需要缓存
687
+ cache: false,
688
+ // 接口重试相关
689
+ retryRequest: {
690
+ isOpenRetry: false,
691
+ count: 5,
692
+ waitTime: 100,
693
+ },
694
+ // 是否返回原生响应头 比如:需要获取响应头时使用该属性
695
+ isReturnNativeResponse: false,
696
+ }
697
+ }, opt || {}))
698
698
  }
699
699
 
700
700
  var CCHttp$1 = /*#__PURE__*/Object.freeze({
@@ -702,31 +702,31 @@ var CCHttp$1 = /*#__PURE__*/Object.freeze({
702
702
  createAxios: createAxios
703
703
  });
704
704
 
705
- Vue.prototype.$Bus = new Vue;
706
- window.ccBus = Vue.prototype.$Bus;
707
- /**
708
- * 发布信息
709
- * @param {string} event 事件名称
710
- * @param {...any} args 参数列表
711
- */
712
- function $emit(...args) {
713
- window.ccBus.$emit(...args);
714
- }
715
- /**
716
- * 订阅消息
717
- * @param {string} event 事件名称
718
- * @param {function} callback 回调方法
719
- */
720
- function $on(...args) {
721
- window.ccBus.$on(...args);
722
- }
723
- /**
724
- * 取消订阅
725
- * @param {string} event 事件名称
726
- * @param { function | function[] | undefined } callbacks 需要解除监听的事件
727
- */
728
- function $off(...args) {
729
- window.ccBus.$off(...args);
705
+ Vue.prototype.$Bus = new Vue;
706
+ window.ccBus = Vue.prototype.$Bus;
707
+ /**
708
+ * 发布信息
709
+ * @param {string} event 事件名称
710
+ * @param {...any} args 参数列表
711
+ */
712
+ function $emit(...args) {
713
+ window.ccBus.$emit(...args);
714
+ }
715
+ /**
716
+ * 订阅消息
717
+ * @param {string} event 事件名称
718
+ * @param {function} callback 回调方法
719
+ */
720
+ function $on(...args) {
721
+ window.ccBus.$on(...args);
722
+ }
723
+ /**
724
+ * 取消订阅
725
+ * @param {string} event 事件名称
726
+ * @param { function | function[] | undefined } callbacks 需要解除监听的事件
727
+ */
728
+ function $off(...args) {
729
+ window.ccBus.$off(...args);
730
730
  }
731
731
 
732
732
  var CCBus = /*#__PURE__*/Object.freeze({
@@ -736,57 +736,57 @@ var CCBus = /*#__PURE__*/Object.freeze({
736
736
  $off: $off
737
737
  });
738
738
 
739
- // 电话对象
740
- let ccCall = new Map();
741
- // 电话服务商当前对象
742
- let currentCall;
743
- /**
744
- * 初始化电话条
745
- * @param {string} id 电话服务商唯一标识
746
- * @param {object} callClient 电话对象
747
- */
748
- function init$1(id, callClient) {
749
- if (id && callClient) {
750
- ccCall.set(id, callClient);
751
- currentCall = callClient;
752
- return currentCall
753
- }
754
- }
755
-
756
-
757
- /**
758
- * 拨打电话
759
- * @param {string} id 电话服务商唯一标识
760
- * @param {object} options 配置信息
761
- */
762
- function call(id, options) {
763
- let call;
764
- if (id) {
765
- call = ccCall.get(id);
766
- } else {
767
- call = currentCall;
768
- }
769
- if (call) {
770
- call.call(options);
771
- }
772
- return call
773
- }
774
- /**
775
- * 打开通话面板
776
- * @param {string} id 电话服务商唯一标识
777
- * @param {object} options 配置信息
778
- */
779
- function openCallPanel(id, options) {
780
- let call;
781
- if (id) {
782
- call = ccCall.get(id);
783
- } else {
784
- call = currentCall;
785
- }
786
- if (call) {
787
- call.openCallPanel(options);
788
- }
789
- return call
739
+ // 电话对象
740
+ let ccCall = new Map();
741
+ // 电话服务商当前对象
742
+ let currentCall;
743
+ /**
744
+ * 初始化电话条
745
+ * @param {string} id 电话服务商唯一标识
746
+ * @param {object} callClient 电话对象
747
+ */
748
+ function init$1(id, callClient) {
749
+ if (id && callClient) {
750
+ ccCall.set(id, callClient);
751
+ currentCall = callClient;
752
+ return currentCall
753
+ }
754
+ }
755
+
756
+
757
+ /**
758
+ * 拨打电话
759
+ * @param {string} id 电话服务商唯一标识
760
+ * @param {object} options 配置信息
761
+ */
762
+ function call(id, options) {
763
+ let call;
764
+ if (id) {
765
+ call = ccCall.get(id);
766
+ } else {
767
+ call = currentCall;
768
+ }
769
+ if (call) {
770
+ call.call(options);
771
+ }
772
+ return call
773
+ }
774
+ /**
775
+ * 打开通话面板
776
+ * @param {string} id 电话服务商唯一标识
777
+ * @param {object} options 配置信息
778
+ */
779
+ function openCallPanel(id, options) {
780
+ let call;
781
+ if (id) {
782
+ call = ccCall.get(id);
783
+ } else {
784
+ call = currentCall;
785
+ }
786
+ if (call) {
787
+ call.openCallPanel(options);
788
+ }
789
+ return call
790
790
  }
791
791
 
792
792
  var CCCall = /*#__PURE__*/Object.freeze({
@@ -796,96 +796,96 @@ var CCCall = /*#__PURE__*/Object.freeze({
796
796
  openCallPanel: openCallPanel
797
797
  });
798
798
 
799
- /**
800
- * 错误日志上报
801
- * @param {object} response 响应体
802
- */
803
- function reportError(response) {
804
- if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
805
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
806
- }
807
- }
808
- /**
809
- * 常规日志上报
810
- * @param {object} response 响应体
811
- */
812
- function reportInfo(response) {
813
- if ("2" === window.Glod['CC_LOG_LEVEL']) {
814
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
815
- serviceName: "lightning-custom-page"
816
- });
817
- }
818
- }
819
-
820
- const service$1 = axios.create({
821
- timeout: 60 * 1000,
822
- headers: {
823
- 'Content-Type': 'application/json; charset=utf-8',
824
- },
825
- });
826
-
827
- service$1.interceptors.request.use(
828
- config => {
829
- config.headers.accessToken = window.$CCDK.CCToken.getToken();
830
- config.headers.requestId = window.$CCDK.CCUtils.getUuid();
831
- config.headers.requestIdProducer = "browser";
832
- return config
833
- },
834
- error => {
835
- Promise.reject(error);
836
- }
837
- );
838
-
839
-
840
- service$1.interceptors.response.use(
841
- response => {
842
- if (response.data.result) {
843
- // 上报日志
844
- reportInfo(response);
845
- return response.data
846
- } else {
847
- reportError(response);
848
- return Promise.reject(response)
849
- }
850
- },
851
- error => {
852
- // 上报错误日志
853
- if (error) {
854
- reportError(error.response);
855
- }
856
- return Promise.reject(error)
857
- }
858
- );
859
-
860
-
861
- var http = {
862
- get: (url, data = {}, responseType = '') => {
863
- return service$1({
864
- url: url,
865
- method: 'get',
866
- params: data,
867
- responseType: responseType
868
- })
869
- },
870
- post: (url, data = {}, responseType = '') => {
871
- return service$1({
872
- url: url,
873
- method: 'post',
874
- data: data,
875
- responseType: responseType
876
- })
877
- },
799
+ /**
800
+ * 错误日志上报
801
+ * @param {object} response 响应体
802
+ */
803
+ function reportError(response) {
804
+ if ("1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
805
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", { serviceName: "lightning-custom-page" });
806
+ }
807
+ }
808
+ /**
809
+ * 常规日志上报
810
+ * @param {object} response 响应体
811
+ */
812
+ function reportInfo(response) {
813
+ if ("2" === window.Glod['CC_LOG_LEVEL']) {
814
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", {
815
+ serviceName: "lightning-custom-page"
816
+ });
817
+ }
818
+ }
819
+
820
+ const service$1 = axios.create({
821
+ timeout: 60 * 1000,
822
+ headers: {
823
+ 'Content-Type': 'application/json; charset=utf-8',
824
+ },
825
+ });
826
+
827
+ service$1.interceptors.request.use(
828
+ config => {
829
+ config.headers.accessToken = window.$CCDK.CCToken.getToken();
830
+ config.headers.requestId = window.$CCDK.CCUtils.getUuid();
831
+ config.headers.requestIdProducer = "browser";
832
+ return config
833
+ },
834
+ error => {
835
+ Promise.reject(error);
836
+ }
837
+ );
838
+
839
+
840
+ service$1.interceptors.response.use(
841
+ response => {
842
+ if (response.data.result) {
843
+ // 上报日志
844
+ reportInfo(response);
845
+ return response.data
846
+ } else {
847
+ reportError(response);
848
+ return Promise.reject(response)
849
+ }
850
+ },
851
+ error => {
852
+ // 上报错误日志
853
+ if (error) {
854
+ reportError(error.response);
855
+ }
856
+ return Promise.reject(error)
857
+ }
858
+ );
859
+
860
+
861
+ var http = {
862
+ get: (url, data = {}, responseType = '') => {
863
+ return service$1({
864
+ url: url,
865
+ method: 'get',
866
+ params: data,
867
+ responseType: responseType
868
+ })
869
+ },
870
+ post: (url, data = {}, responseType = '') => {
871
+ return service$1({
872
+ url: url,
873
+ method: 'post',
874
+ data: data,
875
+ responseType: responseType
876
+ })
877
+ },
878
878
  };
879
879
 
880
- /**
881
- * 请求common接口
882
- * @param {string} className 类名
883
- * @param {string} methodName 方法名
884
- * @param {Array} params 参数集合
885
- * @returns {Promise}
886
- */
887
- function post$1(className, methodName, params) {
888
- return http.post(window.Glod['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
880
+ /**
881
+ * 请求common接口
882
+ * @param {string} className 类名
883
+ * @param {string} methodName 方法名
884
+ * @param {Array} params 参数集合
885
+ * @returns {Promise}
886
+ */
887
+ function post$1(className, methodName, params) {
888
+ return http.post(window.Glod['ccex-apitsf'] + '/api/openCall/common', { className, methodName, params });
889
889
  }
890
890
 
891
891
  var CCCommon = /*#__PURE__*/Object.freeze({
@@ -893,33 +893,33 @@ var CCCommon = /*#__PURE__*/Object.freeze({
893
893
  post: post$1
894
894
  });
895
895
 
896
- /**
897
- * 获取基础url
898
- * @returns 基础地址
899
- */
900
- function getBaseUrl() {
901
- return window.gw.BASE_URL || window.Glod.BASE_URL || (window.location.origin + "/ccdomaingateway")
902
- }
903
- /**
904
- * 获取网关对象
905
- * @returns 网关对象
906
- */
907
- function getGw() {
908
- return window.gw || window.Glod;
909
- }
910
- /**
911
- * 获取服务对象
912
- * @returns 服务对象
913
- */
914
- function getSvc() {
915
- return window.Glod;
916
- }
917
- /**
918
- * 获取静态资源的访问地址
919
- * @returns 静态资源访问地址
920
- */
921
- function getCDNUrl() {
922
- return window.Glod.CDN_URL;
896
+ /**
897
+ * 获取基础url
898
+ * @returns 基础地址
899
+ */
900
+ function getBaseUrl() {
901
+ return window.gw.BASE_URL || window.Glod.BASE_URL || (window.location.origin + "/ccdomaingateway")
902
+ }
903
+ /**
904
+ * 获取网关对象
905
+ * @returns 网关对象
906
+ */
907
+ function getGw() {
908
+ return window.gw || window.Glod;
909
+ }
910
+ /**
911
+ * 获取服务对象
912
+ * @returns 服务对象
913
+ */
914
+ function getSvc() {
915
+ return window.Glod;
916
+ }
917
+ /**
918
+ * 获取静态资源的访问地址
919
+ * @returns 静态资源访问地址
920
+ */
921
+ function getCDNUrl() {
922
+ return window.Glod.CDN_URL;
923
923
  }
924
924
 
925
925
  var CCConfig = /*#__PURE__*/Object.freeze({
@@ -930,69 +930,69 @@ var CCConfig = /*#__PURE__*/Object.freeze({
930
930
  getCDNUrl: getCDNUrl
931
931
  });
932
932
 
933
- /**
934
- * 加密
935
- * @param {String} data 数据
936
- * @param {String} key 密钥
937
- * @param {String} iv 偏移量
938
- * @returns
939
- */
940
- function getAesString(data, key, iv) {
941
- key = CryptoJS.enc.Utf8.parse(key);
942
- iv = CryptoJS.enc.Utf8.parse(iv);
943
- let encrypted = CryptoJS.AES.encrypt(data, key, {
944
- iv: iv,
945
- padding: CryptoJS.pad.Pkcs7,
946
- });
947
- return encrypted.toString(); //返回的是base64格式的密文
948
- }
949
-
950
- /**
951
- * 解密
952
- * @param {String} encrypted 密文
953
- * @param {String} key 密钥
954
- * @param {String} iv 偏移量
955
- * @returns
956
- */
957
- function getDAesString(encrypted, key, iv) {
958
- key = CryptoJS.enc.Utf8.parse(key);
959
- iv = CryptoJS.enc.Utf8.parse(iv);
960
- let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
961
- iv: iv,
962
- padding: CryptoJS.pad.Pkcs7,
963
- });
964
- return decrypted.toString(CryptoJS.enc.Utf8);
965
- }
966
-
967
- /**
968
- * CryptoJS加密
969
- * @param {String} data 数据
970
- * @param {String} key 密钥
971
- * @param {String} iv 偏移量
972
- * @returns 加密的数据
973
- */
974
- function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
975
- data = JSON.stringify(data);
976
- var encrypted = getAesString(data, key, iv); //密文
977
- return encrypted;
978
- }
979
-
980
- /**
981
- * CryptoJS解密
982
- * @param {String} data 加密的数据
983
- * @param {String} key 密钥
984
- * @param {String} iv 偏移量
985
- * @returns 解密的数据
986
- */
987
- function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
988
- try {
989
- var decryptedStr = getDAesString(data, key, iv);
990
- if (!decryptedStr) return null
991
- return JSON.parse(decryptedStr);
992
- } catch (error) {
993
- console.trace("解密密码错误", error);
994
- return null;
995
- }
933
+ /**
934
+ * 加密
935
+ * @param {String} data 数据
936
+ * @param {String} key 密钥
937
+ * @param {String} iv 偏移量
938
+ * @returns
939
+ */
940
+ function getAesString(data, key, iv) {
941
+ key = CryptoJS.enc.Utf8.parse(key);
942
+ iv = CryptoJS.enc.Utf8.parse(iv);
943
+ let encrypted = CryptoJS.AES.encrypt(data, key, {
944
+ iv: iv,
945
+ padding: CryptoJS.pad.Pkcs7,
946
+ });
947
+ return encrypted.toString(); //返回的是base64格式的密文
948
+ }
949
+
950
+ /**
951
+ * 解密
952
+ * @param {String} encrypted 密文
953
+ * @param {String} key 密钥
954
+ * @param {String} iv 偏移量
955
+ * @returns
956
+ */
957
+ function getDAesString(encrypted, key, iv) {
958
+ key = CryptoJS.enc.Utf8.parse(key);
959
+ iv = CryptoJS.enc.Utf8.parse(iv);
960
+ let decrypted = CryptoJS.AES.decrypt(encrypted, key, {
961
+ iv: iv,
962
+ padding: CryptoJS.pad.Pkcs7,
963
+ });
964
+ return decrypted.toString(CryptoJS.enc.Utf8);
965
+ }
966
+
967
+ /**
968
+ * CryptoJS加密
969
+ * @param {String} data 数据
970
+ * @param {String} key 密钥
971
+ * @param {String} iv 偏移量
972
+ * @returns 加密的数据
973
+ */
974
+ function encrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
975
+ data = JSON.stringify(data);
976
+ var encrypted = getAesString(data, key, iv); //密文
977
+ return encrypted;
978
+ }
979
+
980
+ /**
981
+ * CryptoJS解密
982
+ * @param {String} data 加密的数据
983
+ * @param {String} key 密钥
984
+ * @param {String} iv 偏移量
985
+ * @returns 解密的数据
986
+ */
987
+ function decrypt(data, key = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", iv = 1) {
988
+ try {
989
+ var decryptedStr = getDAesString(data, key, iv);
990
+ if (!decryptedStr) return null
991
+ return JSON.parse(decryptedStr);
992
+ } catch (error) {
993
+ console.trace("解密密码错误", error);
994
+ return null;
995
+ }
996
996
  }
997
997
 
998
998
  var Crypto = /*#__PURE__*/Object.freeze({
@@ -1001,76 +1001,76 @@ var Crypto = /*#__PURE__*/Object.freeze({
1001
1001
  decrypt: decrypt
1002
1002
  });
1003
1003
 
1004
- const service = axios.create({
1005
- timeout: 60000,
1006
- headers: {
1007
- 'Content-Type': 'application/json; charset=utf-8',
1008
- },
1009
- });
1010
-
1011
- service.interceptors.request.use(
1012
- config => {
1013
- config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
1014
- return config
1015
- },
1016
- error => {
1017
- Promise.reject(error);
1018
- }
1019
- );
1020
-
1021
- service.interceptors.response.use(
1022
- response => {
1023
- const code = response.data.code || 200;
1024
- if (code !== 200) {
1025
- return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
1026
- } else {
1027
- return response.data
1028
- }
1029
- },
1030
- error => {
1031
- return Promise.reject(error)
1032
- }
1033
- );
1034
- function get(url, data = {}, responseType = '') {
1035
- return service({
1036
- url: url,
1037
- method: 'get',
1038
- params: data,
1039
- responseType: responseType
1040
- })
1041
- }
1042
-
1043
- function post(url, data = {}, responseType = '') {
1044
- return service({
1045
- url: url,
1046
- method: 'post',
1047
- data: data,
1048
- responseType: responseType
1049
- })
1050
- }
1051
-
1052
- function put(url, data = {}) {
1053
- return service({
1054
- url: url,
1055
- method: 'put',
1056
- data: data
1057
- })
1058
- }
1059
-
1060
- function postParams(url, data = {}) {
1061
- return service({
1062
- url: url,
1063
- method: 'post',
1064
- params: data
1065
- })
1066
- }
1067
-
1068
- function patch(url, data = {}) {
1069
- return service({
1070
- url: url,
1071
- method: 'patch',
1072
- data: data
1073
- })
1004
+ const service = axios.create({
1005
+ timeout: 60000,
1006
+ headers: {
1007
+ 'Content-Type': 'application/json; charset=utf-8',
1008
+ },
1009
+ });
1010
+
1011
+ service.interceptors.request.use(
1012
+ config => {
1013
+ config.headers['accessToken'] = window.$CCDK.CCToken.getToken();
1014
+ return config
1015
+ },
1016
+ error => {
1017
+ Promise.reject(error);
1018
+ }
1019
+ );
1020
+
1021
+ service.interceptors.response.use(
1022
+ response => {
1023
+ const code = response.data.code || 200;
1024
+ if (code !== 200) {
1025
+ return Promise.reject(null == response.data.msg ? "未知异常" : response.data.msg)
1026
+ } else {
1027
+ return response.data
1028
+ }
1029
+ },
1030
+ error => {
1031
+ return Promise.reject(error)
1032
+ }
1033
+ );
1034
+ function get(url, data = {}, responseType = '') {
1035
+ return service({
1036
+ url: url,
1037
+ method: 'get',
1038
+ params: data,
1039
+ responseType: responseType
1040
+ })
1041
+ }
1042
+
1043
+ function post(url, data = {}, responseType = '') {
1044
+ return service({
1045
+ url: url,
1046
+ method: 'post',
1047
+ data: data,
1048
+ responseType: responseType
1049
+ })
1050
+ }
1051
+
1052
+ function put(url, data = {}) {
1053
+ return service({
1054
+ url: url,
1055
+ method: 'put',
1056
+ data: data
1057
+ })
1058
+ }
1059
+
1060
+ function postParams(url, data = {}) {
1061
+ return service({
1062
+ url: url,
1063
+ method: 'post',
1064
+ params: data
1065
+ })
1066
+ }
1067
+
1068
+ function patch(url, data = {}) {
1069
+ return service({
1070
+ url: url,
1071
+ method: 'patch',
1072
+ data: data
1073
+ })
1074
1074
  }
1075
1075
 
1076
1076
  var CCHttp = /*#__PURE__*/Object.freeze({
@@ -1082,64 +1082,64 @@ var CCHttp = /*#__PURE__*/Object.freeze({
1082
1082
  postParams: postParams
1083
1083
  });
1084
1084
 
1085
- /**
1086
- * 下载js,并挂载到document上
1087
- * @param {string} src js下载路径
1088
- * @param {object} scriptOption script配置参数
1089
- * @returns
1090
- */
1091
- function loadJs(src, scriptOption) {
1092
- return new Promise((resolve, reject) => {
1093
- let scriptTemp = document.createElement('script');
1094
- if (scriptOption) {
1095
- Object.assign(scriptTemp, scriptOption);
1096
- }
1097
- scriptTemp.type = "text/javascript";
1098
- scriptTemp.src = src;
1099
- document.body.appendChild(scriptTemp);
1100
-
1101
- scriptTemp.onload = () => {
1102
- resolve();
1103
- };
1104
- scriptTemp.onerror = () => {
1105
- reject();
1106
- };
1107
- })
1108
- }
1109
- /**
1110
- * 创建加载js组件
1111
- */
1112
- function createLoadJsComponent() {
1113
- Vue.component('cc-load-script', {
1114
- render: function (createElement) {
1115
- var self = this;
1116
- return createElement('script', {
1117
- attrs: {
1118
- type: 'text/javascript',
1119
- src: this.src
1120
- },
1121
- on: {
1122
- load: function (event) {
1123
- self.$emit('load', event);
1124
- },
1125
- error: function (event) {
1126
- self.$emit('error', event);
1127
- },
1128
- readystatechange: function (event) {
1129
- if (this.readyState == 'complete') {
1130
- self.$emit('load', event);
1131
- }
1132
- }
1133
- }
1134
- });
1135
- },
1136
- props: {
1137
- src: {
1138
- type: String,
1139
- required: true
1140
- }
1141
- }
1142
- });
1085
+ /**
1086
+ * 下载js,并挂载到document上
1087
+ * @param {string} src js下载路径
1088
+ * @param {object} scriptOption script配置参数
1089
+ * @returns
1090
+ */
1091
+ function loadJs(src, scriptOption) {
1092
+ return new Promise((resolve, reject) => {
1093
+ let scriptTemp = document.createElement('script');
1094
+ if (scriptOption) {
1095
+ Object.assign(scriptTemp, scriptOption);
1096
+ }
1097
+ scriptTemp.type = "text/javascript";
1098
+ scriptTemp.src = src;
1099
+ document.body.appendChild(scriptTemp);
1100
+
1101
+ scriptTemp.onload = () => {
1102
+ resolve();
1103
+ };
1104
+ scriptTemp.onerror = () => {
1105
+ reject();
1106
+ };
1107
+ })
1108
+ }
1109
+ /**
1110
+ * 创建加载js组件
1111
+ */
1112
+ function createLoadJsComponent() {
1113
+ Vue.component('cc-load-script', {
1114
+ render: function (createElement) {
1115
+ var self = this;
1116
+ return createElement('script', {
1117
+ attrs: {
1118
+ type: 'text/javascript',
1119
+ src: this.src
1120
+ },
1121
+ on: {
1122
+ load: function (event) {
1123
+ self.$emit('load', event);
1124
+ },
1125
+ error: function (event) {
1126
+ self.$emit('error', event);
1127
+ },
1128
+ readystatechange: function (event) {
1129
+ if (this.readyState == 'complete') {
1130
+ self.$emit('load', event);
1131
+ }
1132
+ }
1133
+ }
1134
+ });
1135
+ },
1136
+ props: {
1137
+ src: {
1138
+ type: String,
1139
+ required: true
1140
+ }
1141
+ }
1142
+ });
1143
1143
  }
1144
1144
 
1145
1145
  var CCLoad = /*#__PURE__*/Object.freeze({
@@ -1148,201 +1148,201 @@ var CCLoad = /*#__PURE__*/Object.freeze({
1148
1148
  createLoadJsComponent: createLoadJsComponent
1149
1149
  });
1150
1150
 
1151
- /**
1152
- * 获取日志基础信息
1153
- * @returns 日志基础信息
1154
- */
1155
- function getBaseInfo() {
1156
- let userInfo = window.$CCDK.CCUser.getUserInfo();
1157
- let old = {
1158
- // 用户名,使用登录账号
1159
- "userName": userInfo.loginName || "未知用户",
1160
- // 用户id
1161
- "userId": userInfo.userId,
1162
- // 组织id
1163
- "orgId": userInfo.orgId,
1164
- // 组织名称
1165
- "orgName": userInfo.orgName,
1166
- // 服务名称
1167
- "serviceName": "未知应用",
1168
- // 记录类型:platform平台日志,dev开发者日志
1169
- "recordType": "platform",
1170
- // 日志类型
1171
- "logType": "front",
1172
- // 发生时间
1173
- "operateTime": (new Date()).valueOf(),
1174
- // 发生时间的str格式:yyyy-MM-dd HH:mm:ss
1175
- "operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
1176
- // 日志标识码,没有这个标识码,不能上传
1177
- "cccode": "hidden",
1178
- // 日志显示级别默认2
1179
- "displayLevel": "2",
1180
- };
1181
- return old
1182
- }
1183
- /**
1184
- * 获取网络异常信息
1185
- * @param {object} response 网络请求响应体
1186
- * @returns 请求体信息
1187
- */
1188
- function getHttpErrorInfo(error = {}) {
1189
- let { config = {}, data = {} } = error;
1190
- if (config) {
1191
- return {
1192
- // 请求地址url
1193
- "requestUrl": config.baseURL + config.url,
1194
- // 请求id
1195
- "requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1196
- // 请求id类型
1197
- "requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
1198
- // 请求体
1199
- "requestParameter": config.data,
1200
- // 错误描述
1201
- "errorMessage": error.message || data.returnInfo || "未知错误",
1202
- // 请求结果状态
1203
- "requestResult": "失败",
1204
- // 日志级别
1205
- "errorLevel": "2",
1206
- // 堆栈信息
1207
- "printStackTraceInfo": (error.message || data.returnInfo || "未知错误") + "\n" + config.data,
1208
- }
1209
- } else {
1210
- return {}
1211
- }
1212
- }
1213
-
1214
-
1215
- /**
1216
- * 获取网络信息
1217
- * @param {object} response 网络请求响应体
1218
- * @returns 请求体信息
1219
- */
1220
- function getHttpInfo(response) {
1221
- if (response) {
1222
- if (window.performance) {
1223
- // 通过性能接口精确测量接口用时
1224
- let per = performance.getEntriesByName(response.request.responseURL, "resource");
1225
- if (per.length > 0) {
1226
- let index = per.length - 1;
1227
- response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
1228
- }
1229
- }
1230
- return {
1231
- // 接口用时
1232
- "spendTime": response.spendTime || "0",
1233
- // 请求地址url
1234
- "requestUrl": response.request ? response.request.responseURL : "",
1235
- // 请求id
1236
- "requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1237
- // 请求id类型
1238
- "requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
1239
- // 请求体
1240
- "requestParameter": response.config.data,
1241
- // 错误描述
1242
- "infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
1243
- // 请求结果状态
1244
- "requestResult": response.data.result ? "成功" : "失败",
1245
- // 日志类型:info,debug
1246
- "infoType": "info",
1247
- }
1248
- } else {
1249
- return {}
1250
- }
1251
- }
1252
-
1253
- /**
1254
- * 上报日志
1255
- * @param {string} url 请求地址
1256
- * @param {object} response 响应信息
1257
- * @param {string} type 日志类型,info,debug,error
1258
- * @param {object} logInfo 日志信息
1259
- */
1260
- function reportLog(url, response, type = "info", logInfo = {}) {
1261
- // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1262
- let userInfo = getBaseInfo();
1263
- if ("未知用户" != userInfo.userName && userInfo.userName) {
1264
- axios.post(url,
1265
- {
1266
- ...userInfo,
1267
- ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1268
- ...logInfo
1269
- });
1270
- }
1271
-
1272
- }
1273
-
1274
-
1275
- /**
1276
- * 批量上报日志
1277
- * @param {string} url 请求地址
1278
- * @param {object} response 响应信息
1279
- * @param {string} type 日志类型,info,debug,error
1280
- * @param {object} logInfo 日志信息
1281
- */
1282
- function batchReportLog(url, response, type = "info", logInfo = []) {
1283
- // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1284
- let userInfo = getBaseInfo();
1285
- if ("未知用户" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
1286
- let datas = logInfo.map(info => {
1287
- return {
1288
- ...userInfo,
1289
- ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1290
- ...info
1291
- }
1292
- });
1293
- axios.post(url, datas);
1294
- }
1295
-
1296
- }
1297
-
1298
- /**
1299
- * 上报info日志
1300
- * @param {object} logInfo 日志信息
1301
- * @param {object} response axios响应信息
1302
- */
1303
- function reportInfoLog(logInfo, response) {
1304
- logInfo.recordType = "dev";
1305
- reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
1306
- }
1307
- /**
1308
- * 上报错误信息
1309
- * @param {object} logInfo 日志信息
1310
- * @param {object} response axios响应信息
1311
- */
1312
- function reportErrorLog(logInfo, response) {
1313
- logInfo.recordType = "dev";
1314
- reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
1315
- }
1316
-
1317
-
1318
- /**
1319
- * CC错误日志上报:这个api目前没有使用的场景
1320
- * @param {object} error 响应体
1321
- * @param {object} options 配置信息
1322
- */
1323
- function reportCCError(error, options = { serviceName: "lightning-main" }) {
1324
- if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
1325
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
1326
- }
1327
- }
1328
- /**
1329
- * CC常规日志上报:这个api目前没有使用的场景
1330
- * @param {object} response 响应体
1331
- * @param {object} options 配置信息
1332
- */
1333
- function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
1334
- if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
1335
- if (response.config.data) {
1336
- try {
1337
- let data = JSON.parse(response.config.data);
1338
- if (data.head && data.head.accessToken) {
1339
- data.head.accessToken = "******";
1340
- response.config.data = JSON.stringify(data);
1341
- }
1342
- } catch (e) { }
1343
- }
1344
- window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
1345
- }
1151
+ /**
1152
+ * 获取日志基础信息
1153
+ * @returns 日志基础信息
1154
+ */
1155
+ function getBaseInfo() {
1156
+ let userInfo = window.$CCDK.CCUser.getUserInfo();
1157
+ let old = {
1158
+ // 用户名,使用登录账号
1159
+ "userName": userInfo.loginName || "未知用户",
1160
+ // 用户id
1161
+ "userId": userInfo.userId,
1162
+ // 组织id
1163
+ "orgId": userInfo.orgId,
1164
+ // 组织名称
1165
+ "orgName": userInfo.orgName,
1166
+ // 服务名称
1167
+ "serviceName": "未知应用",
1168
+ // 记录类型:platform平台日志,dev开发者日志
1169
+ "recordType": "platform",
1170
+ // 日志类型
1171
+ "logType": "front",
1172
+ // 发生时间
1173
+ "operateTime": (new Date()).valueOf(),
1174
+ // 发生时间的str格式:yyyy-MM-dd HH:mm:ss
1175
+ "operateTimeStr": window.$CCDK.CCUtils.getNowFormatDate(),
1176
+ // 日志标识码,没有这个标识码,不能上传
1177
+ "cccode": "hidden",
1178
+ // 日志显示级别默认2
1179
+ "displayLevel": "2",
1180
+ };
1181
+ return old
1182
+ }
1183
+ /**
1184
+ * 获取网络异常信息
1185
+ * @param {object} response 网络请求响应体
1186
+ * @returns 请求体信息
1187
+ */
1188
+ function getHttpErrorInfo(error = {}) {
1189
+ let { config = {}, data = {} } = error;
1190
+ if (config) {
1191
+ return {
1192
+ // 请求地址url
1193
+ "requestUrl": config.baseURL + config.url,
1194
+ // 请求id
1195
+ "requestId": config.headers ? config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1196
+ // 请求id类型
1197
+ "requestIdProducer": config.headers ? config.headers.requestIdProducer : "",
1198
+ // 请求体
1199
+ "requestParameter": config.data,
1200
+ // 错误描述
1201
+ "errorMessage": error.message || data.returnInfo || "未知错误",
1202
+ // 请求结果状态
1203
+ "requestResult": "失败",
1204
+ // 日志级别
1205
+ "errorLevel": "2",
1206
+ // 堆栈信息
1207
+ "printStackTraceInfo": (error.message || data.returnInfo || "未知错误") + "\n" + config.data,
1208
+ }
1209
+ } else {
1210
+ return {}
1211
+ }
1212
+ }
1213
+
1214
+
1215
+ /**
1216
+ * 获取网络信息
1217
+ * @param {object} response 网络请求响应体
1218
+ * @returns 请求体信息
1219
+ */
1220
+ function getHttpInfo(response) {
1221
+ if (response) {
1222
+ if (window.performance) {
1223
+ // 通过性能接口精确测量接口用时
1224
+ let per = performance.getEntriesByName(response.request.responseURL, "resource");
1225
+ if (per.length > 0) {
1226
+ let index = per.length - 1;
1227
+ response.spendTime = (per[index].fetchStart > 0) ? (per[index].responseEnd - per[index].fetchStart) : "0";
1228
+ }
1229
+ }
1230
+ return {
1231
+ // 接口用时
1232
+ "spendTime": response.spendTime || "0",
1233
+ // 请求地址url
1234
+ "requestUrl": response.request ? response.request.responseURL : "",
1235
+ // 请求id
1236
+ "requestId": response.config.headers ? response.config.headers.requestId : window.$CCDK.CCUtils.getUuid(),
1237
+ // 请求id类型
1238
+ "requestIdProducer": response.config.headers ? response.config.headers.requestIdProducer : "",
1239
+ // 请求体
1240
+ "requestParameter": response.config.data,
1241
+ // 错误描述
1242
+ "infoMessage": response.request.responseURL + ". took:" + (response.spendTime || 0).toFixed(0) + "ms" + "\n" + (response.config.data || ''),
1243
+ // 请求结果状态
1244
+ "requestResult": response.data.result ? "成功" : "失败",
1245
+ // 日志类型:info,debug
1246
+ "infoType": "info",
1247
+ }
1248
+ } else {
1249
+ return {}
1250
+ }
1251
+ }
1252
+
1253
+ /**
1254
+ * 上报日志
1255
+ * @param {string} url 请求地址
1256
+ * @param {object} response 响应信息
1257
+ * @param {string} type 日志类型,info,debug,error
1258
+ * @param {object} logInfo 日志信息
1259
+ */
1260
+ function reportLog(url, response, type = "info", logInfo = {}) {
1261
+ // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1262
+ let userInfo = getBaseInfo();
1263
+ if ("未知用户" != userInfo.userName && userInfo.userName) {
1264
+ axios.post(url,
1265
+ {
1266
+ ...userInfo,
1267
+ ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1268
+ ...logInfo
1269
+ });
1270
+ }
1271
+
1272
+ }
1273
+
1274
+
1275
+ /**
1276
+ * 批量上报日志
1277
+ * @param {string} url 请求地址
1278
+ * @param {object} response 响应信息
1279
+ * @param {string} type 日志类型,info,debug,error
1280
+ * @param {object} logInfo 日志信息
1281
+ */
1282
+ function batchReportLog(url, response, type = "info", logInfo = []) {
1283
+ // 某些情况下获取不到用户信息,可能是刚登陆,获取用户信息接口还没返回
1284
+ let userInfo = getBaseInfo();
1285
+ if ("未知用户" != userInfo.userName && userInfo.userName && logInfo.length > 0) {
1286
+ let datas = logInfo.map(info => {
1287
+ return {
1288
+ ...userInfo,
1289
+ ...(type === "info" ? getHttpInfo(response) : getHttpErrorInfo(response)),
1290
+ ...info
1291
+ }
1292
+ });
1293
+ axios.post(url, datas);
1294
+ }
1295
+
1296
+ }
1297
+
1298
+ /**
1299
+ * 上报info日志
1300
+ * @param {object} logInfo 日志信息
1301
+ * @param {object} response axios响应信息
1302
+ */
1303
+ function reportInfoLog(logInfo, response) {
1304
+ logInfo.recordType = "dev";
1305
+ reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", logInfo);
1306
+ }
1307
+ /**
1308
+ * 上报错误信息
1309
+ * @param {object} logInfo 日志信息
1310
+ * @param {object} response axios响应信息
1311
+ */
1312
+ function reportErrorLog(logInfo, response) {
1313
+ logInfo.recordType = "dev";
1314
+ reportLog(window.Glod['ccex-log'] + "/ccerrorlog", response, "error", logInfo);
1315
+ }
1316
+
1317
+
1318
+ /**
1319
+ * CC错误日志上报:这个api目前没有使用的场景
1320
+ * @param {object} error 响应体
1321
+ * @param {object} options 配置信息
1322
+ */
1323
+ function reportCCError(error, options = { serviceName: "lightning-main" }) {
1324
+ if (process.env.NODE_ENV == 'production' && "1" === window.Glod['CC_LOG_LEVEL'] || "2" === window.Glod['CC_LOG_LEVEL']) {
1325
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/ccerrorlog", error, "error", options);
1326
+ }
1327
+ }
1328
+ /**
1329
+ * CC常规日志上报:这个api目前没有使用的场景
1330
+ * @param {object} response 响应体
1331
+ * @param {object} options 配置信息
1332
+ */
1333
+ function reportCCInfo(response, options = { serviceName: "lightning-main" }) {
1334
+ if (process.env.NODE_ENV == 'production' && "2" === window.Glod['CC_LOG_LEVEL']) {
1335
+ if (response.config.data) {
1336
+ try {
1337
+ let data = JSON.parse(response.config.data);
1338
+ if (data.head && data.head.accessToken) {
1339
+ data.head.accessToken = "******";
1340
+ response.config.data = JSON.stringify(data);
1341
+ }
1342
+ } catch (e) { }
1343
+ }
1344
+ window.$CCDK.CCLog.reportLog(window.Glod['ccex-log'] + "/systeminfolog", response, "info", options);
1345
+ }
1346
1346
  }
1347
1347
 
1348
1348
  var CCLog = /*#__PURE__*/Object.freeze({
@@ -1355,123 +1355,123 @@ var CCLog = /*#__PURE__*/Object.freeze({
1355
1355
  batchReportLog: batchReportLog
1356
1356
  });
1357
1357
 
1358
- // 存储所有菜单标识
1359
- const ALL_MENU_LIST = 'all_menu_list';
1360
- // 存储当前选中的菜单
1361
- const CURRENT_MENU = 'current_menu';
1362
-
1363
- /**
1364
- * 获取全部菜单
1365
- */
1366
- function getAllMenu() {
1367
- let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
1368
- if (data) {
1369
- return JSON.parse(data)
1370
- }
1371
- return []
1372
- }
1373
-
1374
- /**
1375
- * 设置全部菜单
1376
- * @param {object} data 菜单集合
1377
- */
1378
- function setAllMenu(data = []) {
1379
- if (data) {
1380
- localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
1381
- }
1382
- }
1383
-
1384
- /**
1385
- * 缓存当前选中菜单对象
1386
- * @param {object} data 菜单对象
1387
- */
1388
- function setCurrentMenu(data = {}) {
1389
- if (data) {
1390
- localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
1391
- }
1392
- }
1393
-
1394
- /**
1395
- * 获取当前选中菜单对象
1396
- * @param {object} data 菜单对象
1397
- */
1398
- function getCurrentMenu() {
1399
- let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
1400
- if (data) {
1401
- return JSON.parse(data)
1402
- }
1403
- return {}
1404
- }
1405
-
1406
- /**
1407
- * 添加一个一级菜单
1408
- * @param {object} options 菜单配置
1409
- */
1410
- function addMenu1(options) {
1411
- window.$CCDK.CCBus.$emit('addMenu1', options);
1412
- }
1413
- /**
1414
- * 添加一个二级菜单
1415
- * @param {object} options 菜单配置
1416
- */
1417
- function addMenu2(options) {
1418
- window.$CCDK.CCBus.$emit('addMenu2', options);
1419
- }
1420
- /**
1421
- * 删除一个一级菜单
1422
- * @param {object} options 菜单配置
1423
- */
1424
- function deleteMenu1(options) {
1425
- window.$CCDK.CCBus.$emit('deleteMenu1', options);
1426
- }
1427
- /**
1428
- * 删除一个二级菜单
1429
- * @param {object} options 菜单配置
1430
- */
1431
- function deleteMenu2(options) {
1432
- window.$CCDK.CCBus.$emit('deleteMenu2', options);
1433
- }
1434
- /**
1435
- * 刷新一个一级菜单
1436
- * @param {object} options 菜单配置
1437
- */
1438
- function refreshMenu1(options) {
1439
- window.$CCDK.CCBus.$emit('refreshMenu1', options);
1440
- }
1441
- /**
1442
- * 刷新一个二级菜单
1443
- * @param {object} options 菜单配置
1444
- */
1445
- function refreshMenu2(options) {
1446
- window.$CCDK.CCBus.$emit('refreshMenu2', options);
1447
- }
1448
- /**
1449
- * 替换一个一级菜单
1450
- * @param {object} options 菜单配置
1451
- */
1452
- function replaceMenu1(options) {
1453
- window.$CCDK.CCBus.$emit('replaceMenu1', options);
1454
- }
1455
- /**
1456
- * 替换一个二级菜单
1457
- * @param {object} options 菜单配置
1458
- */
1459
- function replaceMenu2(options) {
1460
- window.$CCDK.CCBus.$emit('replaceMenu2', options);
1461
- }
1462
- /**
1463
- * 定位到已经打开的一级菜单
1464
- * @param {object} options 菜单配置
1465
- */
1466
- function reOpenMenu1(options) {
1467
- window.$CCDK.CCBus.$emit('reOpenMenu1', options);
1468
- }
1469
- /**
1470
- * 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
1471
- * @param {object} options 菜单配置
1472
- */
1473
- function reOpenMenu2(options) {
1474
- window.$CCDK.CCBus.$emit('reOpenMenu2', options);
1358
+ // 存储所有菜单标识
1359
+ const ALL_MENU_LIST = 'all_menu_list';
1360
+ // 存储当前选中的菜单
1361
+ const CURRENT_MENU = 'current_menu';
1362
+
1363
+ /**
1364
+ * 获取全部菜单
1365
+ */
1366
+ function getAllMenu() {
1367
+ let data = localStorage.getItem(Crypto.encrypt(ALL_MENU_LIST));
1368
+ if (data) {
1369
+ return JSON.parse(data)
1370
+ }
1371
+ return []
1372
+ }
1373
+
1374
+ /**
1375
+ * 设置全部菜单
1376
+ * @param {object} data 菜单集合
1377
+ */
1378
+ function setAllMenu(data = []) {
1379
+ if (data) {
1380
+ localStorage.setItem(Crypto.encrypt(ALL_MENU_LIST), JSON.stringify(data));
1381
+ }
1382
+ }
1383
+
1384
+ /**
1385
+ * 缓存当前选中菜单对象
1386
+ * @param {object} data 菜单对象
1387
+ */
1388
+ function setCurrentMenu(data = {}) {
1389
+ if (data) {
1390
+ localStorage.setItem(Crypto.encrypt(CURRENT_MENU), JSON.stringify(data));
1391
+ }
1392
+ }
1393
+
1394
+ /**
1395
+ * 获取当前选中菜单对象
1396
+ * @param {object} data 菜单对象
1397
+ */
1398
+ function getCurrentMenu() {
1399
+ let data = localStorage.getItem(Crypto.encrypt(CURRENT_MENU));
1400
+ if (data) {
1401
+ return JSON.parse(data)
1402
+ }
1403
+ return {}
1404
+ }
1405
+
1406
+ /**
1407
+ * 添加一个一级菜单
1408
+ * @param {object} options 菜单配置
1409
+ */
1410
+ function addMenu1(options) {
1411
+ window.$CCDK.CCBus.$emit('addMenu1', options);
1412
+ }
1413
+ /**
1414
+ * 添加一个二级菜单
1415
+ * @param {object} options 菜单配置
1416
+ */
1417
+ function addMenu2(options) {
1418
+ window.$CCDK.CCBus.$emit('addMenu2', options);
1419
+ }
1420
+ /**
1421
+ * 删除一个一级菜单
1422
+ * @param {object} options 菜单配置
1423
+ */
1424
+ function deleteMenu1(options) {
1425
+ window.$CCDK.CCBus.$emit('deleteMenu1', options);
1426
+ }
1427
+ /**
1428
+ * 删除一个二级菜单
1429
+ * @param {object} options 菜单配置
1430
+ */
1431
+ function deleteMenu2(options) {
1432
+ window.$CCDK.CCBus.$emit('deleteMenu2', options);
1433
+ }
1434
+ /**
1435
+ * 刷新一个一级菜单
1436
+ * @param {object} options 菜单配置
1437
+ */
1438
+ function refreshMenu1(options) {
1439
+ window.$CCDK.CCBus.$emit('refreshMenu1', options);
1440
+ }
1441
+ /**
1442
+ * 刷新一个二级菜单
1443
+ * @param {object} options 菜单配置
1444
+ */
1445
+ function refreshMenu2(options) {
1446
+ window.$CCDK.CCBus.$emit('refreshMenu2', options);
1447
+ }
1448
+ /**
1449
+ * 替换一个一级菜单
1450
+ * @param {object} options 菜单配置
1451
+ */
1452
+ function replaceMenu1(options) {
1453
+ window.$CCDK.CCBus.$emit('replaceMenu1', options);
1454
+ }
1455
+ /**
1456
+ * 替换一个二级菜单
1457
+ * @param {object} options 菜单配置
1458
+ */
1459
+ function replaceMenu2(options) {
1460
+ window.$CCDK.CCBus.$emit('replaceMenu2', options);
1461
+ }
1462
+ /**
1463
+ * 定位到已经打开的一级菜单
1464
+ * @param {object} options 菜单配置
1465
+ */
1466
+ function reOpenMenu1(options) {
1467
+ window.$CCDK.CCBus.$emit('reOpenMenu1', options);
1468
+ }
1469
+ /**
1470
+ * 定位到当前一级菜单下已经打开的二级菜单(前提是当前在二级菜单下)
1471
+ * @param {object} options 菜单配置
1472
+ */
1473
+ function reOpenMenu2(options) {
1474
+ window.$CCDK.CCBus.$emit('reOpenMenu2', options);
1475
1475
  }
1476
1476
 
1477
1477
  var CCMenu = /*#__PURE__*/Object.freeze({
@@ -1492,43 +1492,43 @@ var CCMenu = /*#__PURE__*/Object.freeze({
1492
1492
  getCurrentMenu: getCurrentMenu
1493
1493
  });
1494
1494
 
1495
- /**
1496
- * 消息提示框
1497
- * @param {string} text 提示文字,支持vhtml渲染
1498
- * @param {string} type 消息类别
1499
- * @param {number} duration 持续时间
1500
- * @param {boolean} showClose 是否显示消息关闭按钮
1501
- * @param {boolean} center 文字是否剧中
1502
- */
1503
- function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
1504
- Message({
1505
- message: text,
1506
- type,
1507
- duration,
1508
- showClose,
1509
- center
1510
- });
1511
- }
1512
- /**
1513
- * 提示确认框
1514
- * @param {string} text 提示信息
1515
- * @param {string} title 标题
1516
- * @param {object} options 配置信息
1517
- */
1518
- function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
1519
- MessageBox.confirm(text, title, options).then(() => {
1520
- confirm();
1521
- }).catch(() => {
1522
- reject();
1523
- });
1524
- }
1525
-
1526
- /**
1527
- * 提示消息框
1528
- * @param {object} options 配置信息
1529
- */
1530
- function showNotification(options = {}) {
1531
- Notification(options);
1495
+ /**
1496
+ * 消息提示框
1497
+ * @param {string} text 提示文字,支持vhtml渲染
1498
+ * @param {string} type 消息类别
1499
+ * @param {number} duration 持续时间
1500
+ * @param {boolean} showClose 是否显示消息关闭按钮
1501
+ * @param {boolean} center 文字是否剧中
1502
+ */
1503
+ function showMessage(text, type = 'info', duration = 3000, showClose = false, center = false) {
1504
+ Message({
1505
+ message: text,
1506
+ type,
1507
+ duration,
1508
+ showClose,
1509
+ center
1510
+ });
1511
+ }
1512
+ /**
1513
+ * 提示确认框
1514
+ * @param {string} text 提示信息
1515
+ * @param {string} title 标题
1516
+ * @param {object} options 配置信息
1517
+ */
1518
+ function showConfirm(text, title, options = {}, confirm = () => { }, reject = () => { }) {
1519
+ MessageBox.confirm(text, title, options).then(() => {
1520
+ confirm();
1521
+ }).catch(() => {
1522
+ reject();
1523
+ });
1524
+ }
1525
+
1526
+ /**
1527
+ * 提示消息框
1528
+ * @param {object} options 配置信息
1529
+ */
1530
+ function showNotification(options = {}) {
1531
+ Notification(options);
1532
1532
  }
1533
1533
 
1534
1534
  var CCMessage = /*#__PURE__*/Object.freeze({
@@ -1538,129 +1538,129 @@ var CCMessage = /*#__PURE__*/Object.freeze({
1538
1538
  showNotification: showNotification
1539
1539
  });
1540
1540
 
1541
- // 对象详情id存储标识
1542
- const OBJECT_DETAIL_ID = 'cc_object_detail_id';
1543
- // 对象存储标识
1544
- const OBJECT = 'cc_object';
1545
- // 列表视图存储标识
1546
- const OBJECT_LIST = 'cc_object_list';
1547
-
1548
- /**
1549
- * 获得当前标准对象信息
1550
- */
1551
- function getObject() {
1552
- let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1553
- if (detail) {
1554
- return JSON.parse(detail)
1555
- }
1556
- return ''
1557
- }
1558
-
1559
- /**
1560
- * 设置当前标准对象信息
1561
- * @param {object} detail 对象数据
1562
- */
1563
- function setObject(detail = '') {
1564
- if (detail) {
1565
- localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1566
- }
1567
- }
1568
-
1569
- /**
1570
- * 获得当前标准对象的详细信息
1571
- * @param {String} apiname: 查找字段的apiname
1572
- * @param {String} detailId: 详情页数据id
1573
- */
1574
- function getObjectDetail(apiname, detailId) {
1575
- let detail;
1576
- // 没有指定详情页id,获取最后一次的id
1577
- detailId = detailId || window.$CCDK.CCDetail.getDetailId();
1578
- if(detailId){
1579
- // 通过详情页id获取对应的详情页数据
1580
- detail = sessionStorage.getItem(detailId);
1581
- }
1582
- if (detail) {
1583
- // 转为对象
1584
- detail = JSON.parse(detail);
1585
- if (apiname) {
1586
- let detailList = detail.detail || [];
1587
- let targetField = undefined;
1588
- targetField = detailList.find(item => item.apiname === apiname);
1589
- return targetField
1590
- } else {
1591
- return detail
1592
- }
1593
- } else {
1594
- return ''
1595
- }
1596
-
1597
- }
1598
-
1599
- /**
1600
- * 设置当前标准对象的详细信息,默认两个小时有效期
1601
- * @param {object} detail 对象详细数据
1602
- */
1603
- function setObjectDetail(detail = '') {
1604
- if (detail && detail.id) {
1605
- // 减少detail.detail层级
1606
- if (Array.isArray(detail.detail) && detail.detail.length > 0) {
1607
- let data = [];
1608
- detail.detail.forEach(item => {
1609
- if (item && Array.isArray(item.data)) {
1610
- item.data.forEach(itemData => {
1611
- if (itemData.left && !Array.isArray(itemData.left)) {
1612
- data.push(itemData.left);
1613
- }
1614
- if (itemData.right && !Array.isArray(itemData.right)) {
1615
- data.push(itemData.right);
1616
- }
1617
- });
1618
- }
1619
- });
1620
- if (data.length > 0) {
1621
- detail.detail = data;
1622
- }
1623
- }
1624
- // 根据详情页id,记录详情页信息
1625
- sessionStorage.setItem(detail.id, JSON.stringify(detail));
1626
- }
1627
- }
1628
- /**
1629
- * 设置当前标准对象列表选中的信息
1630
- * @param {object} detail 选中数据
1631
- */
1632
- function setObjectList(detail = {}) {
1633
- if (detail) {
1634
- sessionStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
1635
- }
1636
- }
1637
- /**
1638
- * 获得当前标准对象列表选中的信息
1639
- */
1640
- function getObjectList() {
1641
- let detail = sessionStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1642
- if (detail) {
1643
- return JSON.parse(detail)
1644
- }
1645
- return { ids: [] }
1646
- }
1647
- /**
1648
- * 设置当前标准对象的详情页id
1649
- * @param {object} id 对象详情页id
1650
- */
1651
- function setObjectDetailId(id = '') {
1652
- if (id) {
1653
- // 兼容老版本,自定义页面使用
1654
- localStorage.setItem("detailRecordId", id);
1655
- // 调整为sessionStorage存储,和标签一一对应
1656
- sessionStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
1657
- }
1658
- }
1659
- /**
1660
- * 获取最后访问标准对象的详情页id
1661
- */
1662
- function getObjectDetailId() {
1663
- return sessionStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID))
1541
+ // 对象详情id存储标识
1542
+ const OBJECT_DETAIL_ID = 'cc_object_detail_id';
1543
+ // 对象存储标识
1544
+ const OBJECT = 'cc_object';
1545
+ // 列表视图存储标识
1546
+ const OBJECT_LIST = 'cc_object_list';
1547
+
1548
+ /**
1549
+ * 获得当前标准对象信息
1550
+ */
1551
+ function getObject() {
1552
+ let detail = localStorage.getItem(Crypto.encrypt(OBJECT));
1553
+ if (detail) {
1554
+ return JSON.parse(detail)
1555
+ }
1556
+ return ''
1557
+ }
1558
+
1559
+ /**
1560
+ * 设置当前标准对象信息
1561
+ * @param {object} detail 对象数据
1562
+ */
1563
+ function setObject(detail = '') {
1564
+ if (detail) {
1565
+ localStorage.setItem(Crypto.encrypt(OBJECT), JSON.stringify(detail));
1566
+ }
1567
+ }
1568
+
1569
+ /**
1570
+ * 获得当前标准对象的详细信息
1571
+ * @param {String} apiname: 查找字段的apiname
1572
+ * @param {String} detailId: 详情页数据id
1573
+ */
1574
+ function getObjectDetail(apiname, detailId) {
1575
+ let detail;
1576
+ // 没有指定详情页id,获取最后一次的id
1577
+ detailId = detailId || window.$CCDK.CCDetail.getDetailId();
1578
+ if(detailId){
1579
+ // 通过详情页id获取对应的详情页数据
1580
+ detail = sessionStorage.getItem(detailId);
1581
+ }
1582
+ if (detail) {
1583
+ // 转为对象
1584
+ detail = JSON.parse(detail);
1585
+ if (apiname) {
1586
+ let detailList = detail.detail || [];
1587
+ let targetField = undefined;
1588
+ targetField = detailList.find(item => item.apiname === apiname);
1589
+ return targetField
1590
+ } else {
1591
+ return detail
1592
+ }
1593
+ } else {
1594
+ return ''
1595
+ }
1596
+
1597
+ }
1598
+
1599
+ /**
1600
+ * 设置当前标准对象的详细信息,默认两个小时有效期
1601
+ * @param {object} detail 对象详细数据
1602
+ */
1603
+ function setObjectDetail(detail = '') {
1604
+ if (detail && detail.id) {
1605
+ // 减少detail.detail层级
1606
+ if (Array.isArray(detail.detail) && detail.detail.length > 0) {
1607
+ let data = [];
1608
+ detail.detail.forEach(item => {
1609
+ if (item && Array.isArray(item.data)) {
1610
+ item.data.forEach(itemData => {
1611
+ if (itemData.left && !Array.isArray(itemData.left)) {
1612
+ data.push(itemData.left);
1613
+ }
1614
+ if (itemData.right && !Array.isArray(itemData.right)) {
1615
+ data.push(itemData.right);
1616
+ }
1617
+ });
1618
+ }
1619
+ });
1620
+ if (data.length > 0) {
1621
+ detail.detail = data;
1622
+ }
1623
+ }
1624
+ // 根据详情页id,记录详情页信息
1625
+ sessionStorage.setItem(detail.id, JSON.stringify(detail));
1626
+ }
1627
+ }
1628
+ /**
1629
+ * 设置当前标准对象列表选中的信息
1630
+ * @param {object} detail 选中数据
1631
+ */
1632
+ function setObjectList(detail = {}) {
1633
+ if (detail) {
1634
+ sessionStorage.setItem(Crypto.encrypt(OBJECT_LIST), JSON.stringify(detail));
1635
+ }
1636
+ }
1637
+ /**
1638
+ * 获得当前标准对象列表选中的信息
1639
+ */
1640
+ function getObjectList() {
1641
+ let detail = sessionStorage.getItem(Crypto.encrypt(OBJECT_LIST));
1642
+ if (detail) {
1643
+ return JSON.parse(detail)
1644
+ }
1645
+ return { ids: [] }
1646
+ }
1647
+ /**
1648
+ * 设置当前标准对象的详情页id
1649
+ * @param {object} id 对象详情页id
1650
+ */
1651
+ function setObjectDetailId(id = '') {
1652
+ if (id) {
1653
+ // 兼容老版本,自定义页面使用
1654
+ localStorage.setItem("detailRecordId", id);
1655
+ // 调整为sessionStorage存储,和标签一一对应
1656
+ sessionStorage.setItem(Crypto.encrypt(OBJECT_DETAIL_ID),id);
1657
+ }
1658
+ }
1659
+ /**
1660
+ * 获取最后访问标准对象的详情页id
1661
+ */
1662
+ function getObjectDetailId() {
1663
+ return sessionStorage.getItem(Crypto.encrypt(OBJECT_DETAIL_ID))
1664
1664
  }
1665
1665
 
1666
1666
  var CCObject = /*#__PURE__*/Object.freeze({
@@ -1675,114 +1675,114 @@ var CCObject = /*#__PURE__*/Object.freeze({
1675
1675
  getObjectDetailId: getObjectDetailId
1676
1676
  });
1677
1677
 
1678
- /**
1679
- * 详情页的一些操作
1680
- */
1681
- // 表名
1682
- const TABLE_NAME$1 = "ccdetail";
1683
- // 相关列表选中key值标识
1684
- const record = "record";
1685
- /**
1686
- * 设置详情页相关列表选中数据
1687
- * @param {string} detailId 详情页id
1688
- * @param {string} recordId 相关列表id
1689
- * @param {Array} list 相关列表选中的数据
1690
- */
1691
- function setRelatedSelected(detailId,recordId,list){
1692
- if(detailId && recordId && list){
1693
- // 获取当前详情页选中数据
1694
- detailId = detailId+record;
1695
- let detail = sessionStorage.getItem(detailId);
1696
- if(detail){
1697
- detail = JSON.parse(detail);
1698
- detail[recordId] = list;
1699
- }else {
1700
- detail = {};
1701
- detail[recordId] = list;
1702
- }
1703
- // 存储到sessionStorage中
1704
- sessionStorage.setItem(detailId,JSON.stringify(detail));
1705
-
1706
- }
1707
- }
1708
- /**
1709
- * 获取相关列表选中数据
1710
- * @param {string} recordId 相关列表id
1711
- * @param {string} detailId 详情页id,不传默认获取当前详情页id
1712
- * @returns {Array,object} 详情页中相关列表选中的数据
1713
- */
1714
- function getRelatedSelected(recordId,detailId){
1715
- if(!detailId){
1716
- detailId = window.$CCDK.CCObject.getObjectDetailId();
1717
- if(!detailId) return ;
1718
- }
1719
- // 获取当前详情页选中数据
1720
- detailId = detailId+record;
1721
- let detail = sessionStorage.getItem(detailId);
1722
- if(detail){
1723
- detail = JSON.parse(detail);
1724
- // 指定记录类型recordId获取选中数据
1725
- if(recordId){
1726
- detail = detail[recordId];
1727
- }
1728
- }
1729
-
1730
- return detail
1731
-
1732
- }
1733
- /**
1734
- * 获得详情页数据
1735
- * @param {String} apiname: 查找字段的apiname
1736
- * @param {String} detailId: 详情页数据id
1737
- */
1738
- function getDetail(apiname, detailId) {
1739
- return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
1740
- }
1741
-
1742
- /**
1743
- * 设置当前标准对象的详细信息,默认两个小时有效期
1744
- * @param {object} detail 对象详细数据
1745
- */
1746
- function setDetail(detail = '') {
1747
- window.$CCDK.CCObject.setObjectDetail(detail);
1748
- }
1749
- /**
1750
- * 设置当前标准对象的详情页id
1751
- * @param {object} id 对象详情页id
1752
- */
1753
- function setDetailId(id = '') {
1754
- window.$CCDK.CCObject.setObjectDetailId(id);
1755
- }
1756
- /**
1757
- * 获取最后访问标准对象的详情页id
1758
- */
1759
- function getDetailId() {
1760
- return window.$CCDK.CCObject.getObjectDetailId()
1761
- }
1762
-
1763
- /**
1764
- * 刷新相关列表
1765
- * @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
1766
- */
1767
- function refreshRelatedList(ids) {
1768
- window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
1769
- }
1770
-
1771
- /**
1772
- * 存储数据
1773
- * @param {object} object 数据对象
1774
- * @returns
1775
- */
1776
- async function setRelatedFieldWidth(object) {
1777
- return await window.$CCDK.CCDB.create(TABLE_NAME$1, [object]);
1778
- }
1779
- /**
1780
- * 获取数据
1781
- * @param {object} object 过滤条件
1782
- * @returns
1783
- */
1784
- async function getRelatedFieldWidth(object) {
1785
- return await window.$CCDK.CCDB.list(TABLE_NAME$1, object);
1678
+ /**
1679
+ * 详情页的一些操作
1680
+ */
1681
+ // 表名
1682
+ const TABLE_NAME$1 = "ccdetail";
1683
+ // 相关列表选中key值标识
1684
+ const record = "record";
1685
+ /**
1686
+ * 设置详情页相关列表选中数据
1687
+ * @param {string} detailId 详情页id
1688
+ * @param {string} recordId 相关列表id
1689
+ * @param {Array} list 相关列表选中的数据
1690
+ */
1691
+ function setRelatedSelected(detailId,recordId,list){
1692
+ if(detailId && recordId && list){
1693
+ // 获取当前详情页选中数据
1694
+ detailId = detailId+record;
1695
+ let detail = sessionStorage.getItem(detailId);
1696
+ if(detail){
1697
+ detail = JSON.parse(detail);
1698
+ detail[recordId] = list;
1699
+ }else {
1700
+ detail = {};
1701
+ detail[recordId] = list;
1702
+ }
1703
+ // 存储到sessionStorage中
1704
+ sessionStorage.setItem(detailId,JSON.stringify(detail));
1705
+
1706
+ }
1707
+ }
1708
+ /**
1709
+ * 获取相关列表选中数据
1710
+ * @param {string} recordId 相关列表id
1711
+ * @param {string} detailId 详情页id,不传默认获取当前详情页id
1712
+ * @returns {Array,object} 详情页中相关列表选中的数据
1713
+ */
1714
+ function getRelatedSelected(recordId,detailId){
1715
+ if(!detailId){
1716
+ detailId = window.$CCDK.CCObject.getObjectDetailId();
1717
+ if(!detailId) return ;
1718
+ }
1719
+ // 获取当前详情页选中数据
1720
+ detailId = detailId+record;
1721
+ let detail = sessionStorage.getItem(detailId);
1722
+ if(detail){
1723
+ detail = JSON.parse(detail);
1724
+ // 指定记录类型recordId获取选中数据
1725
+ if(recordId){
1726
+ detail = detail[recordId];
1727
+ }
1728
+ }
1729
+
1730
+ return detail
1731
+
1732
+ }
1733
+ /**
1734
+ * 获得详情页数据
1735
+ * @param {String} apiname: 查找字段的apiname
1736
+ * @param {String} detailId: 详情页数据id
1737
+ */
1738
+ function getDetail(apiname, detailId) {
1739
+ return window.$CCDK.CCObject.getObjectDetail(apiname, detailId)
1740
+ }
1741
+
1742
+ /**
1743
+ * 设置当前标准对象的详细信息,默认两个小时有效期
1744
+ * @param {object} detail 对象详细数据
1745
+ */
1746
+ function setDetail(detail = '') {
1747
+ window.$CCDK.CCObject.setObjectDetail(detail);
1748
+ }
1749
+ /**
1750
+ * 设置当前标准对象的详情页id
1751
+ * @param {object} id 对象详情页id
1752
+ */
1753
+ function setDetailId(id = '') {
1754
+ window.$CCDK.CCObject.setObjectDetailId(id);
1755
+ }
1756
+ /**
1757
+ * 获取最后访问标准对象的详情页id
1758
+ */
1759
+ function getDetailId() {
1760
+ return window.$CCDK.CCObject.getObjectDetailId()
1761
+ }
1762
+
1763
+ /**
1764
+ * 刷新相关列表
1765
+ * @param {string} ids 相关列表ID字符串,逗号分隔,如果为空那么刷新所有相关列表
1766
+ */
1767
+ function refreshRelatedList(ids) {
1768
+ window.$CCDK.CCBus.$emit('refreshRelation', { relatedlistId: ids });
1769
+ }
1770
+
1771
+ /**
1772
+ * 存储数据
1773
+ * @param {object} object 数据对象
1774
+ * @returns
1775
+ */
1776
+ async function setRelatedFieldWidth(object) {
1777
+ return await window.$CCDK.CCDB.create(TABLE_NAME$1, [object]);
1778
+ }
1779
+ /**
1780
+ * 获取数据
1781
+ * @param {object} object 过滤条件
1782
+ * @returns
1783
+ */
1784
+ async function getRelatedFieldWidth(object) {
1785
+ return await window.$CCDK.CCDB.list(TABLE_NAME$1, object);
1786
1786
  }
1787
1787
 
1788
1788
  var CCDetail = /*#__PURE__*/Object.freeze({
@@ -1798,86 +1798,86 @@ var CCDetail = /*#__PURE__*/Object.freeze({
1798
1798
  getRelatedSelected: getRelatedSelected
1799
1799
  });
1800
1800
 
1801
- // 表名
1802
- const TABLE_NAME = "cclist";
1803
- /**
1804
- * 对象视图页一些操作
1805
- */
1806
- /**
1807
- * 设置当前标准对象列表选中的信息,仅更新ids
1808
- * @param {object} detail 选中数据
1809
- */
1810
- function setSelected(detail = {}) {
1811
- const ids = detail && detail.ids;
1812
- if(ids){
1813
- let info = window.$CCDK.CCObject.getObjectList() || {};
1814
- info.ids = ids;
1815
- window.$CCDK.CCObject.setObjectList(info);
1816
-
1817
- }
1818
-
1819
- }
1820
- /**
1821
- * 获得当前标准对象列表选中的信息
1822
- */
1823
- function getSelected() {
1824
- let {ids} = window.$CCDK.CCObject.getObjectList();
1825
- return { ids: ids }
1826
- }
1827
- /**
1828
- * 获得当前视图列表页选中的视图id
1829
- */
1830
- function getViewId() {
1831
- let {viewId} = window.$CCDK.CCObject.getObjectList();
1832
- return viewId || ''
1833
- }
1834
-
1835
- /**
1836
- * 设置过滤条件
1837
- * @param {object} object 过滤条件
1838
- * {
1839
- objprefix: "003",
1840
- viewid: "aec20238DB5F47AciNyO",
1841
- filtercondition: '{"data":[{"fieldId":"ffe100000001260MztUa","type":"S","val":"11222","objid":"account","op":"c"},{"fieldId":"ffe2017082200ad001fa","type":"AD","val":"中国","objid":"account","op":"c"}]}',
1842
- filterdetail:
1843
- }
1844
- */
1845
- async function setFilter(object) {
1846
- await window.$CCDK.CCDB.create(TABLE_NAME, [object]);
1847
- }
1848
- /**
1849
- * 获取过滤条件
1850
- * @param {object} object 过滤条件
1851
- * {
1852
- objprefix: "003",
1853
- viewid: "aec20238DB5F47AciNyO",
1854
- }
1855
- */
1856
- async function getFilter(object) {
1857
- return await window.$CCDK.CCDB.list(TABLE_NAME, object);
1858
- }
1859
- /**
1860
- * 删除某对象下某视图列表的筛选条件
1861
- * */
1862
- async function deleteFilter(id) {
1863
- return await window.$CCDK.CCDB.deleteCC(TABLE_NAME, id)
1864
- }
1865
-
1866
- /**
1867
- * 清空所有数据
1868
- */
1869
- async function clearFilterAll() {
1870
- await window.$CCDK.CCDB.db[TABLE_NAME].toCollection().modify(item => {
1871
- item.filtercondition = "";
1872
- item.filterdetail = "";
1873
- });
1874
- }
1875
- /**
1876
- * 获取当前对象视图页数据
1877
- * @return {object} 当前视图对象信息
1878
- */
1879
- function getViewInfo(){
1880
- return window.$CCDK.CCObject.getObjectList() || {}
1801
+ // 表名
1802
+ const TABLE_NAME = "cclist";
1803
+ /**
1804
+ * 对象视图页一些操作
1805
+ */
1806
+ /**
1807
+ * 设置当前标准对象列表选中的信息,仅更新ids
1808
+ * @param {object} detail 选中数据
1809
+ */
1810
+ function setSelected(detail = {}) {
1811
+ const ids = detail && detail.ids;
1812
+ if(ids){
1813
+ let info = window.$CCDK.CCObject.getObjectList() || {};
1814
+ info.ids = ids;
1815
+ window.$CCDK.CCObject.setObjectList(info);
1816
+
1817
+ }
1818
+
1819
+ }
1820
+ /**
1821
+ * 获得当前标准对象列表选中的信息
1822
+ */
1823
+ function getSelected() {
1824
+ let {ids} = window.$CCDK.CCObject.getObjectList();
1825
+ return { ids: ids }
1826
+ }
1827
+ /**
1828
+ * 获得当前视图列表页选中的视图id
1829
+ */
1830
+ function getViewId() {
1831
+ let {viewId} = window.$CCDK.CCObject.getObjectList();
1832
+ return viewId || ''
1833
+ }
1834
+
1835
+ /**
1836
+ * 设置过滤条件
1837
+ * @param {object} object 过滤条件
1838
+ * {
1839
+ objprefix: "003",
1840
+ viewid: "aec20238DB5F47AciNyO",
1841
+ filtercondition: '{"data":[{"fieldId":"ffe100000001260MztUa","type":"S","val":"11222","objid":"account","op":"c"},{"fieldId":"ffe2017082200ad001fa","type":"AD","val":"中国","objid":"account","op":"c"}]}',
1842
+ filterdetail:
1843
+ }
1844
+ */
1845
+ async function setFilter(object) {
1846
+ await window.$CCDK.CCDB.create(TABLE_NAME, [object]);
1847
+ }
1848
+ /**
1849
+ * 获取过滤条件
1850
+ * @param {object} object 过滤条件
1851
+ * {
1852
+ objprefix: "003",
1853
+ viewid: "aec20238DB5F47AciNyO",
1854
+ }
1855
+ */
1856
+ async function getFilter(object) {
1857
+ return await window.$CCDK.CCDB.list(TABLE_NAME, object);
1858
+ }
1859
+ /**
1860
+ * 删除某对象下某视图列表的筛选条件
1861
+ * */
1862
+ async function deleteFilter(id) {
1863
+ return await window.$CCDK.CCDB.deleteCC(TABLE_NAME, id)
1864
+ }
1865
+
1866
+ /**
1867
+ * 清空所有数据
1868
+ */
1869
+ async function clearFilterAll() {
1870
+ await window.$CCDK.CCDB.db[TABLE_NAME].toCollection().modify(item => {
1871
+ item.filtercondition = "";
1872
+ item.filterdetail = "";
1873
+ });
1874
+ }
1875
+ /**
1876
+ * 获取当前对象视图页数据
1877
+ * @return {object} 当前视图对象信息
1878
+ */
1879
+ function getViewInfo(){
1880
+ return window.$CCDK.CCObject.getObjectList() || {}
1881
1881
  }
1882
1882
 
1883
1883
  var CCList = /*#__PURE__*/Object.freeze({
@@ -1892,183 +1892,183 @@ var CCList = /*#__PURE__*/Object.freeze({
1892
1892
  getViewInfo: getViewInfo
1893
1893
  });
1894
1894
 
1895
- /**
1896
- * 用于保存打开的页面集合
1897
- */
1898
- let pageList = new Map();
1899
- /**
1900
- * 打开对象视图页面
1901
- * @param {object} obj 对象信息
1902
- * @param {object} options 配置信息
1903
- */
1904
- function openListPage(obj, options = {}) {
1905
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1906
- window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
1907
- return pageId;
1908
- }
1909
-
1910
- /**
1911
- * 打开数据详情页
1912
- * @param {object} obj 对象体
1913
- * @param {string} id 数据id
1914
- * @param {object} options 配置信息
1915
- */
1916
- function openDetailPage(obj, id, options = {}) {
1917
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1918
- window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
1919
- return pageId;
1920
- }
1921
-
1922
- /**
1923
- * 打开创建页面
1924
- * @param {object} obj 对象体
1925
- * @param {object} options 配置信息
1926
- */
1927
- function openCreatePage(obj, options = {}) {
1928
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1929
- window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
1930
- return pageId;
1931
- }
1932
-
1933
- /**
1934
- * 打开修改页面
1935
- * @param {object} obj 对象体
1936
- * @param {string} id 数据id
1937
- * @param {object} options 配置信息
1938
- */
1939
- function openEditPage(obj, id, options = {}) {
1940
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1941
- window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
1942
- return pageId;
1943
- }
1944
- /**
1945
- * 打开自定义页面
1946
- * @param {object} obj 自定义页面参数
1947
- * @param {object} options 配置信息
1948
- */
1949
- function openCustomPage(obj, options = {}) {
1950
- let pageId = options.pageId||Math.random().toString(16).slice(2);
1951
- window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
1952
- return pageId;
1953
- }
1954
-
1955
- /**
1956
- * 通过页面id,重新打开某个页面
1957
- * @param {string} pageId 页面id
1958
- * @param {object} options 配置信息
1959
- */
1960
- function reOpenPage(pageId, options) {
1961
- let page;
1962
- if (pageId) {
1963
- pageId = pageId + '';
1964
- page = pageList.get(pageId);
1965
- }
1966
- if (page) {
1967
- page.reOpenPage();
1968
- if (options.refresh) {
1969
- page.refresh();
1970
- }
1971
- }
1972
- }
1973
-
1974
- /**
1975
- * 将打开的页面添加到集合中
1976
- * @param {string} id 唯一ID
1977
- * @param {object} page 页面对象
1978
- */
1979
- function addPage(id, page) {
1980
- if (id && page) {
1981
- id = id + '';
1982
- pageList.set(id, page);
1983
- }
1984
- }
1985
-
1986
- /**
1987
- * 删除某个页面
1988
- * @param {string} pageId 唯一ID
1989
- */
1990
- function deletePage(pageId) {
1991
- if (pageId) {
1992
- pageId = pageId + '';
1993
- pageList.delete(pageId);
1994
- }
1995
- }
1996
- /**
1997
- * 更改页面数据
1998
- * @param {string} id 唯一ID
1999
- * @param {object} page 页面对象
2000
- */
2001
- function updatePage(id, page) {
2002
- if (id && page) {
2003
- id = id + '';
2004
- pageList.set(id, page);
2005
- }
2006
- }
2007
-
2008
- /**
2009
- * 通过页面id查询页面
2010
- * @param {string} pageId 唯一ID
2011
- */
2012
- function searchPage(pageId) {
2013
- pageId = pageId + '';
2014
- return pageList.get(pageId)
2015
- }
2016
- /**
2017
- * 关闭页面,如果pageId为null,那么关闭当前页面
2018
- * 如果pageId为all,关闭所有一级菜单
2019
- * @param {string} pageId 页面id
2020
- */
2021
- function close$1(pageId = '') {
2022
- let page;
2023
- if(pageId === 'all'){
2024
- page = [...pageList.values()];
2025
- page.forEach(item => {
2026
- if(item){
2027
- item.close();
2028
- }
2029
- });
2030
- }else if (pageId) {
2031
- pageId = pageId + '';
2032
- page = pageList.get(pageId);
2033
- } else {
2034
- // 不传pageId 默认关闭当前选中的
2035
- // 当前选中菜单的树形结构
2036
- let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
2037
- if (currentMenuTree) {
2038
- // 说明当前选中的是二级菜单
2039
- if (currentMenuTree.level2Id) {
2040
- page = pageList.get(currentMenuTree.level2Id);
2041
- } else {
2042
- // 说明当前选中的是一级菜单
2043
- page = pageList.get(currentMenuTree.id);
2044
- }
2045
- }
2046
- // if (pageList.size > 0) {
2047
- // page = [...pageList.values()][pageList.size - 1]
2048
- // }
2049
- }
2050
- if (page) {
2051
- page.close();
2052
- }
2053
- }
2054
- /**
2055
- * 刷新当前页面
2056
- */
2057
- function refresh() {
2058
- window.$CCDK.CCBus.$emit('refresh');
2059
- }
2060
- /**
2061
- * 获取当前一二级选中菜单的树形结构
2062
- * @param {object} obj 自定义页面参数
2063
- * @param {object} options 配置信息
2064
- */
2065
- function getCurrentPage() {
2066
- // 当前选中菜单的树形结构
2067
- let currentMenuTree = localStorage.getItem('current_page');
2068
- if (currentMenuTree) {
2069
- return JSON.parse(currentMenuTree)
2070
- }
2071
- return ''
1895
+ /**
1896
+ * 用于保存打开的页面集合
1897
+ */
1898
+ let pageList = new Map();
1899
+ /**
1900
+ * 打开对象视图页面
1901
+ * @param {object} obj 对象信息
1902
+ * @param {object} options 配置信息
1903
+ */
1904
+ function openListPage(obj, options = {}) {
1905
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1906
+ window.$CCDK.CCBus.$emit('openListPage', pageId, obj, options);
1907
+ return pageId;
1908
+ }
1909
+
1910
+ /**
1911
+ * 打开数据详情页
1912
+ * @param {object} obj 对象体
1913
+ * @param {string} id 数据id
1914
+ * @param {object} options 配置信息
1915
+ */
1916
+ function openDetailPage(obj, id, options = {}) {
1917
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1918
+ window.$CCDK.CCBus.$emit('openDetailPage', pageId, obj, id, options);
1919
+ return pageId;
1920
+ }
1921
+
1922
+ /**
1923
+ * 打开创建页面
1924
+ * @param {object} obj 对象体
1925
+ * @param {object} options 配置信息
1926
+ */
1927
+ function openCreatePage(obj, options = {}) {
1928
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1929
+ window.$CCDK.CCBus.$emit('openCreatePage', pageId, obj, options);
1930
+ return pageId;
1931
+ }
1932
+
1933
+ /**
1934
+ * 打开修改页面
1935
+ * @param {object} obj 对象体
1936
+ * @param {string} id 数据id
1937
+ * @param {object} options 配置信息
1938
+ */
1939
+ function openEditPage(obj, id, options = {}) {
1940
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1941
+ window.$CCDK.CCBus.$emit('openEditPage', pageId, obj, id, options);
1942
+ return pageId;
1943
+ }
1944
+ /**
1945
+ * 打开自定义页面
1946
+ * @param {object} obj 自定义页面参数
1947
+ * @param {object} options 配置信息
1948
+ */
1949
+ function openCustomPage(obj, options = {}) {
1950
+ let pageId = options.pageId||Math.random().toString(16).slice(2);
1951
+ window.$CCDK.CCBus.$emit('openCustomPage', pageId, obj, options);
1952
+ return pageId;
1953
+ }
1954
+
1955
+ /**
1956
+ * 通过页面id,重新打开某个页面
1957
+ * @param {string} pageId 页面id
1958
+ * @param {object} options 配置信息
1959
+ */
1960
+ function reOpenPage(pageId, options) {
1961
+ let page;
1962
+ if (pageId) {
1963
+ pageId = pageId + '';
1964
+ page = pageList.get(pageId);
1965
+ }
1966
+ if (page) {
1967
+ page.reOpenPage();
1968
+ if (options.refresh) {
1969
+ page.refresh();
1970
+ }
1971
+ }
1972
+ }
1973
+
1974
+ /**
1975
+ * 将打开的页面添加到集合中
1976
+ * @param {string} id 唯一ID
1977
+ * @param {object} page 页面对象
1978
+ */
1979
+ function addPage(id, page) {
1980
+ if (id && page) {
1981
+ id = id + '';
1982
+ pageList.set(id, page);
1983
+ }
1984
+ }
1985
+
1986
+ /**
1987
+ * 删除某个页面
1988
+ * @param {string} pageId 唯一ID
1989
+ */
1990
+ function deletePage(pageId) {
1991
+ if (pageId) {
1992
+ pageId = pageId + '';
1993
+ pageList.delete(pageId);
1994
+ }
1995
+ }
1996
+ /**
1997
+ * 更改页面数据
1998
+ * @param {string} id 唯一ID
1999
+ * @param {object} page 页面对象
2000
+ */
2001
+ function updatePage(id, page) {
2002
+ if (id && page) {
2003
+ id = id + '';
2004
+ pageList.set(id, page);
2005
+ }
2006
+ }
2007
+
2008
+ /**
2009
+ * 通过页面id查询页面
2010
+ * @param {string} pageId 唯一ID
2011
+ */
2012
+ function searchPage(pageId) {
2013
+ pageId = pageId + '';
2014
+ return pageList.get(pageId)
2015
+ }
2016
+ /**
2017
+ * 关闭页面,如果pageId为null,那么关闭当前页面
2018
+ * 如果pageId为all,关闭所有一级菜单
2019
+ * @param {string} pageId 页面id
2020
+ */
2021
+ function close$1(pageId = '') {
2022
+ let page;
2023
+ if(pageId === 'all'){
2024
+ page = [...pageList.values()];
2025
+ page.forEach(item => {
2026
+ if(item){
2027
+ item.close();
2028
+ }
2029
+ });
2030
+ }else if (pageId) {
2031
+ pageId = pageId + '';
2032
+ page = pageList.get(pageId);
2033
+ } else {
2034
+ // 不传pageId 默认关闭当前选中的
2035
+ // 当前选中菜单的树形结构
2036
+ let currentMenuTree = JSON.parse(localStorage.getItem('current_page'));
2037
+ if (currentMenuTree) {
2038
+ // 说明当前选中的是二级菜单
2039
+ if (currentMenuTree.level2Id) {
2040
+ page = pageList.get(currentMenuTree.level2Id);
2041
+ } else {
2042
+ // 说明当前选中的是一级菜单
2043
+ page = pageList.get(currentMenuTree.id);
2044
+ }
2045
+ }
2046
+ // if (pageList.size > 0) {
2047
+ // page = [...pageList.values()][pageList.size - 1]
2048
+ // }
2049
+ }
2050
+ if (page) {
2051
+ page.close();
2052
+ }
2053
+ }
2054
+ /**
2055
+ * 刷新当前页面
2056
+ */
2057
+ function refresh() {
2058
+ window.$CCDK.CCBus.$emit('refresh');
2059
+ }
2060
+ /**
2061
+ * 获取当前一二级选中菜单的树形结构
2062
+ * @param {object} obj 自定义页面参数
2063
+ * @param {object} options 配置信息
2064
+ */
2065
+ function getCurrentPage() {
2066
+ // 当前选中菜单的树形结构
2067
+ let currentMenuTree = localStorage.getItem('current_page');
2068
+ if (currentMenuTree) {
2069
+ return JSON.parse(currentMenuTree)
2070
+ }
2071
+ return ''
2072
2072
  }
2073
2073
 
2074
2074
  var CCPage = /*#__PURE__*/Object.freeze({
@@ -2088,62 +2088,62 @@ var CCPage = /*#__PURE__*/Object.freeze({
2088
2088
  getCurrentPage: getCurrentPage
2089
2089
  });
2090
2090
 
2091
- /**
2092
- * 设置用户信息
2093
- * @param {object} sentry
2094
- * @param {object} ccUser 用户信息
2095
- */
2096
- function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
2097
- if (ccUser && ccUser != "") {
2098
- // 添加日志监控标签:组织id
2099
- sentry.setTag("orgId", ccUser.orgId);
2100
- // 添加日志监控标签:组织名称
2101
- sentry.setTag("orgName", ccUser.orgName);
2102
- // 添加日志监控标签:用户id和用户名称
2103
- sentry.setUser({
2104
- username: ccUser.userName,
2105
- id: ccUser.userId,
2106
- });
2107
- }
2108
- }
2109
- /**
2110
- * 内存上报
2111
- * @param {object} sentry
2112
- */
2113
- function reportMemory(sentry, ccUser) {
2114
- if (performance.memory) {
2115
- let memeryMsg =
2116
- "内存监控:jsHeapSizeLimit=" +
2117
- (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
2118
- "mb、" +
2119
- "totalJSHeapSize=" +
2120
- (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
2121
- "mb、" +
2122
- "usedJSHeapSize=" +
2123
- (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
2124
- "mb";
2125
- initUserInfo(sentry, ccUser);
2126
- sentry.withScope(function (scope) {
2127
- // 使用内存
2128
- sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
2129
- // 添加日志监控标签:组织id
2130
- scope.setFingerprint(["内存监控"]);
2131
- sentry.captureMessage(memeryMsg);
2132
- });
2133
- }
2134
- }
2135
-
2136
- /**
2137
- * 网络异常上报
2138
- * @param {object} sentry
2139
- * @param {error} error
2140
- */
2141
- function reportHttpException(sentry, error, ccUser) {
2142
- initUserInfo(sentry, ccUser);
2143
- sentry.withScope(function (scope) {
2144
- scope.setFingerprint(["接口未捕获异常response"]);
2145
- sentry.captureException(error);
2146
- });
2091
+ /**
2092
+ * 设置用户信息
2093
+ * @param {object} sentry
2094
+ * @param {object} ccUser 用户信息
2095
+ */
2096
+ function initUserInfo(sentry, ccUser = window.$CCDK.CCUser.getUserInfo()) {
2097
+ if (ccUser && ccUser != "") {
2098
+ // 添加日志监控标签:组织id
2099
+ sentry.setTag("orgId", ccUser.orgId);
2100
+ // 添加日志监控标签:组织名称
2101
+ sentry.setTag("orgName", ccUser.orgName);
2102
+ // 添加日志监控标签:用户id和用户名称
2103
+ sentry.setUser({
2104
+ username: ccUser.userName,
2105
+ id: ccUser.userId,
2106
+ });
2107
+ }
2108
+ }
2109
+ /**
2110
+ * 内存上报
2111
+ * @param {object} sentry
2112
+ */
2113
+ function reportMemory(sentry, ccUser) {
2114
+ if (performance.memory) {
2115
+ let memeryMsg =
2116
+ "内存监控:jsHeapSizeLimit=" +
2117
+ (performance.memory.jsHeapSizeLimit / 1024 / 1024).toFixed(2) +
2118
+ "mb、" +
2119
+ "totalJSHeapSize=" +
2120
+ (performance.memory.totalJSHeapSize / 1024 / 1024).toFixed(2) +
2121
+ "mb、" +
2122
+ "usedJSHeapSize=" +
2123
+ (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2) +
2124
+ "mb";
2125
+ initUserInfo(sentry, ccUser);
2126
+ sentry.withScope(function (scope) {
2127
+ // 使用内存
2128
+ sentry.setTag("usedJSHeapSize", (performance.memory.usedJSHeapSize / 1024 / 1024).toFixed(2));
2129
+ // 添加日志监控标签:组织id
2130
+ scope.setFingerprint(["内存监控"]);
2131
+ sentry.captureMessage(memeryMsg);
2132
+ });
2133
+ }
2134
+ }
2135
+
2136
+ /**
2137
+ * 网络异常上报
2138
+ * @param {object} sentry
2139
+ * @param {error} error
2140
+ */
2141
+ function reportHttpException(sentry, error, ccUser) {
2142
+ initUserInfo(sentry, ccUser);
2143
+ sentry.withScope(function (scope) {
2144
+ scope.setFingerprint(["接口未捕获异常response"]);
2145
+ sentry.captureException(error);
2146
+ });
2147
2147
  }
2148
2148
 
2149
2149
  var CCSentry = /*#__PURE__*/Object.freeze({
@@ -2153,24 +2153,24 @@ var CCSentry = /*#__PURE__*/Object.freeze({
2153
2153
  reportHttpException: reportHttpException
2154
2154
  });
2155
2155
 
2156
- /**
2157
- * 初始化侧边区域
2158
- * @param {object} options 自定义页面配置
2159
- */
2160
- function init(options) {
2161
- window.$CCDK.CCBus.$emit('initSide', options);
2162
- }
2163
- /**
2164
- * 打开侧边区域
2165
- */
2166
- function open() {
2167
- window.$CCDK.CCBus.$emit('openSide');
2168
- }
2169
- /**
2170
- * 关闭侧边区域
2171
- */
2172
- function close() {
2173
- window.$CCDK.CCBus.$emit('closeSide');
2156
+ /**
2157
+ * 初始化侧边区域
2158
+ * @param {object} options 自定义页面配置
2159
+ */
2160
+ function init(options) {
2161
+ window.$CCDK.CCBus.$emit('initSide', options);
2162
+ }
2163
+ /**
2164
+ * 打开侧边区域
2165
+ */
2166
+ function open() {
2167
+ window.$CCDK.CCBus.$emit('openSide');
2168
+ }
2169
+ /**
2170
+ * 关闭侧边区域
2171
+ */
2172
+ function close() {
2173
+ window.$CCDK.CCBus.$emit('closeSide');
2174
2174
  }
2175
2175
 
2176
2176
  var CCSide = /*#__PURE__*/Object.freeze({
@@ -2180,60 +2180,60 @@ var CCSide = /*#__PURE__*/Object.freeze({
2180
2180
  close: close
2181
2181
  });
2182
2182
 
2183
- // cookie存储标识
2184
- const TOKEN = "cc_token";
2185
- /**
2186
- * 获取URL中参数的数据
2187
- * @param {name} 参数名
2188
- */
2189
- function getUrlQuery(name) {
2190
- var reg = new RegExp(name + "=([^&]*)(&|$)");
2191
- var r = window.location.href.match(reg);
2192
- let res = null;
2193
- if (r != null) res = r[1].trim();
2194
- return res;
2195
- }
2196
- /**
2197
- * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
2198
- * @param {String} urlName 获取token的url名称
2199
- * @param {String} cookieName 获取token的cookie名称
2200
- * @returns
2201
- */
2202
- function getToken(urlName = "binding", cookieName = TOKEN) {
2203
- let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN);
2204
- if (token) {
2205
- token = setToken(token, cookieName);
2206
- }
2207
- return token
2208
- }
2209
- /**
2210
- * 存储token
2211
- * @param {String} token token
2212
- * @param {String} cookieName 获取token的cookie名称
2213
- * @param {String} domain 域名
2214
- */
2215
- function setToken(token, cookieName = TOKEN, domain = getDomain()) {
2216
- // let { result } = verifyToken(token);
2217
- // if (result) {
2218
- Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 });
2219
- Cookies.set("JSESSIONID", token, { expires: 1 / 12 });
2220
- // localStorage.setItem(Crypto.encrypt(cookieName), token);
2221
- return token
2222
- // } else {
2223
- // return null
2224
- // }
2225
- }
2226
-
2227
- /**
2228
- * 清除Token数据
2229
- * @param {String} domain 域名
2230
- * @param {String} cookieName 获取token的cookie名称
2231
- */
2232
- function clearToken(cookieName = TOKEN, domain = getDomain()) {
2233
- Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
2234
- Cookies.remove(Crypto.encrypt(cookieName));
2235
- Cookies.remove("JSESSIONID");
2236
- localStorage.removeItem(Crypto.encrypt(cookieName));
2183
+ // cookie存储标识
2184
+ const TOKEN = "cc_token";
2185
+ /**
2186
+ * 获取URL中参数的数据
2187
+ * @param {name} 参数名
2188
+ */
2189
+ function getUrlQuery(name) {
2190
+ var reg = new RegExp(name + "=([^&]*)(&|$)");
2191
+ var r = window.location.href.match(reg);
2192
+ let res = null;
2193
+ if (r != null) res = r[1].trim();
2194
+ return res;
2195
+ }
2196
+ /**
2197
+ * 获取token:优先级-url最高,cc_token-cookies第二,binding-cookies第三,local第四
2198
+ * @param {String} urlName 获取token的url名称
2199
+ * @param {String} cookieName 获取token的cookie名称
2200
+ * @returns
2201
+ */
2202
+ function getToken(urlName = "binding", cookieName = TOKEN) {
2203
+ let token = getUrlQuery(urlName) || Cookies.get(Crypto.encrypt(cookieName)) || Cookies.get(urlName || TOKEN);
2204
+ if (token) {
2205
+ token = setToken(token, cookieName);
2206
+ }
2207
+ return token
2208
+ }
2209
+ /**
2210
+ * 存储token
2211
+ * @param {String} token token
2212
+ * @param {String} cookieName 获取token的cookie名称
2213
+ * @param {String} domain 域名
2214
+ */
2215
+ function setToken(token, cookieName = TOKEN, domain = getDomain()) {
2216
+ // let { result } = verifyToken(token);
2217
+ // if (result) {
2218
+ Cookies.set(Crypto.encrypt(cookieName), token, { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2219
+ Cookies.set("JSESSIONID", token, { expires: 1 / 12, sameSite: 'Lax' });
2220
+ // localStorage.setItem(Crypto.encrypt(cookieName), token);
2221
+ return token
2222
+ // } else {
2223
+ // return null
2224
+ // }
2225
+ }
2226
+
2227
+ /**
2228
+ * 清除Token数据
2229
+ * @param {String} domain 域名
2230
+ * @param {String} cookieName 获取token的cookie名称
2231
+ */
2232
+ function clearToken(cookieName = TOKEN, domain = getDomain()) {
2233
+ Cookies.remove(Crypto.encrypt(cookieName), { domain: domain });
2234
+ Cookies.remove(Crypto.encrypt(cookieName));
2235
+ Cookies.remove("JSESSIONID");
2236
+ localStorage.removeItem(Crypto.encrypt(cookieName));
2237
2237
  }
2238
2238
 
2239
2239
  var CCToken = /*#__PURE__*/Object.freeze({
@@ -2244,55 +2244,55 @@ var CCToken = /*#__PURE__*/Object.freeze({
2244
2244
  getUrlQuery: getUrlQuery
2245
2245
  });
2246
2246
 
2247
- // 用户cookie存储标识
2248
- const USER_INFO = "cc_user_info";
2249
- // JWT的cookie存储标识
2250
- const USER_JWT_INFO = "cc_user_jwt_info";
2251
-
2252
- /**
2253
- * 存储用户信息
2254
- * @param {String} userInfo 用户信息
2255
- * @param {String} domain 域名
2256
- */
2257
- function setUserInfo(userInfo, domain = getDomain()) {
2258
- Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 });
2259
- }
2260
-
2261
- /**
2262
- * 获取用户信息
2263
- * @returns {String} 用户信息
2264
- */
2265
- function getUserInfo() {
2266
- // 加密的用户信息
2267
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
2268
- if (encryptUserInfo) {
2269
- return Crypto.decrypt(encryptUserInfo)
2270
- } else {
2271
- return ""
2272
- }
2273
- }
2274
-
2275
- /**
2276
- * 存储用户jwt信息
2277
- * @param {String} jwtInfo 用户信息
2278
- * @param {String} domain 域名
2279
- */
2280
- function setUserJwtInfo(jwtInfo, domain = getDomain()) {
2281
- Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 });
2282
- }
2283
-
2284
- /**
2285
- * 获取用户jwt信息
2286
- * @returns {Object} 用户信息
2287
- */
2288
- function getUserJwtInfo() {
2289
- // 加密的用户信息
2290
- let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
2291
- if (encryptUserInfo) {
2292
- return JSON.parse(Crypto.decrypt(encryptUserInfo))
2293
- } else {
2294
- return {}
2295
- }
2247
+ // 用户cookie存储标识
2248
+ const USER_INFO = "cc_user_info";
2249
+ // JWT的cookie存储标识
2250
+ const USER_JWT_INFO = "cc_user_jwt_info";
2251
+
2252
+ /**
2253
+ * 存储用户信息
2254
+ * @param {String} userInfo 用户信息
2255
+ * @param {String} domain 域名
2256
+ */
2257
+ function setUserInfo(userInfo, domain = getDomain()) {
2258
+ Cookies.set(Crypto.encrypt(USER_INFO), Crypto.encrypt(userInfo), { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2259
+ }
2260
+
2261
+ /**
2262
+ * 获取用户信息
2263
+ * @returns {String} 用户信息
2264
+ */
2265
+ function getUserInfo() {
2266
+ // 加密的用户信息
2267
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_INFO));
2268
+ if (encryptUserInfo) {
2269
+ return Crypto.decrypt(encryptUserInfo)
2270
+ } else {
2271
+ return ""
2272
+ }
2273
+ }
2274
+
2275
+ /**
2276
+ * 存储用户jwt信息
2277
+ * @param {String} jwtInfo 用户信息
2278
+ * @param {String} domain 域名
2279
+ */
2280
+ function setUserJwtInfo(jwtInfo, domain = getDomain()) {
2281
+ Cookies.set(Crypto.encrypt(USER_JWT_INFO), Crypto.encrypt(jwtInfo), { domain: domain, expires: 1 / 12 , sameSite: 'Lax'});
2282
+ }
2283
+
2284
+ /**
2285
+ * 获取用户jwt信息
2286
+ * @returns {Object} 用户信息
2287
+ */
2288
+ function getUserJwtInfo() {
2289
+ // 加密的用户信息
2290
+ let encryptUserInfo = Cookies.get(Crypto.encrypt(USER_JWT_INFO));
2291
+ if (encryptUserInfo) {
2292
+ return JSON.parse(Crypto.decrypt(encryptUserInfo))
2293
+ } else {
2294
+ return {}
2295
+ }
2296
2296
  }
2297
2297
 
2298
2298
  var CCUser = /*#__PURE__*/Object.freeze({
@@ -2303,8 +2303,8 @@ var CCUser = /*#__PURE__*/Object.freeze({
2303
2303
  getUserJwtInfo: getUserJwtInfo
2304
2304
  });
2305
2305
 
2306
- let CCDK = { CCDB, CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
2307
- Vue.prototype.$CCDK = CCDK;
2306
+ let CCDK = { CCDB, CCApplication, CCAxios: CCHttp$1, CCUser, CCCrypto: Crypto, CCDetail, CCList, CCToken, CCConfig, CCLoad, CCLog, CCMenu, CCUtils, CCHttp, CCObject, CCPage, CCSentry, CCSide, CCBus, CCCall, CCCommon, CCMessage };
2307
+ Vue.prototype.$CCDK = CCDK;
2308
2308
  window.$CCDK = CCDK;
2309
2309
 
2310
2310
  export { CCDK as default };