From 3d20aee8eb1efcfda76da594d323a01cffc6e83c Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 14 Jun 2023 06:37:33 +0800 Subject: [PATCH] add format converter --- src/components/dynamic/ArrayObjectElement.vue | 2 +- src/components/dynamic/TextElement.vue | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/components/dynamic/ArrayObjectElement.vue b/src/components/dynamic/ArrayObjectElement.vue index a20453ac..2032002a 100644 --- a/src/components/dynamic/ArrayObjectElement.vue +++ b/src/components/dynamic/ArrayObjectElement.vue @@ -27,7 +27,7 @@ const header = computed(() => { :key="index" class="text-left capitalize" > - {{ item }} - + {{ item.replace(/_/g, ' ') }} diff --git a/src/components/dynamic/TextElement.vue b/src/components/dynamic/TextElement.vue index 9b471c08..a0c0704d 100644 --- a/src/components/dynamic/TextElement.vue +++ b/src/components/dynamic/TextElement.vue @@ -4,6 +4,7 @@ import { useBlockchain, useFormatter } from '@/stores'; import MdEditor from 'md-editor-v3'; import { computed, onMounted, ref } from 'vue'; import nameMatcha from '@leapwallet/name-matcha' +import { fromBase64, toHex } from '@cosmjs/encoding'; const chainStore = useBlockchain() const props = defineProps(['value']); @@ -33,6 +34,8 @@ const text = computed(() => { case v.search(/^[1-9]\d{3}-\d{1,2}-\d{1,2}T\d{1,2}:\d{2}:\d{2}[.\d]*Z$/g) > -1: { return new Date(v).toLocaleString(navigator.language) } + case toHexOutput.value: + return toHex(fromBase64(v)).toUpperCase() } return v }) @@ -44,6 +47,10 @@ onMounted(() => { names.value = Object.keys(re).map(key => ({name: re[key], provider: key})).filter( x => x.name) }) }) +const toHexOutput = ref(false) +const isConvertable = computed(() => { + return String(props.value).endsWith('=') && props.value.length !== 28 +})