fix: can not refresh value display after edit

This commit is contained in:
Lykin 2024-04-19 17:21:20 +08:00
parent 971c89a5cf
commit a682aabb0b
2 changed files with 18 additions and 0 deletions

View File

@ -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,
() => {

View File

@ -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%"