Compare commits

...

2 Commits

12 changed files with 95 additions and 28 deletions

View File

@ -2,6 +2,7 @@ package types
const FORMAT_RAW = "Raw" const FORMAT_RAW = "Raw"
const FORMAT_JSON = "JSON" const FORMAT_JSON = "JSON"
const FORMAT_UNICODE_JSON = "Unicode JSON"
const FORMAT_YAML = "YAML" const FORMAT_YAML = "YAML"
const FORMAT_XML = "XML" const FORMAT_XML = "XML"
const FORMAT_HEX = "Hex" const FORMAT_HEX = "Hex"

View File

@ -15,6 +15,7 @@ type DataConvert interface {
var ( var (
jsonConv JsonConvert jsonConv JsonConvert
uniJsonConv UnicodeJsonConvert
yamlConv YamlConvert yamlConv YamlConvert
xmlConv XmlConvert xmlConv XmlConvert
base64Conv Base64Convert base64Conv Base64Convert
@ -31,6 +32,7 @@ var (
var BuildInFormatters = map[string]DataConvert{ var BuildInFormatters = map[string]DataConvert{
types.FORMAT_JSON: jsonConv, types.FORMAT_JSON: jsonConv,
types.FORMAT_UNICODE_JSON: uniJsonConv,
types.FORMAT_YAML: yamlConv, types.FORMAT_YAML: yamlConv,
types.FORMAT_XML: xmlConv, types.FORMAT_XML: xmlConv,
types.FORMAT_HEX: hexConv, types.FORMAT_HEX: hexConv,

View File

@ -0,0 +1,43 @@
package convutil
import (
"bytes"
"encoding/json"
"strings"
)
type UnicodeJsonConvert struct{}
func (UnicodeJsonConvert) Enable() bool {
return true
}
func (UnicodeJsonConvert) Decode(str string) (string, bool) {
trimedStr := strings.TrimSpace(str)
if strings.HasPrefix(trimedStr, "{") && strings.HasSuffix(trimedStr, "}") {
var obj map[string]any
if err := json.Unmarshal([]byte(trimedStr), &obj); err == nil {
var out []byte
if out, err = json.MarshalIndent(obj, "", " "); err == nil {
return string(out), true
}
}
} else if strings.HasPrefix(trimedStr, "[") && strings.HasSuffix(trimedStr, "]") {
var arr []any
if err := json.Unmarshal([]byte(trimedStr), &arr); err == nil {
var out []byte
if out, err = json.MarshalIndent(arr, "", " "); err == nil {
return string(out), true
}
}
}
return str, false
}
func (UnicodeJsonConvert) Encode(str string) (string, bool) {
var dst bytes.Buffer
if err := json.Compact(&dst, []byte(str)); err != nil {
return str, false
}
return dst.String(), true
}

View File

@ -94,6 +94,7 @@ const enableSave = computed(() => {
const viewLanguage = computed(() => { const viewLanguage = computed(() => {
switch (viewAs.format) { switch (viewAs.format) {
case formatTypes.JSON: case formatTypes.JSON:
case formatTypes.UNICODE_JSON:
return 'json' return 'json'
case formatTypes.YAML: case formatTypes.YAML:
return 'yaml' return 'yaml'

View File

@ -107,17 +107,17 @@ const fieldColumn = computed(() => ({
}, },
})) }))
const displayCode = computed(() => { const isCode = computed(() => {
return props.format === formatTypes.JSON return props.format === formatTypes.JSON || props.format === formatTypes.UNICODE_JSON
}) })
// const valueFilterOption = ref(null) // const valueFilterOption = ref(null)
const valueColumn = computed(() => ({ const valueColumn = computed(() => ({
key: 'value', key: 'value',
title: () => i18n.t('common.value'), title: () => i18n.t('common.value'),
align: displayCode.value ? 'left' : 'center', align: isCode.value ? 'left' : 'center',
titleAlign: 'center', titleAlign: 'center',
resizable: true, resizable: true,
ellipsis: displayCode.value ellipsis: isCode.value
? false ? false
: { : {
tooltip: { tooltip: {
@ -137,7 +137,7 @@ const valueColumn = computed(() => ({
// return !!~row.v.indexOf(value.toString()) // return !!~row.v.indexOf(value.toString())
// }, // },
render: (row) => { render: (row) => {
if (displayCode.value) { if (isCode.value) {
return h('pre', {}, row.dv || row.v) return h('pre', {}, row.dv || row.v)
} }
return row.dv || row.v return row.dv || row.v

View File

@ -77,16 +77,16 @@ const inEdit = computed(() => {
}) })
const fullEdit = ref(false) const fullEdit = ref(false)
const displayCode = computed(() => { const isCode = computed(() => {
return props.format === formatTypes.JSON return props.format === formatTypes.JSON || props.format === formatTypes.UNICODE_JSON
}) })
const valueFilterOption = ref(null) const valueFilterOption = ref(null)
const valueColumn = computed(() => ({ const valueColumn = computed(() => ({
key: 'value', key: 'value',
title: () => i18n.t('common.value'), title: () => i18n.t('common.value'),
align: displayCode.value ? 'left' : 'center', align: isCode.value ? 'left' : 'center',
titleAlign: 'center', titleAlign: 'center',
ellipsis: displayCode.value ellipsis: isCode.value
? false ? false
: { : {
tooltip: { tooltip: {
@ -106,7 +106,7 @@ const valueColumn = computed(() => ({
return !!~row.v.indexOf(value.toString()) return !!~row.v.indexOf(value.toString())
}, },
render: (row) => { render: (row) => {
if (displayCode.value) { if (isCode.value) {
return h('pre', {}, row.dv || row.v) return h('pre', {}, row.dv || row.v)
} }
return row.dv || row.v return row.dv || row.v

View File

@ -76,16 +76,16 @@ const inEdit = computed(() => {
}) })
const fullEdit = ref(false) const fullEdit = ref(false)
const displayCode = computed(() => { const isCode = computed(() => {
return props.format === formatTypes.JSON return props.format === formatTypes.JSON || props.format === formatTypes.UNICODE_JSON
}) })
const valueFilterOption = ref(null) const valueFilterOption = ref(null)
const valueColumn = computed(() => ({ const valueColumn = computed(() => ({
key: 'value', key: 'value',
title: () => i18n.t('common.value'), title: () => i18n.t('common.value'),
align: displayCode.value ? 'left' : 'center', align: isCode.value ? 'left' : 'center',
titleAlign: 'center', titleAlign: 'center',
ellipsis: displayCode.value ellipsis: isCode.value
? false ? false
: { : {
tooltip: { tooltip: {
@ -105,7 +105,7 @@ const valueColumn = computed(() => ({
return !!~row.v.indexOf(value.toString()) return !!~row.v.indexOf(value.toString())
}, },
render: (row) => { render: (row) => {
if (displayCode.value) { if (isCode.value) {
return h('pre', {}, row.dv || row.v) return h('pre', {}, row.dv || row.v)
} }
return row.dv || row.v return row.dv || row.v

View File

@ -47,6 +47,7 @@ const keyType = redisTypes.STRING
const viewLanguage = computed(() => { const viewLanguage = computed(() => {
switch (viewAs.format) { switch (viewAs.format) {
case formatTypes.JSON: case formatTypes.JSON:
case formatTypes.UNICODE_JSON:
return 'json' return 'json'
case formatTypes.YAML: case formatTypes.YAML:
return 'yaml' return 'yaml'

View File

@ -124,17 +124,17 @@ const scoreColumn = computed(() => ({
}, },
})) }))
const displayCode = computed(() => { const isCode = computed(() => {
return props.format === formatTypes.JSON return props.format === formatTypes.JSON || props.format === formatTypes.UNICODE_JSON
}) })
const valueFilterOption = ref(null) const valueFilterOption = ref(null)
const valueColumn = computed(() => ({ const valueColumn = computed(() => ({
key: 'value', key: 'value',
title: () => i18n.t('common.value'), title: () => i18n.t('common.value'),
align: displayCode.value ? 'left' : 'center', align: isCode.value ? 'left' : 'center',
titleAlign: 'center', titleAlign: 'center',
resizable: true, resizable: true,
ellipsis: displayCode.value ellipsis: isCode.value
? false ? false
: { : {
tooltip: { tooltip: {
@ -155,7 +155,7 @@ const valueColumn = computed(() => ({
}, },
// sorter: (row1, row2) => row1.value - row2.value, // sorter: (row1, row2) => row1.value - row2.value,
render: (row) => { render: (row) => {
if (displayCode.value) { if (isCode.value) {
return h('pre', {}, row.dv || row.v) return h('pre', {}, row.dv || row.v)
} }
return row.dv || row.v return row.dv || row.v

View File

@ -0,0 +1,18 @@
<script setup>
const props = defineProps({
strokeWidth: {
type: [Number, String],
default: 3,
},
})
</script>
<template>
<svg fill="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path
:stroke-width="props.strokeWidth"
d="M8 2H1L9.26086 13.0145L1.44995 21.9999H4.09998L10.4883 14.651L16 22H23L14.3917 10.5223L21.8001 2H19.1501L13.1643 8.88578L8 2ZM17 20L5 4H7L19 20H17Z"></path>
</svg>
</template>
<style lang="scss" scoped></style>

View File

@ -16,6 +16,7 @@ import useBrowserStore from 'stores/browser.js'
import { useRender } from '@/utils/render.js' import { useRender } from '@/utils/render.js'
import wechatUrl from '@/assets/images/wechat_official.png' import wechatUrl from '@/assets/images/wechat_official.png'
import QRCode from '@/components/icons/QRCode.vue' import QRCode from '@/components/icons/QRCode.vue'
import Twitter from '@/components/icons/Twitter.vue'
const themeVars = useThemeVars() const themeVars = useThemeVars()
const render = useRender() const render = useRender()
@ -173,13 +174,12 @@ const exThemeVars = computed(() => {
@click="openWechatOfficial" /> @click="openWechatOfficial" />
<icon-button <icon-button
v-else v-else
:icon="Twitter"
:border="false" :border="false"
:size="iconSize" :size="iconSize"
class="nav-menu-button" class="nav-menu-button"
t-tooltip="ribbon.follow_x" t-tooltip="ribbon.follow_x"
@click="openX"> @click="openX" />
<span style="font-weight: bold; font-size: 24px">𝕏</span>
</icon-button>
<icon-button <icon-button
:icon="Github" :icon="Github"
:size="iconSize" :size="iconSize"

View File

@ -5,6 +5,7 @@
export const formatTypes = { export const formatTypes = {
RAW: 'Raw', RAW: 'Raw',
JSON: 'JSON', JSON: 'JSON',
UNICODE_JSON: 'Unicode JSON',
YAML: 'YAML', YAML: 'YAML',
XML: 'XML', XML: 'XML',
HEX: 'Hex', HEX: 'Hex',