refactor: reset on leave

This commit is contained in:
Methapon2001 2023-12-07 09:42:49 +07:00
parent 4f9ca4bd17
commit 458c1663bf
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 7 additions and 1 deletions

View file

@ -38,6 +38,10 @@ const emit = defineEmits([
'submit',
])
defineExpose({
reset,
})
function keydown(e: KeyboardEvent) {
if (e.key === 'Escape' && props.open === true) {
emit('update:open', false)
@ -63,7 +67,6 @@ function submit() {
keyword: props.keyword,
category: props.category,
})
emit('update:open', !open), reset()
}
const createKeyword = ((val, done) => {

View file

@ -64,6 +64,7 @@ const fileFormData = ref<{
const fileFormType = ref<'edit' | 'create'>('create')
const fileFormError = ref<{ fileExist?: boolean; fileName2Long?: boolean }>({})
const fileExistNotification = ref<boolean>(false)
const fileFormComponent = ref<InstanceType<typeof FileForm>>()
function triggerFolderDelete(pathname: string) {
deleteFormType.value = 'deleteFolder'
@ -176,6 +177,7 @@ async function submitFileForm(
fileFormData.value = {}
fileFormState.value = false
currentParam.value = undefined
fileFormComponent.value?.reset()
}
</script>
@ -379,6 +381,7 @@ async function submitFileForm(
</div>
<file-form
ref="fileFormComponent"
:mode="fileFormType"
:error="fileFormError"
v-model:open="fileFormState"