bri-components 1.6.5 → 1.6.6

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": "bri-components",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "author": "dengshanghui",
5
5
  "description": "a component lib for vue project",
6
6
  "main": "src/index.js",
@@ -149,8 +149,7 @@
149
149
  _canAction: false, // 是否使用操作图标
150
150
  _cropper: false, // 使用裁剪
151
151
  _useBorderRadius: false, // 用圆角
152
-
153
- _requestOssType: "", //
152
+ _imageResizeConfig: undefined,
154
153
  _aliOssType: "binaryMultipartUpload", // 阿里云上传方式
155
154
 
156
155
  ...this.propsObj
@@ -184,9 +183,6 @@
184
183
  h: 100
185
184
  };
186
185
  },
187
- requestOssType () {
188
- return this.selfPropsObj._requestOssType;
189
- },
190
186
 
191
187
  modalPropsObj () {
192
188
  return {
@@ -207,6 +203,29 @@
207
203
  },
208
204
  created () {},
209
205
  methods: {
206
+ // 点击文件预览
207
+ handlePreview (file) {
208
+ let viewerImage = this.$refs.viewerImage;
209
+ let viewer = new Viewer(viewerImage, {
210
+ url: "data-original",
211
+ hidden: function () {
212
+ viewer.destroy();
213
+ },
214
+ loop: false,
215
+ zIndex: 2147483647
216
+ });
217
+ viewer.show();
218
+ },
219
+ // 点击文件删除 - fileList服务器的数据列表
220
+ handleRemove (file) {
221
+ this.uploadType = "file"; // 删除后可以重新上传
222
+ this.curVal = "";
223
+ this.change(this.value);
224
+ },
225
+ change (...params) {
226
+ this.$emit("change", ...params);
227
+ },
228
+
210
229
  handleChange (event) {
211
230
  if (event.target.files.length) {
212
231
  const file = event.target.files[0];
@@ -242,11 +261,18 @@
242
261
  },
243
262
  // 提交裁剪后的图片
244
263
  submitCropImage () {
245
- const cropImg = this.$refs.cropperDom.getCroppedCanvas().toDataURL(); // base64格式
246
- this.dealPostImage(cropImg);
264
+ this.dealPostImage(this.$refs.cropperDom.getCroppedCanvas().toDataURL()); // base64格式
247
265
 
248
266
  this.closeAvatarModal();
249
267
  },
268
+ // 处理图片的提交
269
+ dealPostImage (fileData) {
270
+ this.handlePost((ossType) => {
271
+ return ossType === "local"
272
+ ? this.dataURLtoFile(fileData, "") // 本地上传,将图片Base64转成文件
273
+ : Buffer.from(fileData.split(",")[1], "base64"); // 阿里上传,object类型
274
+ });
275
+ },
250
276
  successCb (response, res) {
251
277
  this.curVal = res.data.downloadUrl;
252
278
  this.$emit("change", res);
@@ -260,26 +286,6 @@
260
286
  // get image data for post processing, e.g. upload or setting image src
261
287
  this.cropImg = this.$refs.cropperDom.getCroppedCanvas().toDataURL(); // base64格式
262
288
  },
263
- // 处理图片的提交
264
- dealPostImage (data) {
265
- // 本地上传
266
- if (this.requestOssType === "local") {
267
- const imgFile = this.dataURLtoFile(data, ""); // 将图片Base64转成文件
268
- this.handlePost(imgFile); // object类型
269
- // {
270
- // lastModified: 1752065308269
271
- // name: ".png"
272
- // size: 528557
273
- // type: "image/png"
274
- // webkitRelativePath: ""
275
- // }
276
- }
277
- // 阿里上传用
278
- else {
279
- const dataBuffer = Buffer.from(data.split(",")[1], "base64");
280
- this.handlePost(dataBuffer); // object类型
281
- }
282
- },
283
289
  // 将图片Base64转成文件
284
290
  dataURLtoFile (dataurl, filename) {
285
291
  // 获取文件扩展名称
@@ -292,30 +298,15 @@
292
298
  while (n--) {
293
299
  u8arr[n] = bstr.charCodeAt(n);
294
300
  }
295
- return new File([u8arr], `${filename}.${extension}`, { type: mime });
296
- },
297
301
 
298
- // 点击文件预览
299
- handlePreview (file) {
300
- let viewerImage = this.$refs.viewerImage;
301
- let viewer = new Viewer(viewerImage, {
302
- url: "data-original",
303
- hidden: function () {
304
- viewer.destroy();
305
- },
306
- loop: false,
307
- zIndex: 2147483647
308
- });
309
- viewer.show();
310
- },
311
- // 点击文件删除 - fileList服务器的数据列表
312
- handleRemove (file) {
313
- this.uploadType = "file"; // 删除后可以重新上传
314
- this.curVal = "";
315
- this.change(this.value);
316
- },
317
- change (...params) {
318
- this.$emit("change", ...params);
302
+ return new File([u8arr], `${filename}.${extension}`, { type: mime });
303
+ // {
304
+ // lastModified: 1752065308269
305
+ // name: ".png"
306
+ // size: 528557
307
+ // type: "image/png"
308
+ // webkitRelativePath: ""
309
+ // }
319
310
  },
320
311
 
321
312
  // 打开修改头像
@@ -344,9 +335,9 @@
344
335
  width: 100%;
345
336
 
346
337
  &-img {
338
+ float: left;
347
339
  width: 100px;
348
340
  height: 100px;
349
- float: left;
350
341
  background-repeat: no-repeat;
351
342
  background-position: center;
352
343
  background-size: contain;
@@ -357,7 +348,9 @@
357
348
  overflow: hidden;
358
349
 
359
350
  &-action {
351
+ font-weight: 600;
360
352
  color: @themeColor;
353
+ // color: #ffffff;
361
354
  cursor: pointer;
362
355
  }
363
356
 
@@ -41,6 +41,11 @@ export default {
41
41
  callback: res => {
42
42
  this.uploadType = "file";
43
43
 
44
+ // BriUploadImage使用时,file参数是个函数
45
+ if (typeof file === "function") {
46
+ file = file(res.ossType);
47
+ }
48
+
44
49
  if (res.ossType === "ali-oss") {
45
50
  // 上传到阿里云res
46
51
  if (this.aliOssType === "binaryMultipartUpload") {