fix: headless cause side effect
This commit is contained in:
parent
71a7abc93b
commit
e0d18401fb
1 changed files with 3 additions and 6 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
|
||||||
import AppBox from './app/AppBox.vue';
|
import AppBox from './app/AppBox.vue';
|
||||||
|
|
||||||
defineExpose({ browse });
|
defineExpose({ browse });
|
||||||
|
|
@ -37,7 +36,6 @@ const inputFile = (() => {
|
||||||
_element.addEventListener('change', change);
|
_element.addEventListener('change', change);
|
||||||
return _element;
|
return _element;
|
||||||
})();
|
})();
|
||||||
const headless = ref(false);
|
|
||||||
|
|
||||||
reader.addEventListener('load', () => {
|
reader.addEventListener('load', () => {
|
||||||
if (typeof reader.result === 'string') imageUrl.value = reader.result;
|
if (typeof reader.result === 'string') imageUrl.value = reader.result;
|
||||||
|
|
@ -45,7 +43,6 @@ reader.addEventListener('load', () => {
|
||||||
|
|
||||||
function browse() {
|
function browse() {
|
||||||
inputFile?.click();
|
inputFile?.click();
|
||||||
headless.value = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function change(e: Event) {
|
function change(e: Event) {
|
||||||
|
|
@ -55,10 +52,10 @@ function change(e: Event) {
|
||||||
if (_file) {
|
if (_file) {
|
||||||
file.value = _file;
|
file.value = _file;
|
||||||
reader.readAsDataURL(_file);
|
reader.readAsDataURL(_file);
|
||||||
if (headless) emit('save', _file, imageUrl.value);
|
if (!dialogState.value) {
|
||||||
|
emit('save', _file, imageUrl.value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
headless.value = false;
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue