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
|
param.Decode = types.DECODE_NONE
|
||||||
}
|
}
|
||||||
if len(param.Format) <= 0 {
|
if len(param.Format) <= 0 {
|
||||||
param.Format = types.VIEWAS_PLAIN_TEXT
|
param.Format = types.FORMAT_RAW
|
||||||
}
|
}
|
||||||
switch strings.ToLower(param.KeyType) {
|
switch strings.ToLower(param.KeyType) {
|
||||||
case "string":
|
case "string":
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package types
|
package types
|
||||||
|
|
||||||
const VIEWAS_PLAIN_TEXT = "Plain Text"
|
const FORMAT_RAW = "Raw"
|
||||||
const VIEWAS_JSON = "JSON"
|
const FORMAT_JSON = "JSON"
|
||||||
const VIEWAS_HEX = "Hex"
|
const FORMAT_HEX = "Hex"
|
||||||
const VIEWAS_BINARY = "Binary"
|
const FORMAT_BINARY = "Binary"
|
||||||
|
|
||||||
const DECODE_NONE = "None"
|
const DECODE_NONE = "None"
|
||||||
const DECODE_BASE64 = "Base64"
|
const DECODE_BASE64 = "Base64"
|
||||||
|
|
|
@ -25,7 +25,7 @@ func ConvertTo(str, decodeType, formatType string) (value, resultDecode, resultF
|
||||||
if len(str) <= 0 {
|
if len(str) <= 0 {
|
||||||
// empty content
|
// empty content
|
||||||
if len(formatType) <= 0 {
|
if len(formatType) <= 0 {
|
||||||
resultFormat = types.VIEWAS_PLAIN_TEXT
|
resultFormat = types.FORMAT_RAW
|
||||||
} else {
|
} else {
|
||||||
resultFormat = formatType
|
resultFormat = formatType
|
||||||
}
|
}
|
||||||
|
@ -142,12 +142,12 @@ 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.VIEWAS_PLAIN_TEXT:
|
case types.FORMAT_RAW:
|
||||||
value = str
|
value = str
|
||||||
resultFormat = formatType
|
resultFormat = formatType
|
||||||
return
|
return
|
||||||
|
|
||||||
case types.VIEWAS_JSON:
|
case types.FORMAT_JSON:
|
||||||
if jsonStr, ok := decodeJson(str); ok {
|
if jsonStr, ok := decodeJson(str); ok {
|
||||||
value = jsonStr
|
value = jsonStr
|
||||||
} else {
|
} else {
|
||||||
|
@ -156,7 +156,7 @@ func viewAs(str, formatType string) (value, resultFormat string) {
|
||||||
resultFormat = formatType
|
resultFormat = formatType
|
||||||
return
|
return
|
||||||
|
|
||||||
case types.VIEWAS_HEX:
|
case types.FORMAT_HEX:
|
||||||
if hexStr, ok := decodeToHex(str); ok {
|
if hexStr, ok := decodeToHex(str); ok {
|
||||||
value = hexStr
|
value = hexStr
|
||||||
} else {
|
} else {
|
||||||
|
@ -165,7 +165,7 @@ func viewAs(str, formatType string) (value, resultFormat string) {
|
||||||
resultFormat = formatType
|
resultFormat = formatType
|
||||||
return
|
return
|
||||||
|
|
||||||
case types.VIEWAS_BINARY:
|
case types.FORMAT_BINARY:
|
||||||
if binStr, ok := decodeBinary(str); ok {
|
if binStr, ok := decodeBinary(str); ok {
|
||||||
value = binStr
|
value = binStr
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,20 +185,20 @@ func autoViewAs(str string) (value, resultFormat string) {
|
||||||
if len(str) > 0 {
|
if len(str) > 0 {
|
||||||
var ok bool
|
var ok bool
|
||||||
if value, ok = decodeJson(str); ok {
|
if value, ok = decodeJson(str); ok {
|
||||||
resultFormat = types.VIEWAS_JSON
|
resultFormat = types.FORMAT_JSON
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if containsBinary(str) {
|
if containsBinary(str) {
|
||||||
if value, ok = decodeToHex(str); ok {
|
if value, ok = decodeToHex(str); ok {
|
||||||
resultFormat = types.VIEWAS_HEX
|
resultFormat = types.FORMAT_HEX
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value = str
|
value = str
|
||||||
resultFormat = types.VIEWAS_PLAIN_TEXT
|
resultFormat = types.FORMAT_RAW
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ func decodeBrotli(str string) (string, bool) {
|
||||||
func SaveAs(str, viewType, decodeType string) (value string, err error) {
|
func SaveAs(str, viewType, decodeType string) (value string, err error) {
|
||||||
value = str
|
value = str
|
||||||
switch viewType {
|
switch viewType {
|
||||||
case types.VIEWAS_JSON:
|
case types.FORMAT_JSON:
|
||||||
if jsonStr, ok := encodeJson(str); ok {
|
if jsonStr, ok := encodeJson(str); ok {
|
||||||
value = jsonStr
|
value = jsonStr
|
||||||
} else {
|
} else {
|
||||||
|
@ -292,7 +292,7 @@ func SaveAs(str, viewType, decodeType string) (value string, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case types.VIEWAS_HEX:
|
case types.FORMAT_HEX:
|
||||||
if hexStr, ok := encodeHex(str); ok {
|
if hexStr, ok := encodeHex(str); ok {
|
||||||
value = hexStr
|
value = hexStr
|
||||||
} else {
|
} else {
|
||||||
|
@ -300,7 +300,7 @@ func SaveAs(str, viewType, decodeType string) (value string, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
case types.VIEWAS_BINARY:
|
case types.FORMAT_BINARY:
|
||||||
if binStr, ok := encodeBinary(str); ok {
|
if binStr, ok := encodeBinary(str); ok {
|
||||||
value = binStr
|
value = binStr
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -56,7 +56,7 @@ const tabContent = computed(() => {
|
||||||
size: tab.size || 0,
|
size: tab.size || 0,
|
||||||
length: tab.length || 0,
|
length: tab.length || 0,
|
||||||
decode: tab.decode || decodeTypes.NONE,
|
decode: tab.decode || decodeTypes.NONE,
|
||||||
format: tab.format || formatTypes.PLAIN_TEXT,
|
format: tab.format || formatTypes.RAW,
|
||||||
end: tab.end === true,
|
end: tab.end === true,
|
||||||
loading: tab.loading === true,
|
loading: tab.loading === true,
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ const loading = ref(false)
|
||||||
const viewAs = reactive({
|
const viewAs = reactive({
|
||||||
field: '',
|
field: '',
|
||||||
value: '',
|
value: '',
|
||||||
format: formatTypes.PLAIN_TEXT,
|
format: formatTypes.RAW,
|
||||||
decode: decodeTypes.NONE,
|
decode: decodeTypes.NONE,
|
||||||
})
|
})
|
||||||
const displayValue = computed(() => {
|
const displayValue = computed(() => {
|
||||||
|
|
|
@ -42,7 +42,7 @@ const props = defineProps({
|
||||||
length: Number,
|
length: Number,
|
||||||
format: {
|
format: {
|
||||||
type: String,
|
type: String,
|
||||||
default: formatTypes.PLAIN_TEXT,
|
default: formatTypes.RAW,
|
||||||
},
|
},
|
||||||
decode: {
|
decode: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -81,7 +81,7 @@ const currentEditRow = reactive({
|
||||||
no: 0,
|
no: 0,
|
||||||
key: '',
|
key: '',
|
||||||
value: null,
|
value: null,
|
||||||
format: formatTypes.PLAIN_TEXT,
|
format: formatTypes.RAW,
|
||||||
decode: decodeTypes.NONE,
|
decode: decodeTypes.NONE,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ const resetEdit = () => {
|
||||||
currentEditRow.no = 0
|
currentEditRow.no = 0
|
||||||
currentEditRow.key = ''
|
currentEditRow.key = ''
|
||||||
currentEditRow.value = null
|
currentEditRow.value = null
|
||||||
currentEditRow.format = formatTypes.PLAIN_TEXT
|
currentEditRow.format = formatTypes.RAW
|
||||||
currentEditRow.decode = decodeTypes.NONE
|
currentEditRow.decode = decodeTypes.NONE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ const props = defineProps({
|
||||||
length: Number,
|
length: Number,
|
||||||
viewAs: {
|
viewAs: {
|
||||||
type: String,
|
type: String,
|
||||||
default: formatTypes.PLAIN_TEXT,
|
default: formatTypes.RAW,
|
||||||
},
|
},
|
||||||
decode: {
|
decode: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
@ -35,7 +35,7 @@ const props = defineProps({
|
||||||
length: Number,
|
length: Number,
|
||||||
viewAs: {
|
viewAs: {
|
||||||
type: String,
|
type: String,
|
||||||
default: formatTypes.PLAIN_TEXT,
|
default: formatTypes.RAW,
|
||||||
},
|
},
|
||||||
decode: {
|
decode: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
@ -38,7 +38,7 @@ const props = defineProps({
|
||||||
length: Number,
|
length: Number,
|
||||||
viewAs: {
|
viewAs: {
|
||||||
type: String,
|
type: String,
|
||||||
default: formatTypes.PLAIN_TEXT,
|
default: formatTypes.RAW,
|
||||||
},
|
},
|
||||||
decode: {
|
decode: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|
|
@ -59,7 +59,7 @@ const viewLanguage = computed(() => {
|
||||||
|
|
||||||
const viewAs = reactive({
|
const viewAs = reactive({
|
||||||
value: '',
|
value: '',
|
||||||
format: formatTypes.PLAIN_TEXT,
|
format: formatTypes.RAW,
|
||||||
decode: decodeTypes.NONE,
|
decode: decodeTypes.NONE,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ const loadData = async (reset, full) => {
|
||||||
decodeType: decodeType,
|
decodeType: decodeType,
|
||||||
matchPattern: matchPattern,
|
matchPattern: matchPattern,
|
||||||
decode: reset ? decodeTypes.NONE : decode,
|
decode: reset ? decodeTypes.NONE : decode,
|
||||||
format: reset ? formatTypes.PLAIN_TEXT : format,
|
format: reset ? formatTypes.RAW : format,
|
||||||
reset,
|
reset,
|
||||||
full: full === true,
|
full: full === true,
|
||||||
})
|
})
|
||||||
|
|
|
@ -135,6 +135,9 @@ const valueColumn = reactive({
|
||||||
align: 'center',
|
align: 'center',
|
||||||
titleAlign: 'center',
|
titleAlign: 'center',
|
||||||
resizable: true,
|
resizable: true,
|
||||||
|
ellipsis: {
|
||||||
|
tooltip: true,
|
||||||
|
},
|
||||||
filterOptionValue: null,
|
filterOptionValue: null,
|
||||||
filter(value, row) {
|
filter(value, row) {
|
||||||
return !!~row.value.indexOf(value.toString())
|
return !!~row.value.indexOf(value.toString())
|
||||||
|
|
|
@ -12,7 +12,7 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
format: {
|
format: {
|
||||||
type: String,
|
type: String,
|
||||||
default: formatTypes.PLAIN_TEXT,
|
default: formatTypes.RAW,
|
||||||
},
|
},
|
||||||
disabled: Boolean,
|
disabled: Boolean,
|
||||||
})
|
})
|
||||||
|
@ -23,7 +23,7 @@ const onFormatChanged = (selDecode, selFormat) => {
|
||||||
selDecode = decodeTypes.NONE
|
selDecode = decodeTypes.NONE
|
||||||
}
|
}
|
||||||
if (!some(formatTypes, (val) => val === selFormat)) {
|
if (!some(formatTypes, (val) => val === selFormat)) {
|
||||||
selFormat = formatTypes.PLAIN_TEXT
|
selFormat = formatTypes.RAW
|
||||||
}
|
}
|
||||||
emit('formatChanged', selDecode, selFormat)
|
emit('formatChanged', selDecode, selFormat)
|
||||||
if (selDecode !== props.decode) {
|
if (selDecode !== props.decode) {
|
||||||
|
@ -38,7 +38,7 @@ const onFormatChanged = (selDecode, selFormat) => {
|
||||||
<template>
|
<template>
|
||||||
<n-space :size="0" :wrap="false" :wrap-item="false" align="center" justify="start" style="margin-top: 5px">
|
<n-space :size="0" :wrap="false" :wrap-item="false" align="center" justify="start" style="margin-top: 5px">
|
||||||
<dropdown-selector
|
<dropdown-selector
|
||||||
:default="formatTypes.PLAIN_TEXT"
|
:default="formatTypes.RAW"
|
||||||
:disabled="props.disabled"
|
:disabled="props.disabled"
|
||||||
:icon="Code"
|
:icon="Code"
|
||||||
:options="formatTypes"
|
:options="formatTypes"
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
export const formatTypes = {
|
export const formatTypes = {
|
||||||
PLAIN_TEXT: 'Plain Text',
|
RAW: 'Raw',
|
||||||
JSON: 'JSON',
|
JSON: 'JSON',
|
||||||
// XML: 'XML',
|
// XML: 'XML',
|
||||||
// YML: 'YML',
|
// YML: 'YML',
|
||||||
|
|
|
@ -963,16 +963,7 @@ const useBrowserStore = defineStore('browser', {
|
||||||
* @param {string} [decode]
|
* @param {string} [decode]
|
||||||
* @returns {Promise<{[msg]: string, success: boolean, [nodeKey]: {string}}>}
|
* @returns {Promise<{[msg]: string, success: boolean, [nodeKey]: {string}}>}
|
||||||
*/
|
*/
|
||||||
async setKey({
|
async setKey({ server, db, key, keyType, value, ttl, format = formatTypes.RAW, decode = decodeTypes.NONE }) {
|
||||||
server,
|
|
||||||
db,
|
|
||||||
key,
|
|
||||||
keyType,
|
|
||||||
value,
|
|
||||||
ttl,
|
|
||||||
format = formatTypes.PLAIN_TEXT,
|
|
||||||
decode = decodeTypes.NONE,
|
|
||||||
}) {
|
|
||||||
try {
|
try {
|
||||||
const { data, success, msg } = await SetKeyValue({
|
const { data, success, msg } = await SetKeyValue({
|
||||||
server,
|
server,
|
||||||
|
@ -1030,7 +1021,7 @@ const useBrowserStore = defineStore('browser', {
|
||||||
newField = '',
|
newField = '',
|
||||||
value = '',
|
value = '',
|
||||||
decode = decodeTypes.NONE,
|
decode = decodeTypes.NONE,
|
||||||
format = formatTypes.PLAIN_TEXT,
|
format = formatTypes.RAW,
|
||||||
refresh,
|
refresh,
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue