gxd-uni-library-editx 1.0.70 → 1.0.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gxd-uni-library-editx",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
4
4
  "private": false,
5
5
  "description": "聚福宝基础插件专用库",
6
6
  "main": "index.js",
@@ -82,11 +82,14 @@
82
82
  ]),
83
83
  ...mapState({
84
84
  currentStyle:(state)=>{
85
- let style = {};
86
- Object.keys(state.currentStyle).map(key=>{
87
- style[`$${key}`] = state.currentStyle[key];
88
- });
89
- return style
85
+ if(state.currentStyle !== null) {
86
+ let style = {};
87
+ Object.keys(state.currentStyle).map(key=>{
88
+ style[`$${key}`] = state.currentStyle[key];
89
+ });
90
+ return style
91
+ }
92
+ return {}
90
93
  }
91
94
  })
92
95
 
@@ -318,7 +318,7 @@ class StyleForm {
318
318
  type: 'number',
319
319
  valueKey: borderWidth,
320
320
  value: data[borderWidth] || '',
321
- placeholder: '请输入边框颜色',
321
+ placeholder: '请输入边框大小',
322
322
  className: 'input80',
323
323
  },
324
324
  ].filter(i=>i).map(item=>{
@@ -812,6 +812,13 @@ class Helpers {
812
812
  }
813
813
 
814
814
  replacePathForDir(url){
815
+ //#ifndef H5
816
+ return url
817
+ //#endif
818
+
819
+
820
+
821
+ //#ifdef H5
815
822
  let siteDomain = `${window.location.protocol}//${window.location.host}`;
816
823
  let dir = '';
817
824
  if(store.state.brandInfo && store.state.brandInfo.deploy_dir) {
@@ -830,6 +837,7 @@ class Helpers {
830
837
  else return `${siteDomain}${url.replace(reg, '')}`;
831
838
  }
832
839
  return url;
840
+ //#endif
833
841
  }
834
842
 
835
843
  /**
@@ -209,12 +209,12 @@ export function handlePesponse(
209
209
  /**
210
210
  * @type {Vue}
211
211
  */
212
- let $vm = (getApp().globalData && getApp().globalData.$vm) || null;
212
+ let $vm = (getApp() && getApp().globalData && getApp().globalData.$vm) || null;
213
213
  let useTime = new Date().getTime() - request.start;
214
214
  let requestInfo = xdGetPesponseParams(request, response);
215
215
 
216
216
  //长连接(耗时连接)
217
- if (getApp().globalData
217
+ if (getApp() && getApp().globalData
218
218
  && getApp().globalData.$store
219
219
  && typeof getApp().saveLogs === 'function'
220
220
  && !checkNotLogs(request.options)
@@ -261,7 +261,7 @@ export function handlePesponse(
261
261
  }
262
262
 
263
263
  //记录错误日志
264
- if (typeof getApp().saveLogs === 'function'
264
+ if (getApp() && typeof getApp().saveLogs === 'function'
265
265
  && !checkNotLogs(request.options)
266
266
  ) {
267
267
  getApp().saveLogs(requestInfo, 'alert', 'ajax');
@@ -342,7 +342,7 @@ export function handlePesponse(
342
342
  }
343
343
 
344
344
  //记录错误日志
345
- if (typeof getApp().saveLogs === 'function'
345
+ if (getApp() && typeof getApp().saveLogs === 'function'
346
346
  && !checkNotLogs(request.options)
347
347
  ) {
348
348
  getApp().saveLogs(requestInfo, 'alert', 'ajax');
@@ -360,7 +360,7 @@ export function handlePesponse(
360
360
  }
361
361
 
362
362
  //记录错误日志
363
- if (typeof getApp().saveLogs === 'function'
363
+ if (getApp() && typeof getApp().saveLogs === 'function'
364
364
  && !checkNotLogs(request.options)
365
365
  ) {
366
366
  getApp().saveLogs(requestInfo, 'alert', 'ajax');
@@ -392,7 +392,7 @@ export function handlePesponse(
392
392
  //记录错误日志
393
393
  //statusCode === undefined 并且 忽略:.json静态文件和请求返沪时间小雨15秒的
394
394
  if(!uriIgnoreErrors(request.options.url, useTime)) {
395
- if (typeof getApp().saveLogs === 'function'
395
+ if (getApp() && typeof getApp().saveLogs === 'function'
396
396
  && !checkNotLogs(request.options)
397
397
  ) {
398
398
  getApp().saveLogs(requestInfo, 'alert', 'ajax');
@@ -402,7 +402,7 @@ export function handlePesponse(
402
402
 
403
403
  if (!$vm) {
404
404
  reject(response);
405
- throw new Error(message);
405
+ console.warn(message)
406
406
  } else {
407
407
  $vm.$xdHideLoading();
408
408
  reject(response);
@@ -5,7 +5,7 @@ import {runtime} from "@/common/runtime";
5
5
  const settings = require('./../../settings');
6
6
  const md5 = require('md5');
7
7
  import Vue from 'vue';
8
- import store from "@/store";
8
+ import store from "@/store/index";
9
9
  import {
10
10
  baseIsEmpty,
11
11
  baseJsDateToTime,
@@ -46,6 +46,18 @@ class Logs {
46
46
  return typeof uni.setStorageSync === 'function';
47
47
  }
48
48
 
49
+ setProject(pos, params){
50
+ console.warn(`${pos}:${JSON.stringify(params)}`)
51
+ }
52
+
53
+ getParams(data){
54
+ return {}
55
+ }
56
+
57
+ setARMSError(error){
58
+ console.error(error)
59
+ }
60
+
49
61
 
50
62
  checkApiHost() {
51
63
  if (typeof getApp !== 'function') return false;
@@ -0,0 +1,302 @@
1
+ 'use strict';
2
+ import {Base64} from 'js-base64';
3
+ import {runtime} from "@/common/runtime";
4
+
5
+ const settings = require('./../../settings');
6
+ const md5 = require('md5');
7
+ import Vue from 'vue';
8
+ import store from "@/store";
9
+ import {
10
+ baseIsEmpty,
11
+ baseJsDateToTime,
12
+ baseGetHost
13
+ } from "@/utils/xd.base";
14
+
15
+
16
+ let logInstance = null;
17
+
18
+
19
+ class Logs {
20
+ constructor() {
21
+ this.initDone = false; //是否已加载uni.request和brandInfo['api_host']完成
22
+ this.checkcount = 0; //最大检查1000次
23
+ this.startcount = 0; //最大检查可以上传日志次数
24
+ this.checkMaxWaitTime = 1000;
25
+ //this.check();
26
+ this.saveUploadedLog = [];
27
+ this.onUpdateKeyword = [
28
+ '$vm', //跟uniApp uni.createSelectorQuery() 有关
29
+ "e.x", //跟uniApp滚动组件有关
30
+ 'null is not an object (evaluating', //跟uniApp滚动组件有关
31
+ "Cannot read property 'x' of ",// 跟uniApp滚动组件有关
32
+ ];
33
+
34
+ //#ifdef H5
35
+ this.initH5GlobalEvent()
36
+ //#endif
37
+ }
38
+
39
+ checkUniRequest() {
40
+ if (typeof uni === 'undefined') return false;
41
+ return typeof uni.request === 'function';
42
+ }
43
+
44
+ checkUniSetStorage() {
45
+ if (typeof uni === 'undefined') return false;
46
+ return typeof uni.setStorageSync === 'function';
47
+ }
48
+
49
+
50
+ checkApiHost() {
51
+ if (typeof getApp !== 'function') return false;
52
+ if (typeof getApp().globalData === "undefined") return false;
53
+ if (typeof getApp().globalData.$xd === 'undefined') return false;
54
+ if (typeof getApp().globalData.$xd['brandInfo'] === 'undefined') return false;
55
+ return typeof getApp().globalData.$xd['brandInfo']['api_host'] !== 'undefined';
56
+ }
57
+
58
+ check() {
59
+ let timer = setInterval(() => {
60
+ if ((this.checkUniRequest() && this.checkApiHost())
61
+ || this.checkcount > this.checkMaxWaitTime
62
+ ) {
63
+ this.initDone = true;
64
+ if (this.checkUniRequest() && this.checkApiHost()) {
65
+ setTimeout(() => {
66
+ this.checkBeforeStart();
67
+ }, 2000)
68
+ }
69
+ clearInterval(timer);
70
+ } else {
71
+ this.checkcount++;
72
+ }
73
+ }, 10)
74
+ }
75
+
76
+ checkBeforeStart() {
77
+ let timer = setInterval(() => {
78
+ if (this.startcount > this.checkMaxWaitTime) {
79
+ clearTimeout(timer);
80
+ return;
81
+ }
82
+ if (getApp().globalData.$xd['userInfo'] !== undefined
83
+ && !baseIsEmpty(getApp().globalData.$xd['userInfo'])
84
+ ) {
85
+ this.goBeforeUploadLogs();
86
+ clearTimeout(timer);
87
+ } else {
88
+ this.startcount++;
89
+ }
90
+ }, 10)
91
+ }
92
+
93
+ goBeforeUploadLogs() {
94
+ let logsSave = uni.getStorageInfoSync();
95
+ let logs = [];
96
+ logsSave.keys.map((key) => {
97
+ if (key.indexOf('xd.log.') === 0) {
98
+ logs.push(key);
99
+ }
100
+ });
101
+ logs.map((key) => {
102
+ let logStorage = uni.getStorageSync(key);
103
+ let system = this.getSystemInfo();
104
+
105
+ this.ajaxLogs({
106
+ baseApi: getApp().globalData.$xd.brandInfo['api_host'],
107
+ level: logStorage.level,
108
+ content: JSON.stringify({
109
+ ...system,
110
+ date: baseJsDateToTime(new Date().getTime() / 1000),
111
+ ...logStorage.logs
112
+ })
113
+ })
114
+ uni.removeStorageSync(key);
115
+ })
116
+
117
+ }
118
+
119
+ getSystemInfo() {
120
+ console.log(getApp().globalData.$xd.userInfo);
121
+ let userInfo = {};
122
+ let ext = {};
123
+ if (getApp().globalData
124
+ && getApp().globalData.$xd
125
+ && getApp().globalData.$xd.userInfo
126
+ ) {
127
+ userInfo = Base64.encodeURI(JSON.stringify(getApp().globalData.$xd.userInfo));
128
+ }
129
+
130
+ //#ifdef MP-WEIXIN
131
+ if (!baseIsEmpty(uni.getExtConfigSync())) {
132
+ ext = Base64.encodeURI(JSON.stringify(uni.getExtConfigSync()));
133
+ }
134
+ //#endif
135
+
136
+ const {
137
+ SDKVersion,
138
+ model,
139
+ system,
140
+ version,
141
+ deviceOrientation
142
+ } = uni.getSystemInfoSync();
143
+
144
+ console.log(userInfo, ext, uni.getSystemInfoSync());
145
+ return {
146
+ platform: 'weixin',
147
+ project: settings.system,
148
+ SDKVersion,
149
+ model,
150
+ system,
151
+ version,
152
+ deviceOrientation,
153
+ userInfo,
154
+ ext,
155
+ }
156
+ }
157
+
158
+
159
+ /**
160
+ * @description 上报日志
161
+ * @param log {Object} 上报日志内容
162
+ * @param type {String} 上报日志内容类型
163
+ * type = global(全局错误)
164
+ * type = onerror(系统捕获全局错误信息)
165
+ * type = promise(异步请求全局捕获错误)
166
+ * type = info(普通日志上报错误)
167
+ * type = debug(上报调试日志)
168
+ * type = ajax(返回异步请求字符串错误)
169
+ * type = unkown(返回异步请求字符串错误)
170
+ * tyoe = setting.error (项目配置错误)
171
+ * type = entry.index (记录访问首页入口来源)
172
+ * type = ajax.default {记录异步请求不知道的code的值}
173
+ * @param level {String} 上报级别 alert|info|debug
174
+ */
175
+ push(log, level = 'alert', type = "info") {
176
+ if (level === 'debug') {
177
+ if (settings.isDebug) {
178
+ level = 'info';
179
+ type = 'debug';
180
+ } else return;
181
+ }
182
+ type = `handle.${type}`;
183
+ if (!this.initDone) {
184
+ this.saveLog({log, type, level});
185
+ } else {
186
+ this.updateLog(log, type, level);
187
+ }
188
+ }
189
+
190
+ ajaxLogs(data) {
191
+ store['dispatch']('saveLogs', data)
192
+ .then(res => {
193
+ })
194
+ .catch(res => {
195
+ })
196
+ }
197
+
198
+ /**
199
+ * @description 上报日志
200
+ * @param log
201
+ * @param type
202
+ * @param level
203
+ */
204
+ updateLog(log, type, level) {
205
+ console.log(log, type, level);
206
+ let system = this.getSystemInfo();
207
+ if (level === 'info') system = {}
208
+ let logs = {...system, type, ...log};
209
+ let key = 'xd.log.' + md5(JSON.stringify(logs));
210
+ if (!this.saveUploadedLog.includes(key)) {
211
+ this.ajaxLogs({
212
+ baseApi: getApp().globalData.$xd.brandInfo['api_host'],
213
+ level: level,
214
+ content: JSON.stringify({
215
+ date: baseJsDateToTime(new Date().getTime() / 1000),
216
+ ...logs
217
+ }),
218
+ });
219
+ this.saveUploadedLog.push(key);
220
+ }
221
+ }
222
+
223
+ saveLog({log, type, level}) {
224
+ let logs = {type, before: true, ...log};
225
+ let key = 'xd.log.' + md5(JSON.stringify(logs));
226
+ if (this.checkUniSetStorage()) {
227
+ uni.setStorageSync(key, {logs, level});
228
+ }
229
+ }
230
+
231
+ checkMessage(error) {
232
+ let errorStr = error;
233
+ if (Object.prototype.toString.call(error) === '[object Error]') {
234
+ errorStr = JSON.stringify(runtime().getErrorInfo(error));
235
+ }
236
+ if (Object.prototype.toString.call(error) === '[object String]') {
237
+ errorStr = error;
238
+ }
239
+ if (Object.prototype.toString.call(error) === '[object Object]') {
240
+ errorStr = JSON.stringify(error);
241
+ }
242
+
243
+ let isUpdate = true;
244
+ this.onUpdateKeyword.map((keyword) => {
245
+ if (errorStr.indexOf(keyword) !== -1) {
246
+ isUpdate = false
247
+ }
248
+ });
249
+ return isUpdate === false ? isUpdate : Base64.encodeURI(errorStr);
250
+ }
251
+
252
+ initH5GlobalEvent() {
253
+ /**vue捕获全局错误**/
254
+ this.vueErrorHandler();
255
+ }
256
+
257
+ /**
258
+ * @description vue全局报错
259
+ */
260
+ vueErrorHandler() {
261
+ Vue.config.errorHandler = (error, vm) => {
262
+ let messageStr = this.checkMessage(error);
263
+ if (messageStr !== false) {
264
+ this.push(
265
+ {error: messageStr},
266
+ 'alert',
267
+ 'global'
268
+ )
269
+ }
270
+
271
+ };
272
+ }
273
+
274
+ /**
275
+ * @description 统一Promise catch处理
276
+ * @param error {Error|String} 错误对象(new Error())|字符串当为字符串时候,全局捕获不会处理
277
+ * @param callback 回调事件
278
+ */
279
+ catch(error, callback = null) {
280
+ let messageStr = logInstance.checkMessage(error);
281
+ if (messageStr !== false) {
282
+ logInstance.push(
283
+ {error: messageStr},
284
+ 'alert',
285
+ 'catch'
286
+ );
287
+ }
288
+ if (typeof callback === 'function') callback()
289
+ }
290
+ }
291
+
292
+ function xdWxlog() {
293
+ if (logInstance === null) {
294
+ logInstance = new Logs();
295
+ }
296
+ return logInstance;
297
+ }
298
+
299
+
300
+ export default xdWxlog();
301
+
302
+