From 4dc8839a515c5990f92bc3c47c2c7dc69b871f59 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Fri, 29 Dec 2023 00:38:09 +0800 Subject: [PATCH] feat: add format type 'YAML' and 'XML' #110 --- backend/types/view_type.go | 2 ++ backend/utils/string/convert.go | 2 +- .../src/components/content_value/ContentEntryEditor.vue | 9 ++++----- .../src/components/content_value/ContentValueString.vue | 4 ++++ frontend/src/consts/value_view_type.js | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/backend/types/view_type.go b/backend/types/view_type.go index f4fe4ad..9c706f7 100644 --- a/backend/types/view_type.go +++ b/backend/types/view_type.go @@ -2,6 +2,8 @@ package types const FORMAT_RAW = "Raw" const FORMAT_JSON = "JSON" +const FORMAT_YAML = "YAML" +const FORMAT_XML = "XML" const FORMAT_HEX = "Hex" const FORMAT_BINARY = "Binary" diff --git a/backend/utils/string/convert.go b/backend/utils/string/convert.go index 437f913..37d4008 100644 --- a/backend/utils/string/convert.go +++ b/backend/utils/string/convert.go @@ -148,7 +148,7 @@ func autoDecode(str string) (value, resultDecode string) { func viewAs(str, formatType string) (value, resultFormat string) { if len(formatType) > 0 { switch formatType { - case types.FORMAT_RAW: + case types.FORMAT_RAW, types.FORMAT_YAML, types.FORMAT_XML: value = str resultFormat = formatType return diff --git a/frontend/src/components/content_value/ContentEntryEditor.vue b/frontend/src/components/content_value/ContentEntryEditor.vue index 37bf770..8b684f6 100644 --- a/frontend/src/components/content_value/ContentEntryEditor.vue +++ b/frontend/src/components/content_value/ContentEntryEditor.vue @@ -97,6 +97,10 @@ const viewLanguage = computed(() => { switch (viewAs.format) { case formatTypes.JSON: return 'json' + case formatTypes.YAML: + return 'yaml' + case formatTypes.XML: + return 'xml' default: return 'plaintext' } @@ -129,11 +133,6 @@ const onFormatChanged = async (decode = null, format = null) => { } } -const onUpdateValue = (value) => { - // emit('update:value', value) - viewAs.value = value -} - const onInput = (content) => { editingContent.value = content } diff --git a/frontend/src/components/content_value/ContentValueString.vue b/frontend/src/components/content_value/ContentValueString.vue index 64ba1da..77868da 100644 --- a/frontend/src/components/content_value/ContentValueString.vue +++ b/frontend/src/components/content_value/ContentValueString.vue @@ -53,6 +53,10 @@ const viewLanguage = computed(() => { switch (viewAs.format) { case formatTypes.JSON: return 'json' + case formatTypes.YAML: + return 'yaml' + case formatTypes.XML: + return 'xml' default: return 'plaintext' } diff --git a/frontend/src/consts/value_view_type.js b/frontend/src/consts/value_view_type.js index fe60a91..cdd69d0 100644 --- a/frontend/src/consts/value_view_type.js +++ b/frontend/src/consts/value_view_type.js @@ -5,8 +5,8 @@ export const formatTypes = { RAW: 'Raw', JSON: 'JSON', - // XML: 'XML', - // YML: 'YML', + YAML: 'YAML', + XML: 'XML', HEX: 'Hex', BINARY: 'Binary', }