|
|
|
|
@ -10,6 +10,7 @@ |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import {api} from "../../js/modules/api"; |
|
|
|
|
import downscale from 'downscale'; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
name: "lil-image", |
|
|
|
|
@ -25,16 +26,18 @@ |
|
|
|
|
let file = event.target.files[0]; |
|
|
|
|
let reader = new FileReader(); |
|
|
|
|
reader.onload = () => { |
|
|
|
|
api.uploadImage(reader.result, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
this.loading = false; |
|
|
|
|
this.$emit('update:imageId', response.data.id); |
|
|
|
|
this.$emit('update:imageUrl', response.data.image); |
|
|
|
|
}) |
|
|
|
|
.catch((error) => { |
|
|
|
|
this.loading = false; |
|
|
|
|
console.log('error', error); |
|
|
|
|
}); |
|
|
|
|
downscale(reader.result, 2000, 2000).then((dataURL) => { |
|
|
|
|
api.uploadImage(dataURL, this.accessToken) |
|
|
|
|
.then((response) => { |
|
|
|
|
this.loading = false; |
|
|
|
|
this.$emit('update:imageId', response.data.id); |
|
|
|
|
this.$emit('update:imageUrl', response.data.image); |
|
|
|
|
}) |
|
|
|
|
.catch((error) => { |
|
|
|
|
this.loading = false; |
|
|
|
|
console.log('error', error); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
if (file) { |
|
|
|
|
reader.readAsDataURL(file); |
|
|
|
|
@ -51,4 +54,4 @@ |
|
|
|
|
display: block; |
|
|
|
|
object-fit: contain; |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|
</style> |
|
|
|
|
|