fix: headless cause side effect

This commit is contained in:
Methapon2001 2024-08-08 17:09:36 +07:00
parent 71a7abc93b
commit e0d18401fb

View file

@ -1,5 +1,4 @@
<script lang="ts" setup>
import { ref } from 'vue';
import AppBox from './app/AppBox.vue';
defineExpose({ browse });
@ -37,7 +36,6 @@ const inputFile = (() => {
_element.addEventListener('change', change);
return _element;
})();
const headless = ref(false);
reader.addEventListener('load', () => {
if (typeof reader.result === 'string') imageUrl.value = reader.result;
@ -45,7 +43,6 @@ reader.addEventListener('load', () => {
function browse() {
inputFile?.click();
headless.value = true;
}
function change(e: Event) {
@ -55,10 +52,10 @@ function change(e: Event) {
if (_file) {
file.value = _file;
reader.readAsDataURL(_file);
if (headless) emit('save', _file, imageUrl.value);
if (!dialogState.value) {
emit('save', _file, imageUrl.value);
}
}
headless.value = false;
}
</script>
<template>