refactor: rename "viewas" to "format", rename "plain text" to "raw"
This commit is contained in:
parent
a2c2ceb483
commit
200b12cd51
|
@ -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":
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ const props = defineProps({
|
|||
length: Number,
|
||||
viewAs: {
|
||||
type: String,
|
||||
default: formatTypes.PLAIN_TEXT,
|
||||
default: formatTypes.RAW,
|
||||
},
|
||||
decode: {
|
||||
type: String,
|
||||
|
|
|
@ -35,7 +35,7 @@ const props = defineProps({
|
|||
length: Number,
|
||||
viewAs: {
|
||||
type: String,
|
||||
default: formatTypes.PLAIN_TEXT,
|
||||
default: formatTypes.RAW,
|
||||
},
|
||||
decode: {
|
||||
type: String,
|
||||
|
|
|
@ -38,7 +38,7 @@ const props = defineProps({
|
|||
length: Number,
|
||||
viewAs: {
|
||||
type: String,
|
||||
default: formatTypes.PLAIN_TEXT,
|
||||
default: formatTypes.RAW,
|
||||
},
|
||||
decode: {
|
||||
type: String,
|
||||
|
|
|
@ -59,7 +59,7 @@ const viewLanguage = computed(() => {
|
|||
|
||||
const viewAs = reactive({
|
||||
value: '',
|
||||
format: formatTypes.PLAIN_TEXT,
|
||||
format: formatTypes.RAW,
|
||||
decode: decodeTypes.NONE,
|
||||
})
|
||||
|
||||
|
|
|
@ -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,
|
||||
})
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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) => {
|
|||
<template>
|
||||
<n-space :size="0" :wrap="false" :wrap-item="false" align="center" justify="start" style="margin-top: 5px">
|
||||
<dropdown-selector
|
||||
:default="formatTypes.PLAIN_TEXT"
|
||||
:default="formatTypes.RAW"
|
||||
:disabled="props.disabled"
|
||||
:icon="Code"
|
||||
:options="formatTypes"
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* @enum {string}
|
||||
*/
|
||||
export const formatTypes = {
|
||||
PLAIN_TEXT: 'Plain Text',
|
||||
RAW: 'Raw',
|
||||
JSON: 'JSON',
|
||||
// XML: 'XML',
|
||||
// YML: 'YML',
|
||||
|
|
|
@ -963,16 +963,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
* @param {string} [decode]
|
||||
* @returns {Promise<{[msg]: string, success: boolean, [nodeKey]: {string}}>}
|
||||
*/
|
||||
async setKey({
|
||||
server,
|
||||
db,
|
||||
key,
|
||||
keyType,
|
||||
value,
|
||||
ttl,
|
||||
format = formatTypes.PLAIN_TEXT,
|
||||
decode = decodeTypes.NONE,
|
||||
}) {
|
||||
async setKey({ server, db, key, keyType, value, ttl, format = formatTypes.RAW, decode = decodeTypes.NONE }) {
|
||||
try {
|
||||
const { data, success, msg } = await SetKeyValue({
|
||||
server,
|
||||
|
@ -1030,7 +1021,7 @@ const useBrowserStore = defineStore('browser', {
|
|||
newField = '',
|
||||
value = '',
|
||||
decode = decodeTypes.NONE,
|
||||
format = formatTypes.PLAIN_TEXT,
|
||||
format = formatTypes.RAW,
|
||||
refresh,
|
||||
}) {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue