refactor: edit addEventListener No waiting url

This commit is contained in:
Net 2024-09-11 17:59:18 +07:00
parent 685ad0cc54
commit 1c467bff35

View file

@ -41,7 +41,10 @@ const inputFile = (() => {
})();
reader.addEventListener('load', () => {
if (typeof reader.result === 'string') imageUrl.value = reader.result;
if (typeof reader.result === 'string') {
imageUrl.value = reader.result;
if (!dialogState.value) emit('save', file.value, imageUrl.value);
}
});
function browse() {
@ -51,13 +54,9 @@ function browse() {
function change(e: Event) {
const _element = e.target as HTMLInputElement | null;
const _file = _element?.files?.[0];
if (_file) {
file.value = _file;
reader.readAsDataURL(_file);
if (!dialogState.value) {
emit('save', _file, imageUrl.value);
}
}
}