Manage display of book covers
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { postImage } from './api.js'
|
||||
|
||||
const emit = defineEmits(['OnImageUpload'])
|
||||
const props = defineProps({
|
||||
name: String
|
||||
});
|
||||
@@ -12,10 +13,15 @@
|
||||
function onFileChanged(e) {
|
||||
postImage(e.target.files[0])
|
||||
.then((res) => res.json())
|
||||
.then((json) => (imagePath.value = json["filepath"]))
|
||||
.then((json) => onJsonResult(json))
|
||||
.catch((err) => (error.value = err["error"]));
|
||||
}
|
||||
|
||||
function onJsonResult(json) {
|
||||
imagePath.value = json["filepath"];
|
||||
emit('OnImageUpload', json["fileId"])
|
||||
}
|
||||
|
||||
function unsetImage() {
|
||||
imagePath.value = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user