feat: add format type 'YAML' and 'XML' #110

This commit is contained in:
Lykin 2023-12-29 00:38:09 +08:00
parent 4c9d75303c
commit 4dc8839a51
5 changed files with 13 additions and 8 deletions

View File

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

View File

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

View File

@ -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
}

View File

@ -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'
}

View File

@ -5,8 +5,8 @@
export const formatTypes = {
RAW: 'Raw',
JSON: 'JSON',
// XML: 'XML',
// YML: 'YML',
YAML: 'YAML',
XML: 'XML',
HEX: 'Hex',
BINARY: 'Binary',
}