@v2coding/ui 0.1.21 → 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 +43 -3
- package/dist/v2coding-ui.min.js +2 -2
- package/dist/v2coding-ui.ssr.js +73 -3
- 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
|
};
|