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_JSON = "JSON"
const FORMAT_UNICODE_JSON = "Unicode JSON"
const FORMAT_YAML = "YAML"
const FORMAT_XML = "XML"
const FORMAT_HEX = "Hex"

View File

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

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(() => {
switch (viewAs.format) {
case formatTypes.JSON:
case formatTypes.UNICODE_JSON:
return 'json'
case formatTypes.YAML:
return 'yaml'

View File

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

View File

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

View File

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

View File

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

View File

@ -124,17 +124,17 @@ const scoreColumn = computed(() => ({
},
}))
const displayCode = computed(() => {
return props.format === formatTypes.JSON
const isCode = computed(() => {
return props.format === formatTypes.JSON || props.format === formatTypes.UNICODE_JSON
})
const valueFilterOption = ref(null)
const valueColumn = computed(() => ({
key: 'value',
title: () => i18n.t('common.value'),
align: displayCode.value ? 'left' : 'center',
align: isCode.value ? 'left' : 'center',
titleAlign: 'center',
resizable: true,
ellipsis: displayCode.value
ellipsis: isCode.value
? false
: {
tooltip: {
@ -155,7 +155,7 @@ const valueColumn = computed(() => ({
},
// sorter: (row1, row2) => row1.value - row2.value,
render: (row) => {
if (displayCode.value) {
if (isCode.value) {
return h('pre', {}, 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 wechatUrl from '@/assets/images/wechat_official.png'
import QRCode from '@/components/icons/QRCode.vue'
import Twitter from '@/components/icons/Twitter.vue'
const themeVars = useThemeVars()
const render = useRender()
@ -173,13 +174,12 @@ const exThemeVars = computed(() => {
@click="openWechatOfficial" />
<icon-button
v-else
:icon="Twitter"
:border="false"
:size="iconSize"
class="nav-menu-button"
t-tooltip="ribbon.follow_x"
@click="openX">
<span style="font-weight: bold; font-size: 24px">𝕏</span>
</icon-button>
@click="openX" />
<icon-button
:icon="Github"
:size="iconSize"

View File

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