From 200b12cd5128bc2cf2882a4b3fd2860db6ddabdc Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Mon, 13 Nov 2023 22:41:33 +0800 Subject: [PATCH] refactor: rename "viewas" to "format", rename "plain text" to "raw" --- backend/services/browser_service.go | 2 +- backend/types/view_type.go | 8 +++---- backend/utils/string/convert.go | 22 +++++++++---------- .../src/components/content/ContentPane.vue | 2 +- .../content_value/ContentEntryEditor.vue | 2 +- .../content_value/ContentValueHash.vue | 6 ++--- .../content_value/ContentValueList.vue | 2 +- .../content_value/ContentValueSet.vue | 2 +- .../content_value/ContentValueStream.vue | 2 +- .../content_value/ContentValueString.vue | 2 +- .../content_value/ContentValueWrapper.vue | 2 +- .../content_value/ContentValueZSet.vue | 3 +++ .../content_value/FormatSelector.vue | 6 ++--- frontend/src/consts/value_view_type.js | 2 +- frontend/src/stores/browser.js | 13 ++--------- 15 files changed, 35 insertions(+), 41 deletions(-) diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index 103e3a3..a4951a9 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -902,7 +902,7 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp param.Decode = types.DECODE_NONE } if len(param.Format) <= 0 { - param.Format = types.VIEWAS_PLAIN_TEXT + param.Format = types.FORMAT_RAW } switch strings.ToLower(param.KeyType) { case "string": diff --git a/backend/types/view_type.go b/backend/types/view_type.go index d62d264..f4fe4ad 100644 --- a/backend/types/view_type.go +++ b/backend/types/view_type.go @@ -1,9 +1,9 @@ package types -const VIEWAS_PLAIN_TEXT = "Plain Text" -const VIEWAS_JSON = "JSON" -const VIEWAS_HEX = "Hex" -const VIEWAS_BINARY = "Binary" +const FORMAT_RAW = "Raw" +const FORMAT_JSON = "JSON" +const FORMAT_HEX = "Hex" +const FORMAT_BINARY = "Binary" const DECODE_NONE = "None" const DECODE_BASE64 = "Base64" diff --git a/backend/utils/string/convert.go b/backend/utils/string/convert.go index 62a4602..67fa749 100644 --- a/backend/utils/string/convert.go +++ b/backend/utils/string/convert.go @@ -25,7 +25,7 @@ func ConvertTo(str, decodeType, formatType string) (value, resultDecode, resultF if len(str) <= 0 { // empty content if len(formatType) <= 0 { - resultFormat = types.VIEWAS_PLAIN_TEXT + resultFormat = types.FORMAT_RAW } else { resultFormat = formatType } @@ -142,12 +142,12 @@ func autoDecode(str string) (value, resultDecode string) { func viewAs(str, formatType string) (value, resultFormat string) { if len(formatType) > 0 { switch formatType { - case types.VIEWAS_PLAIN_TEXT: + case types.FORMAT_RAW: value = str resultFormat = formatType return - case types.VIEWAS_JSON: + case types.FORMAT_JSON: if jsonStr, ok := decodeJson(str); ok { value = jsonStr } else { @@ -156,7 +156,7 @@ func viewAs(str, formatType string) (value, resultFormat string) { resultFormat = formatType return - case types.VIEWAS_HEX: + case types.FORMAT_HEX: if hexStr, ok := decodeToHex(str); ok { value = hexStr } else { @@ -165,7 +165,7 @@ func viewAs(str, formatType string) (value, resultFormat string) { resultFormat = formatType return - case types.VIEWAS_BINARY: + case types.FORMAT_BINARY: if binStr, ok := decodeBinary(str); ok { value = binStr } else { @@ -185,20 +185,20 @@ func autoViewAs(str string) (value, resultFormat string) { if len(str) > 0 { var ok bool if value, ok = decodeJson(str); ok { - resultFormat = types.VIEWAS_JSON + resultFormat = types.FORMAT_JSON return } if containsBinary(str) { if value, ok = decodeToHex(str); ok { - resultFormat = types.VIEWAS_HEX + resultFormat = types.FORMAT_HEX return } } } value = str - resultFormat = types.VIEWAS_PLAIN_TEXT + resultFormat = types.FORMAT_RAW return } @@ -284,7 +284,7 @@ func decodeBrotli(str string) (string, bool) { func SaveAs(str, viewType, decodeType string) (value string, err error) { value = str switch viewType { - case types.VIEWAS_JSON: + case types.FORMAT_JSON: if jsonStr, ok := encodeJson(str); ok { value = jsonStr } else { @@ -292,7 +292,7 @@ func SaveAs(str, viewType, decodeType string) (value string, err error) { return } - case types.VIEWAS_HEX: + case types.FORMAT_HEX: if hexStr, ok := encodeHex(str); ok { value = hexStr } else { @@ -300,7 +300,7 @@ func SaveAs(str, viewType, decodeType string) (value string, err error) { return } - case types.VIEWAS_BINARY: + case types.FORMAT_BINARY: if binStr, ok := encodeBinary(str); ok { value = binStr } else { diff --git a/frontend/src/components/content/ContentPane.vue b/frontend/src/components/content/ContentPane.vue index 9440ebf..4ce294c 100644 --- a/frontend/src/components/content/ContentPane.vue +++ b/frontend/src/components/content/ContentPane.vue @@ -56,7 +56,7 @@ const tabContent = computed(() => { size: tab.size || 0, length: tab.length || 0, decode: tab.decode || decodeTypes.NONE, - format: tab.format || formatTypes.PLAIN_TEXT, + format: tab.format || formatTypes.RAW, end: tab.end === true, loading: tab.loading === true, } diff --git a/frontend/src/components/content_value/ContentEntryEditor.vue b/frontend/src/components/content_value/ContentEntryEditor.vue index bcb5b7e..a026505 100644 --- a/frontend/src/components/content_value/ContentEntryEditor.vue +++ b/frontend/src/components/content_value/ContentEntryEditor.vue @@ -51,7 +51,7 @@ const loading = ref(false) const viewAs = reactive({ field: '', value: '', - format: formatTypes.PLAIN_TEXT, + format: formatTypes.RAW, decode: decodeTypes.NONE, }) const displayValue = computed(() => { diff --git a/frontend/src/components/content_value/ContentValueHash.vue b/frontend/src/components/content_value/ContentValueHash.vue index c48e9b9..2b711d3 100644 --- a/frontend/src/components/content_value/ContentValueHash.vue +++ b/frontend/src/components/content_value/ContentValueHash.vue @@ -42,7 +42,7 @@ const props = defineProps({ length: Number, format: { type: String, - default: formatTypes.PLAIN_TEXT, + default: formatTypes.RAW, }, decode: { type: String, @@ -81,7 +81,7 @@ const currentEditRow = reactive({ no: 0, key: '', value: null, - format: formatTypes.PLAIN_TEXT, + format: formatTypes.RAW, decode: decodeTypes.NONE, }) @@ -171,7 +171,7 @@ const resetEdit = () => { currentEditRow.no = 0 currentEditRow.key = '' currentEditRow.value = null - currentEditRow.format = formatTypes.PLAIN_TEXT + currentEditRow.format = formatTypes.RAW currentEditRow.decode = decodeTypes.NONE } diff --git a/frontend/src/components/content_value/ContentValueList.vue b/frontend/src/components/content_value/ContentValueList.vue index 97d1247..4b886ff 100644 --- a/frontend/src/components/content_value/ContentValueList.vue +++ b/frontend/src/components/content_value/ContentValueList.vue @@ -35,7 +35,7 @@ const props = defineProps({ length: Number, viewAs: { type: String, - default: formatTypes.PLAIN_TEXT, + default: formatTypes.RAW, }, decode: { type: String, diff --git a/frontend/src/components/content_value/ContentValueSet.vue b/frontend/src/components/content_value/ContentValueSet.vue index 3eb9c0e..0bf8641 100644 --- a/frontend/src/components/content_value/ContentValueSet.vue +++ b/frontend/src/components/content_value/ContentValueSet.vue @@ -35,7 +35,7 @@ const props = defineProps({ length: Number, viewAs: { type: String, - default: formatTypes.PLAIN_TEXT, + default: formatTypes.RAW, }, decode: { type: String, diff --git a/frontend/src/components/content_value/ContentValueStream.vue b/frontend/src/components/content_value/ContentValueStream.vue index 1ae8eb2..a119903 100644 --- a/frontend/src/components/content_value/ContentValueStream.vue +++ b/frontend/src/components/content_value/ContentValueStream.vue @@ -38,7 +38,7 @@ const props = defineProps({ length: Number, viewAs: { type: String, - default: formatTypes.PLAIN_TEXT, + default: formatTypes.RAW, }, decode: { type: String, diff --git a/frontend/src/components/content_value/ContentValueString.vue b/frontend/src/components/content_value/ContentValueString.vue index c20503f..136726f 100644 --- a/frontend/src/components/content_value/ContentValueString.vue +++ b/frontend/src/components/content_value/ContentValueString.vue @@ -59,7 +59,7 @@ const viewLanguage = computed(() => { const viewAs = reactive({ value: '', - format: formatTypes.PLAIN_TEXT, + format: formatTypes.RAW, decode: decodeTypes.NONE, }) diff --git a/frontend/src/components/content_value/ContentValueWrapper.vue b/frontend/src/components/content_value/ContentValueWrapper.vue index 4cfd9e5..6aeb5a7 100644 --- a/frontend/src/components/content_value/ContentValueWrapper.vue +++ b/frontend/src/components/content_value/ContentValueWrapper.vue @@ -76,7 +76,7 @@ const loadData = async (reset, full) => { decodeType: decodeType, matchPattern: matchPattern, decode: reset ? decodeTypes.NONE : decode, - format: reset ? formatTypes.PLAIN_TEXT : format, + format: reset ? formatTypes.RAW : format, reset, full: full === true, }) diff --git a/frontend/src/components/content_value/ContentValueZSet.vue b/frontend/src/components/content_value/ContentValueZSet.vue index f551c67..c62c117 100644 --- a/frontend/src/components/content_value/ContentValueZSet.vue +++ b/frontend/src/components/content_value/ContentValueZSet.vue @@ -135,6 +135,9 @@ const valueColumn = reactive({ align: 'center', titleAlign: 'center', resizable: true, + ellipsis: { + tooltip: true, + }, filterOptionValue: null, filter(value, row) { return !!~row.value.indexOf(value.toString()) diff --git a/frontend/src/components/content_value/FormatSelector.vue b/frontend/src/components/content_value/FormatSelector.vue index 2733daf..7fdc299 100644 --- a/frontend/src/components/content_value/FormatSelector.vue +++ b/frontend/src/components/content_value/FormatSelector.vue @@ -12,7 +12,7 @@ const props = defineProps({ }, format: { type: String, - default: formatTypes.PLAIN_TEXT, + default: formatTypes.RAW, }, disabled: Boolean, }) @@ -23,7 +23,7 @@ const onFormatChanged = (selDecode, selFormat) => { selDecode = decodeTypes.NONE } if (!some(formatTypes, (val) => val === selFormat)) { - selFormat = formatTypes.PLAIN_TEXT + selFormat = formatTypes.RAW } emit('formatChanged', selDecode, selFormat) if (selDecode !== props.decode) { @@ -38,7 +38,7 @@ const onFormatChanged = (selDecode, selFormat) => {