master
git 8 years ago
parent f65a220435
commit 657fd2fb4e

@ -109,7 +109,6 @@ export default {
let cropper = new Cropper(this.$refs.editImage, {
aspectRatio: 1 / 1,
viewMode: 1,
minContainerHeight: 300,
})
this.cropper = cropper
})
@ -123,15 +122,20 @@ export default {
},
methods: {
async editSave() {
editSave() {
this.edit = false
let blob = await new Promise((resolve, reject) => {
this.cropper.getCroppedCanvas().toBlob(function (value) {
resolve(value)
})
})
let file = new File([blob], this.files[0].name, { type: blob.type })
this.$refs.upload.update(this.files[0].id, {
let oldFile = this.files[0]
let binStr = atob(this.cropper.getCroppedCanvas().toDataURL(oldFile.type).split(',')[1])
let arr = new Uint8Array(binStr.length)
for (let i = 0; i < binStr.length; i++) {
arr[i] = binStr.charCodeAt(i)
}
let file = new File([arr], oldFile.name, { type: oldFile.type })
this.$refs.upload.update(oldFile.id, {
file,
type: file.type,
size: file.size,

@ -541,7 +541,7 @@ export default {
this.$refs.upload.update(file, { error: 'edit' })
},
async onEditorFile() {
onEditorFile() {
if (!this.$refs.upload.features.html5) {
this.alert('Your browser does not support')
this.editFile.show = false
@ -552,14 +552,13 @@ export default {
name: this.editFile.name,
}
if (this.editFile.cropper) {
let blob = await new Promise((resolve, reject) => {
this.editFile.cropper.getCroppedCanvas().toBlob(function (value) {
resolve(value)
})
})
data.file = new File([blob], data.name, { type: blob.type })
data.type = blob.type
data.size = blob.size
let binStr = atob(this.editFile.cropper.getCroppedCanvas().toDataURL(this.editFile.type).split(',')[1])
let arr = new Uint8Array(binStr.length)
for (let i = 0; i < binStr.length; i++) {
arr[i] = binStr.charCodeAt(i)
}
data.file = new File([arr], data.name, { type: this.editFile.type })
data.size = data.file.size
}
this.$refs.upload.update(this.editFile.id, data)
this.editFile.error = ''

Loading…
Cancel
Save