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_RAW = "Raw"
const FORMAT_JSON = "JSON" const FORMAT_JSON = "JSON"
const FORMAT_YAML = "YAML"
const FORMAT_XML = "XML"
const FORMAT_HEX = "Hex" const FORMAT_HEX = "Hex"
const FORMAT_BINARY = "Binary" 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) { func viewAs(str, formatType string) (value, resultFormat string) {
if len(formatType) > 0 { if len(formatType) > 0 {
switch formatType { switch formatType {
case types.FORMAT_RAW: case types.FORMAT_RAW, types.FORMAT_YAML, types.FORMAT_XML:
value = str value = str
resultFormat = formatType resultFormat = formatType
return return

View File

@ -97,6 +97,10 @@ const viewLanguage = computed(() => {
switch (viewAs.format) { switch (viewAs.format) {
case formatTypes.JSON: case formatTypes.JSON:
return 'json' return 'json'
case formatTypes.YAML:
return 'yaml'
case formatTypes.XML:
return 'xml'
default: default:
return 'plaintext' 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) => { const onInput = (content) => {
editingContent.value = content editingContent.value = content
} }

View File

@ -53,6 +53,10 @@ const viewLanguage = computed(() => {
switch (viewAs.format) { switch (viewAs.format) {
case formatTypes.JSON: case formatTypes.JSON:
return 'json' return 'json'
case formatTypes.YAML:
return 'yaml'
case formatTypes.XML:
return 'xml'
default: default:
return 'plaintext' return 'plaintext'
} }

View File

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