@v2coding/ui 0.1.20 → 0.1.22
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/dist/v2coding-ui.esm.js +49 -35
- package/dist/v2coding-ui.min.js +2 -2
- package/dist/v2coding-ui.ssr.js +80 -42
- package/package.json +1 -1
package/dist/v2coding-ui.esm.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { fromJS, is } from 'immutable';
|
|
2
2
|
import merge from 'lodash.merge';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
+
import to from 'await-to-js';
|
|
5
|
+
import { Message, TableColumn as TableColumn$1 } from 'element-ui';
|
|
4
6
|
import Vuex, { mapState } from 'vuex';
|
|
5
7
|
import VuexPersistence from 'vuex-persist';
|
|
6
8
|
import VueRouter from 'vue-router';
|
|
7
|
-
import to from 'await-to-js';
|
|
8
9
|
import throttle from 'lodash.throttle';
|
|
9
10
|
import PinyinMatch from 'pinyin-match';
|
|
10
11
|
import moment from 'moment';
|
|
11
12
|
import debounce from 'lodash.debounce';
|
|
12
|
-
import { Message, TableColumn as TableColumn$1 } from 'element-ui';
|
|
13
13
|
import { Quill, quillEditor } from 'vue-quill-editor';
|
|
14
14
|
import 'quill/dist/quill.core.css';
|
|
15
15
|
import 'quill/dist/quill.snow.css';
|
|
@@ -162,15 +162,55 @@ const downloadFile = (data, filename, mime) => {
|
|
|
162
162
|
}
|
|
163
163
|
};
|
|
164
164
|
|
|
165
|
+
const blobToObj = data => {
|
|
166
|
+
return new Promise((resolve, reject) => {
|
|
167
|
+
let reader = new FileReader();
|
|
168
|
+
reader.readAsText(data, 'utf-8');
|
|
169
|
+
|
|
170
|
+
reader.onload = function () {
|
|
171
|
+
try {
|
|
172
|
+
resolve(JSON.parse(reader.result));
|
|
173
|
+
} catch (error) {
|
|
174
|
+
reject(error);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
165
180
|
const initDownload = server => {
|
|
166
181
|
return (url, filename, config) => {
|
|
167
182
|
const _config = Object.assign({
|
|
168
183
|
url,
|
|
169
|
-
method: 'get'
|
|
184
|
+
method: 'get',
|
|
185
|
+
autoMessage: false
|
|
170
186
|
}, config || {});
|
|
171
187
|
|
|
172
188
|
return server(_config).then(res => {
|
|
173
189
|
downloadFile(res, filename);
|
|
190
|
+
}).catch(async error => {
|
|
191
|
+
var _response$data;
|
|
192
|
+
|
|
193
|
+
const {
|
|
194
|
+
response
|
|
195
|
+
} = error || {};
|
|
196
|
+
|
|
197
|
+
if ((response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.type) === 'application/json') {
|
|
198
|
+
const [, result] = await to(blobToObj(response.data));
|
|
199
|
+
|
|
200
|
+
if (result) {
|
|
201
|
+
Message.error({
|
|
202
|
+
dangerouslyUseHTMLString: true,
|
|
203
|
+
message: result.message || '网络出现故障,请稍后再试'
|
|
204
|
+
});
|
|
205
|
+
return Promise.reject(result);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
Message.error({
|
|
210
|
+
dangerouslyUseHTMLString: true,
|
|
211
|
+
message: '网络出现故障,请稍后再试'
|
|
212
|
+
});
|
|
213
|
+
return Promise.reject(error);
|
|
174
214
|
});
|
|
175
215
|
};
|
|
176
216
|
};
|
|
@@ -535,14 +575,9 @@ const getSetting = () => {
|
|
|
535
575
|
return Objects.merge({}, setting);
|
|
536
576
|
};
|
|
537
577
|
|
|
538
|
-
const isFormErrorResponse = result => {
|
|
539
|
-
return result.code === 'FAILURE_PARAM_ERROR';
|
|
540
|
-
};
|
|
541
578
|
/**
|
|
542
579
|
* 自动解析 get/post 请求并提示信息(解析返回信息中的 message/data 字段)
|
|
543
580
|
*/
|
|
544
|
-
|
|
545
|
-
|
|
546
581
|
var AxiosWithMessage = {
|
|
547
582
|
methods: {
|
|
548
583
|
getWithMessage() {
|
|
@@ -553,22 +588,15 @@ var AxiosWithMessage = {
|
|
|
553
588
|
|
|
554
589
|
const {
|
|
555
590
|
success = false,
|
|
556
|
-
data,
|
|
557
591
|
message
|
|
558
592
|
} = result;
|
|
559
593
|
|
|
560
594
|
if (success) {
|
|
561
595
|
message && this.$nextTick(() => this.$message({
|
|
562
596
|
message,
|
|
563
|
-
type:
|
|
564
|
-
}));
|
|
565
|
-
} else if (isFormErrorResponse(result)) {
|
|
566
|
-
const err = Object.values(data);
|
|
567
|
-
err.length && this.$nextTick(() => this.$message.error({
|
|
568
|
-
dangerouslyUseHTMLString: true,
|
|
569
|
-
message: err.join(';<br/>')
|
|
597
|
+
type: 'success'
|
|
570
598
|
}));
|
|
571
|
-
}
|
|
599
|
+
}
|
|
572
600
|
|
|
573
601
|
return result;
|
|
574
602
|
});
|
|
@@ -582,22 +610,15 @@ var AxiosWithMessage = {
|
|
|
582
610
|
|
|
583
611
|
const {
|
|
584
612
|
success = false,
|
|
585
|
-
data,
|
|
586
613
|
message = `操作${success ? '成功' : '失败'}`
|
|
587
614
|
} = result;
|
|
588
615
|
|
|
589
616
|
if (success) {
|
|
590
617
|
message && this.$nextTick(() => this.$message({
|
|
591
618
|
message,
|
|
592
|
-
type:
|
|
593
|
-
}));
|
|
594
|
-
} else if (isFormErrorResponse(result)) {
|
|
595
|
-
const err = Object.values(data);
|
|
596
|
-
err.length && this.$nextTick(() => this.$message.error({
|
|
597
|
-
dangerouslyUseHTMLString: true,
|
|
598
|
-
message: err.join(';<br/>')
|
|
619
|
+
type: 'success'
|
|
599
620
|
}));
|
|
600
|
-
}
|
|
621
|
+
}
|
|
601
622
|
|
|
602
623
|
return result;
|
|
603
624
|
});
|
|
@@ -611,22 +632,15 @@ var AxiosWithMessage = {
|
|
|
611
632
|
|
|
612
633
|
const {
|
|
613
634
|
success = false,
|
|
614
|
-
data,
|
|
615
635
|
message
|
|
616
636
|
} = result;
|
|
617
637
|
|
|
618
638
|
if (success) {
|
|
619
639
|
message && this.$nextTick(() => this.$message({
|
|
620
640
|
message,
|
|
621
|
-
type:
|
|
622
|
-
}));
|
|
623
|
-
} else if (isFormErrorResponse(result)) {
|
|
624
|
-
const err = Object.values(data);
|
|
625
|
-
err.length && this.$nextTick(() => this.$message.error({
|
|
626
|
-
dangerouslyUseHTMLString: true,
|
|
627
|
-
message: err.join(';<br/>')
|
|
641
|
+
type: 'success'
|
|
628
642
|
}));
|
|
629
|
-
}
|
|
643
|
+
}
|
|
630
644
|
|
|
631
645
|
return result;
|
|
632
646
|
});
|