leisure-core 1.0.2 → 1.0.4

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 (94) hide show
  1. package/index.js +223 -0
  2. package/le-area/index.js +7 -0
  3. package/le-area/src/main.vue +112 -0
  4. package/le-button/index.js +7 -0
  5. package/le-button/src/main.vue +47 -0
  6. package/le-button-attach/index.js +6 -0
  7. package/le-button-attach/src/main.vue +171 -0
  8. package/le-button-msg/index.js +7 -0
  9. package/le-button-msg/src/main.vue +65 -0
  10. package/le-button-qr/index.js +7 -0
  11. package/le-button-qr/src/main.vue +96 -0
  12. package/le-date-picker/index.js +7 -0
  13. package/le-date-picker/src/main.vue +67 -0
  14. package/le-date-picker-auto/index.js +6 -0
  15. package/le-date-picker-auto/src/main.vue +131 -0
  16. package/le-dialog-container/index.js +7 -0
  17. package/le-dialog-container/src/main.vue +80 -0
  18. package/le-form/index.js +7 -0
  19. package/le-form/src/main.vue +13 -0
  20. package/le-form-item/index.js +7 -0
  21. package/le-form-item/src/main.vue +13 -0
  22. package/le-home/index.js +7 -0
  23. package/le-home/src/LeHeaderMenu.vue +60 -0
  24. package/le-home/src/main.vue +1307 -0
  25. package/le-home/src/sub.vue +82 -0
  26. package/le-image/index.js +7 -0
  27. package/le-image/src/main.vue +53 -0
  28. package/le-input/index.js +7 -0
  29. package/le-input/src/main.vue +15 -0
  30. package/le-input-advanced/index.js +7 -0
  31. package/le-input-advanced/src/main.vue +71 -0
  32. package/le-input-number/index.js +7 -0
  33. package/le-input-number/src/main.vue +15 -0
  34. package/le-input-validate/index.js +6 -0
  35. package/le-input-validate/src/main.vue +469 -0
  36. package/le-libs/js/drag.js +78 -0
  37. package/le-libs/js/event.js +3 -0
  38. package/le-libs/js/hrequest.js +76 -0
  39. package/le-libs/js/hrequestFile.js +151 -0
  40. package/le-libs/js/info.js +7 -0
  41. package/le-libs/js/tokens.js +13 -0
  42. package/le-libs/mixins/main.js +48 -0
  43. package/le-list/index.js +7 -0
  44. package/le-list/src/main.vue +645 -0
  45. package/le-list-form/index.js +7 -0
  46. package/le-list-form/src/main.vue +474 -0
  47. package/le-login/index.js +7 -0
  48. package/le-login/src/ForgotPassword.vue +613 -0
  49. package/le-login/src/main.vue +982 -0
  50. package/le-media/index.js +7 -0
  51. package/le-media/src/main.vue +298 -0
  52. package/le-media-list/index.js +7 -0
  53. package/le-media-list/src/main.vue +178 -0
  54. package/le-media-upload/index.js +7 -0
  55. package/le-media-upload/src/main.vue +329 -0
  56. package/le-menu/index.js +7 -0
  57. package/le-menu/src/main.vue +248 -0
  58. package/le-report/index.js +6 -0
  59. package/le-report/src/main.vue +1747 -0
  60. package/le-report/src/rmixins.js +30 -0
  61. package/le-role/index.js +7 -0
  62. package/le-role/src/main.vue +183 -0
  63. package/le-role/src/sub.vue +79 -0
  64. package/le-role-user/index.js +7 -0
  65. package/le-role-user/src/main.vue +160 -0
  66. package/le-role-user/src/sub.vue +90 -0
  67. package/le-select/index.js +7 -0
  68. package/le-select/src/main.vue +49 -0
  69. package/le-select-multi/index.js +6 -0
  70. package/le-select-multi/src/main.vue +816 -0
  71. package/le-select-option/index.js +7 -0
  72. package/le-select-option/src/main.vue +69 -0
  73. package/le-select-search/index.js +7 -0
  74. package/le-select-search/src/main.vue +46 -0
  75. package/le-span/index.js +7 -0
  76. package/le-span/src/main.vue +29 -0
  77. package/le-table-edit/index.js +6 -0
  78. package/le-table-edit/src/main.vue +689 -0
  79. package/le-theme/common/vars.css +131 -0
  80. package/le-theme/iconfont/iconfont.css +125 -0
  81. package/le-theme/iconfont/iconfont.ttf +0 -0
  82. package/le-theme/iconfont/iconfont.woff +0 -0
  83. package/le-theme/iconfont/iconfont.woff2 +0 -0
  84. package/le-theme/index.js +189 -0
  85. package/le-theme/pages/index.css +15 -0
  86. package/le-upload/index.js +7 -0
  87. package/le-upload/src/main.vue +134 -0
  88. package/le-upload-table/index.js +6 -0
  89. package/le-upload-table/src/main.vue +648 -0
  90. package/le-url/index.js +7 -0
  91. package/le-url/src/main.vue +27 -0
  92. package/le-video/index.js +7 -0
  93. package/le-video/src/main.vue +42 -0
  94. package/package.json +1 -6
@@ -0,0 +1,469 @@
1
+ <template>
2
+ <div class="le-input-wrapper">
3
+ <el-input
4
+ ref="inputRef"
5
+ v-bind="mergedAttrs"
6
+ :class="['le-input', $attrs.class, { 'is-error': hasError }]"
7
+ :style="$attrs.style"
8
+ clearable
9
+ @input="handleInput"
10
+ @blur="handleBlur"
11
+ @clear="handleClear"
12
+ @focus="handleFocus"
13
+ >
14
+ <!-- 显式透传 prepend 插槽 -->
15
+ <template v-if="$slots.prepend" #prepend>
16
+ <slot name="prepend" />
17
+ </template>
18
+
19
+ <!-- 显式透传 append 插槽 -->
20
+ <template v-if="$slots.append" #append>
21
+ <slot name="append" />
22
+ </template>
23
+
24
+ <!-- 显式透传 prefix 插槽 -->
25
+ <template v-if="$slots.prefix" #prefix>
26
+ <slot name="prefix" />
27
+ </template>
28
+ <template v-if="showCount" #suffix>
29
+ <span class="input-count" :class="{ 'is-error': isOverMaxLength }">
30
+ {{ valueLength }}/{{ computedMaxlength }}
31
+ </span>
32
+ </template>
33
+ <template v-else-if="$slots.suffix" #suffix>
34
+ <slot name="suffix" />
35
+ </template>
36
+ </el-input>
37
+
38
+ <div v-if="hasError && errorMessage" class="error-message">
39
+ {{ errorMessage }}
40
+ </div>
41
+ </div>
42
+ </template>
43
+
44
+ <script>
45
+ export default {
46
+ name: "le-input-validate",
47
+ inheritAttrs: false,
48
+
49
+ props: {
50
+ number: {
51
+ type: Boolean,
52
+ default: false,
53
+ },
54
+ mobile: {
55
+ type: Boolean,
56
+ default: false,
57
+ },
58
+ email: {
59
+ type: Boolean,
60
+ default: false,
61
+ },
62
+ amount: {
63
+ type: Boolean,
64
+ default: false,
65
+ },
66
+ maxlength: {
67
+ type: [Number, String],
68
+ default: null,
69
+ },
70
+ showCount: {
71
+ type: Boolean,
72
+ default: false,
73
+ },
74
+ validator: {
75
+ type: Function,
76
+ default: null,
77
+ },
78
+ value: {
79
+ type: [String, Number],
80
+ default: "",
81
+ },
82
+ allowDecimal: {
83
+ type: Boolean,
84
+ default: true,
85
+ },
86
+ decimalLimit: {
87
+ type: Number,
88
+ default: 2,
89
+ },
90
+ allowNegative: {
91
+ type: Boolean,
92
+ default: false,
93
+ },
94
+ },
95
+
96
+ data() {
97
+ return {
98
+ hasError: false,
99
+ errorMessage: "",
100
+ internalValue: this.value,
101
+ isTouched: false,
102
+ isFocused: false,
103
+ };
104
+ },
105
+
106
+ computed: {
107
+ mergedAttrs() {
108
+ const attrs = { ...this.$attrs };
109
+
110
+ delete attrs.class;
111
+ delete attrs.style;
112
+ delete attrs.number;
113
+ delete attrs.mobile;
114
+ delete attrs.email;
115
+ delete attrs.amount;
116
+ delete attrs.maxlength;
117
+ delete attrs.showCount;
118
+ delete attrs.validator;
119
+ delete attrs.value;
120
+ delete attrs.allowDecimal;
121
+ delete attrs.decimalLimit;
122
+ delete attrs.allowNegative;
123
+
124
+ return {
125
+ ...attrs,
126
+ value: this.displayValue,
127
+ maxlength: this.computedMaxlength,
128
+ };
129
+ },
130
+
131
+ computedMaxlength() {
132
+ if (this.maxlength) {
133
+ return Number(this.maxlength);
134
+ }
135
+ if (this.mobile) {
136
+ return 11;
137
+ }
138
+ return null;
139
+ },
140
+
141
+ valueLength() {
142
+ return String(this.internalValue || "").length;
143
+ },
144
+
145
+ isOverMaxLength() {
146
+ return (
147
+ this.computedMaxlength && this.valueLength > this.computedMaxlength
148
+ );
149
+ },
150
+
151
+ displayValue() {
152
+ if (
153
+ this.amount &&
154
+ !this.isFocused &&
155
+ this.internalValue !== undefined &&
156
+ this.internalValue !== ""
157
+ ) {
158
+ return this.formatAmount(this.internalValue);
159
+ }
160
+ return this.internalValue;
161
+ },
162
+ },
163
+
164
+ watch: {
165
+ value(newVal) {
166
+ this.internalValue = newVal;
167
+ },
168
+
169
+ internalValue(newVal) {
170
+ this.validateInput(newVal);
171
+ this.$listeners.change && this.$listeners.change(newVal);
172
+ },
173
+ },
174
+
175
+ methods: {
176
+ handleInput(value) {
177
+ let processedValue = value;
178
+
179
+ if (this.number) {
180
+ processedValue = this.formatNumber(value);
181
+ }
182
+
183
+ if (this.mobile) {
184
+ processedValue = this.formatMobile(value);
185
+ }
186
+
187
+ if (this.amount) {
188
+ processedValue = this.formatAmountInput(value);
189
+ }
190
+
191
+ if (
192
+ this.computedMaxlength &&
193
+ processedValue.length > this.computedMaxlength
194
+ ) {
195
+ processedValue = processedValue.slice(0, this.computedMaxlength);
196
+ }
197
+
198
+ this.internalValue = processedValue;
199
+ this.$emit("input", processedValue);
200
+ this.$listeners.input && this.$listeners.input(processedValue);
201
+ },
202
+
203
+ handleBlur(event) {
204
+ this.isTouched = true;
205
+ this.isFocused = false;
206
+ this.validateInput(this.internalValue, true);
207
+ this.$emit("blur", event);
208
+ this.$listeners.blur && this.$listeners.blur(event);
209
+ },
210
+
211
+ handleFocus(event) {
212
+ this.isFocused = true;
213
+ this.$emit("focus", event);
214
+ this.$listeners.focus && this.$listeners.focus(event);
215
+ },
216
+
217
+ handleClear() {
218
+ this.hasError = false;
219
+ this.errorMessage = "";
220
+ this.$emit("clear");
221
+ this.$listeners.clear && this.$listeners.clear();
222
+ },
223
+
224
+ formatNumber(value) {
225
+ let filtered = value;
226
+ if (this.allowNegative) {
227
+ // 允许负数:保留数字、小数点、负号,负号只能出现在开头
228
+ filtered = value.replace(/[^\d.-]/g, "");
229
+ const hasNegative = filtered.startsWith("-");
230
+ filtered = filtered.replace(/-/g, "");
231
+ if (hasNegative) {
232
+ filtered = "-" + filtered;
233
+ }
234
+ filtered = filtered.replace(/(\..*)\./g, "$1");
235
+ } else {
236
+ filtered = value.replace(/[^\d.]/g, "");
237
+ filtered = filtered.replace(/(\..*)\./g, "$1");
238
+ }
239
+
240
+ if (this.number && !this.allowDecimal) {
241
+ filtered = filtered.replace(/\./g, "");
242
+ }
243
+
244
+ if (this.number && this.allowDecimal && this.decimalLimit > 0) {
245
+ const parts = filtered.split(".");
246
+ if (parts.length === 2 && parts[1].length > this.decimalLimit) {
247
+ filtered = parts[0] + "." + parts[1].substring(0, this.decimalLimit);
248
+ }
249
+ }
250
+
251
+ return filtered;
252
+ },
253
+
254
+ formatMobile(value) {
255
+ return value.replace(/\D/g, "");
256
+ },
257
+
258
+ formatAmountInput(value) {
259
+ let filteredValue = value;
260
+
261
+ if (this.allowNegative) {
262
+ filteredValue = value.replace(/[^\d.-]/g, "");
263
+ const hasNegative = filteredValue.startsWith("-");
264
+ filteredValue = filteredValue.replace(/-/g, "");
265
+ if (hasNegative) {
266
+ filteredValue = "-" + filteredValue;
267
+ }
268
+ // 修复:允许临时输入 '-' 或 '-.',不清空,以便用户继续输入小数部分
269
+ if (filteredValue === "-" || filteredValue === "-.") {
270
+ return filteredValue;
271
+ }
272
+ } else {
273
+ filteredValue = value.replace(/[^\d.]/g, "");
274
+ }
275
+
276
+ if (!this.allowDecimal) {
277
+ return filteredValue.replace(/\./g, "");
278
+ }
279
+
280
+ const parts = filteredValue.split(".");
281
+ if (parts.length > 2) {
282
+ filteredValue = parts[0] + "." + parts.slice(1).join("");
283
+ }
284
+
285
+ if (parts.length === 2 && parts[1].length > this.decimalLimit) {
286
+ filteredValue =
287
+ parts[0] + "." + parts[1].substring(0, this.decimalLimit);
288
+ }
289
+
290
+ return filteredValue;
291
+ },
292
+
293
+ formatAmount(value) {
294
+ if (value === undefined || value === null || value === "") return "";
295
+
296
+ const strValue = String(value);
297
+ const isNegative = strValue.startsWith("-");
298
+ let absValue = isNegative ? strValue.slice(1) : strValue;
299
+
300
+ // 修复:处理无效的中间状态,如 '-' 或 '-.'
301
+ if (absValue === "" || absValue === ".") {
302
+ return strValue;
303
+ }
304
+
305
+ const parts = absValue.split(".");
306
+ let integerPart = parts[0];
307
+ let decimalPart = parts.length > 1 ? parts[1] : "";
308
+
309
+ integerPart = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
310
+
311
+ let formatted = "";
312
+ if (decimalPart && this.allowDecimal) {
313
+ formatted = `${integerPart}.${decimalPart}`;
314
+ } else {
315
+ formatted = integerPart;
316
+ }
317
+
318
+ if (isNegative && formatted !== "") {
319
+ formatted = "-" + formatted;
320
+ }
321
+
322
+ return formatted;
323
+ },
324
+
325
+ validateInput(value, showError = false) {
326
+ if (!this.isTouched && !showError) return true;
327
+
328
+ let isValid = true;
329
+ let message = "";
330
+ const strValue = String(value || "");
331
+
332
+ if (this.number && strValue) {
333
+ let numberPattern;
334
+ if (this.allowNegative) {
335
+ numberPattern = /^-?\d*\.?\d*$/;
336
+ } else {
337
+ numberPattern = /^\d*\.?\d*$/;
338
+ }
339
+ if (!numberPattern.test(strValue)) {
340
+ isValid = false;
341
+ message = "请输入有效的数值";
342
+ }
343
+ }
344
+
345
+ if (this.mobile && strValue) {
346
+ if (!/^1[3-9]\d{9}$/.test(strValue)) {
347
+ isValid = false;
348
+ message = "请输入有效的手机号码";
349
+ }
350
+ }
351
+
352
+ if (this.email && strValue) {
353
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(strValue)) {
354
+ isValid = false;
355
+ message = "请输入有效的邮箱地址";
356
+ }
357
+ }
358
+
359
+ if (this.amount && strValue) {
360
+ const cleanValue = strValue.replace(/,/g, "");
361
+ let amountPattern;
362
+ if (this.allowNegative) {
363
+ // 更严格的金额正则:不允许单独的负号、小数点、负号+小数点
364
+ if (this.allowDecimal) {
365
+ amountPattern = /^-?(?:[1-9]\d*|0)(?:\.\d{0,2})?$|^-?0\.\d{0,2}$/;
366
+ } else {
367
+ amountPattern = /^-?(?:[1-9]\d*|0)$/;
368
+ }
369
+ // 临时允许用户输入过程中的不完整状态,但最终提交时需完整
370
+ // 这里先检查完整格式,如果是不完整状态(如 '-'、'-.'、'.')也认为无效
371
+ if (
372
+ cleanValue === "-" ||
373
+ cleanValue === "-." ||
374
+ cleanValue === "." ||
375
+ cleanValue === ""
376
+ ) {
377
+ isValid = false;
378
+ message = this.allowDecimal
379
+ ? "请输入有效的金额"
380
+ : "请输入有效的整数金额";
381
+ } else if (!amountPattern.test(cleanValue)) {
382
+ isValid = false;
383
+ message = this.allowDecimal
384
+ ? `请输入有效的金额(最多${this.decimalLimit}位小数)`
385
+ : "请输入有效的金额(整数)";
386
+ }
387
+ } else {
388
+ amountPattern = this.allowDecimal
389
+ ? /^(?:[1-9]\d*|0)(?:\.\d{0,2})?$|^0\.\d{0,2}$/
390
+ : /^(?:[1-9]\d*|0)$/;
391
+ if (!amountPattern.test(cleanValue)) {
392
+ isValid = false;
393
+ message = this.allowDecimal
394
+ ? `请输入有效的金额(最多${this.decimalLimit}位小数)`
395
+ : "请输入有效的金额(整数)";
396
+ }
397
+ }
398
+ if (!this.allowNegative && cleanValue.startsWith("-")) {
399
+ isValid = false;
400
+ message = "不允许输入负数";
401
+ }
402
+ }
403
+
404
+ if (this.computedMaxlength && strValue.length > this.computedMaxlength) {
405
+ isValid = false;
406
+ message = `输入内容不能超过${this.computedMaxlength}个字符`;
407
+ }
408
+
409
+ if (this.validator && typeof this.validator === "function") {
410
+ const customResult = this.validator(value);
411
+ if (customResult !== true) {
412
+ isValid = false;
413
+ message = customResult || "输入内容不符合要求";
414
+ }
415
+ }
416
+
417
+ this.hasError = !isValid && (this.isTouched || showError);
418
+ this.errorMessage = message;
419
+
420
+ return isValid;
421
+ },
422
+
423
+ validate() {
424
+ this.isTouched = true;
425
+ return this.validateInput(this.internalValue, true);
426
+ },
427
+
428
+ clearValidate() {
429
+ this.hasError = false;
430
+ this.errorMessage = "";
431
+ this.isTouched = false;
432
+ },
433
+
434
+ focus() {
435
+ this.$refs.inputRef?.focus();
436
+ },
437
+
438
+ blur() {
439
+ this.$refs.inputRef?.blur();
440
+ },
441
+ },
442
+ };
443
+ </script>
444
+
445
+ <style scoped>
446
+ .le-input-wrapper {
447
+ position: relative;
448
+ }
449
+
450
+ .le-input.is-error ::v-deep .el-input__inner {
451
+ border-color: #f56c6c;
452
+ }
453
+
454
+ .input-count {
455
+ font-size: 12px;
456
+ color: #909399;
457
+ }
458
+
459
+ .input-count.is-error {
460
+ color: #f56c6c;
461
+ }
462
+
463
+ .error-message {
464
+ color: #f56c6c;
465
+ font-size: 12px;
466
+ line-height: 1;
467
+ padding-top: 4px;
468
+ }
469
+ </style>
@@ -0,0 +1,78 @@
1
+ export default {
2
+ bind(el, binding, vnode) {
3
+ const dialogHeaderEl = el.querySelector(".el-dialog__header");
4
+ const dragDom = el.querySelector(".el-dialog");
5
+ dialogHeaderEl.style.cssText += ";cursor:move;";
6
+ dragDom.style.cssText += ";top:0px;";
7
+
8
+ // 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
9
+ const getStyle = (function () {
10
+ if (window.document.currentStyle) {
11
+ return (dom, attr) => dom.currentStyle[attr];
12
+ } else {
13
+ return (dom, attr) => getComputedStyle(dom, false)[attr];
14
+ }
15
+ })();
16
+
17
+ dialogHeaderEl.onmousedown = (e) => {
18
+ // 鼠标按下,计算当前元素距离可视区的距离
19
+ const disX = e.clientX - dialogHeaderEl.offsetLeft;
20
+ const disY = e.clientY - dialogHeaderEl.offsetTop;
21
+
22
+ const dragDomWidth = dragDom.offsetWidth;
23
+ // const dragDomHeight = dragDom.offsetHeight
24
+
25
+ const screenWidth = document.body.clientWidth;
26
+ const screenHeight = document.body.clientHeight;
27
+
28
+ const minDragDomLeft = dragDom.offsetLeft;
29
+ const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
30
+
31
+ const minDragDomTop = dragDom.offsetTop;
32
+ // const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomHeight
33
+ const maxDragDomTop = screenHeight - dragDom.offsetTop; // 不需要-dragDomHeight
34
+
35
+ // 获取到的值带px 正则匹配替换
36
+ let styL = getStyle(dragDom, "left");
37
+ let styT = getStyle(dragDom, "top");
38
+
39
+ if (styL.includes("%")) {
40
+ styL = +document.body.clientWidth * (+styL.replace(/\%/g, "") / 100);
41
+ styT = +document.body.clientHeight * (+styT.replace(/\%/g, "") / 100);
42
+ } else {
43
+ styL = +styL.replace(/\px/g, "");
44
+ styT = +styT.replace(/\px/g, "");
45
+ }
46
+
47
+ document.onmousemove = function (e) {
48
+ // 通过事件委托,计算移动的距离
49
+ let left = e.clientX - disX;
50
+ let top = e.clientY - disY;
51
+
52
+ // 边界处理
53
+ if (-left > minDragDomLeft) {
54
+ left = -minDragDomLeft;
55
+ } else if (left > maxDragDomLeft) {
56
+ left = maxDragDomLeft;
57
+ }
58
+
59
+ if (-top > minDragDomTop) {
60
+ top = -minDragDomTop;
61
+ } else if (top > maxDragDomTop) {
62
+ top = maxDragDomTop;
63
+ }
64
+
65
+ // 移动当前元素
66
+ dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
67
+
68
+ // emit onDrag event
69
+ vnode.child.$emit("dragDialog");
70
+ };
71
+
72
+ document.onmouseup = function (e) {
73
+ document.onmousemove = null;
74
+ document.onmouseup = null;
75
+ };
76
+ };
77
+ },
78
+ };
@@ -0,0 +1,3 @@
1
+ import Vue from "vue";
2
+
3
+ export const EventBus = new Vue();
@@ -0,0 +1,76 @@
1
+ import axios from "axios";
2
+ import router from "@/router";
3
+ import store from "@/store";
4
+ import { Message } from "element-ui";
5
+ import dayjs from "dayjs";
6
+
7
+ let calMethod = null;
8
+
9
+ function sign(param) {
10
+ if (!param) return "";
11
+ param = param.toString();
12
+ if (calMethod) {
13
+ return calMethod(param);
14
+ } else return "";
15
+ }
16
+
17
+ function setCalMethod(param) {
18
+ calMethod = param;
19
+ }
20
+
21
+ const msg = (info) =>
22
+ Message({
23
+ message: info,
24
+ type: "error",
25
+ duration: 2000,
26
+ });
27
+
28
+ const service = axios.create({
29
+ baseURL: process.env.VUE_APP_BASE_API,
30
+ timeout: 50000,
31
+ });
32
+
33
+ service.interceptors.request.use(
34
+ (config) => {
35
+ if (!config.headers["Content-Type"]) {
36
+ config.headers["Content-Type"] = "application/json;";
37
+ }
38
+
39
+ let userinfo = store.getters.userinfo;
40
+ if (userinfo != undefined && userinfo.token != undefined) {
41
+ config.headers["authentication"] = userinfo.token;
42
+ }
43
+ const timestamp = dayjs().unix();
44
+ config.headers["timestamp"] = timestamp;
45
+ config.headers["sign"] = sign(timestamp);
46
+ return config;
47
+ },
48
+ (error) => {
49
+ Promise.reject(error);
50
+ },
51
+ );
52
+
53
+ service.interceptors.response.use(
54
+ (response) => {
55
+ const code = response.data.code;
56
+ const info = response.data.info;
57
+ if (code == "801" || code == "802") {
58
+ router.push({ path: "/" });
59
+ } else if (code !== "10000" || code == "803") {
60
+ console.log("请求失败,code和info分别为", code, info);
61
+ msg(info);
62
+ // return Promise.reject(info);
63
+ } else {
64
+ return response;
65
+ }
66
+ },
67
+ (error) => {
68
+ console.log("请求失败:" + error);
69
+ return Promise.reject(error);
70
+ },
71
+ );
72
+
73
+ export default {
74
+ service,
75
+ setCalMethod,
76
+ };