From a682aabb0b334e69dda278d1332a16f9eec55839 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Fri, 19 Apr 2024 17:21:20 +0800 Subject: [PATCH] fix: can not refresh value display after edit --- .../components/content_value/ContentEditor.vue | 15 +++++++++++++++ .../content_value/ContentValueString.vue | 3 +++ 2 files changed, 18 insertions(+) diff --git a/frontend/src/components/content_value/ContentEditor.vue b/frontend/src/components/content_value/ContentEditor.vue index 2d965fb..538e0e0 100644 --- a/frontend/src/components/content_value/ContentEditor.vue +++ b/frontend/src/components/content_value/ContentEditor.vue @@ -23,6 +23,10 @@ const props = defineProps({ type: Boolean, default: false, }, + resetKey: { + type: String, + default: '', + }, offsetKey: { type: String, default: '', @@ -144,6 +148,17 @@ watch( }, ) +watch( + () => props.resetKey, + async () => { + if (editorNode != null) { + editorNode.setValue(props.content) + await nextTick(() => emit('reset', props.content)) + updateScroll() + } + }, +) + watch( () => props.offsetKey, () => { diff --git a/frontend/src/components/content_value/ContentValueString.vue b/frontend/src/components/content_value/ContentValueString.vue index 60da97b..553b96c 100644 --- a/frontend/src/components/content_value/ContentValueString.vue +++ b/frontend/src/components/content_value/ContentValueString.vue @@ -71,6 +71,7 @@ const viewAs = reactive({ }) const editingContent = ref('') +const resetKey = ref('') const enableSave = computed(() => { return editingContent.value !== viewAs.value && !props.loading @@ -110,6 +111,7 @@ const onFormatChanged = async (decode = '', format = '') => { viewAs.decode = decode || retDecode viewAs.format = format || retFormat browserStore.setSelectedFormat(props.name, props.keyPath, props.db, viewAs.format, viewAs.decode) + resetKey.value = Date.now().toString() } finally { converting.value = false } @@ -207,6 +209,7 @@ defineExpose({ :language="viewLanguage" :loading="props.loading" :offset-key="props.keyPath" + :reset-key="resetKey" class="flex-item-expand" keep-offset style="height: 100%"