mirror of
https://github.com/tiny-craft/tiny-rdm.git
synced 2025-10-31 02:26:54 +08:00
feat: add decode and format selection for Hash edit
perf: move decode and format state management into the component internally perf: add component FormatSelector and ContentEntryEditor refactor: modified functions with an excessive number of parameters to accept an object as a parameter
This commit is contained in:
@@ -10,7 +10,6 @@ import { useThemeVars } from 'naive-ui'
|
||||
import useBrowserStore from 'stores/browser.js'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { isEmpty } from 'lodash'
|
||||
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
|
||||
import useDialogStore from 'stores/dialog.js'
|
||||
|
||||
const themeVars = useThemeVars()
|
||||
@@ -45,6 +44,7 @@ const props = defineProps({
|
||||
const data = computed(() => {
|
||||
return props.content
|
||||
})
|
||||
const initializing = ref(false)
|
||||
|
||||
const binaryKey = computed(() => {
|
||||
return !!data.value.keyCode
|
||||
@@ -116,22 +116,29 @@ const onLoadAll = () => {
|
||||
loadData(false, true)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
const initContent = async () => {
|
||||
// onReload()
|
||||
loadData(false, false)
|
||||
})
|
||||
|
||||
const contentRef = ref(null)
|
||||
watch(
|
||||
() => data.value?.keyPath,
|
||||
() => {
|
||||
// onReload()
|
||||
try {
|
||||
initializing.value = true
|
||||
if (contentRef.value?.reset != null) {
|
||||
contentRef.value?.reset()
|
||||
}
|
||||
loadData(false, false)
|
||||
},
|
||||
)
|
||||
await loadData(false, false)
|
||||
if (contentRef.value?.beforeShow != null) {
|
||||
await contentRef.value?.beforeShow()
|
||||
}
|
||||
} finally {
|
||||
initializing.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
// onReload()
|
||||
initContent()
|
||||
})
|
||||
|
||||
const contentRef = ref(null)
|
||||
watch(() => data.value?.keyPath, initContent)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -145,17 +152,15 @@ watch(
|
||||
:is="valueComponents[data.type]"
|
||||
ref="contentRef"
|
||||
:db="data.db"
|
||||
:decode="data.decode || decodeTypes.NONE"
|
||||
:end="data.end"
|
||||
:key-code="data.keyCode"
|
||||
:key-path="data.keyPath"
|
||||
:length="data.length"
|
||||
:loading="data.loading === true"
|
||||
:loading="data.loading === true || initializing"
|
||||
:name="data.name"
|
||||
:size="data.size"
|
||||
:ttl="data.ttl"
|
||||
:value="data.value"
|
||||
:view-as="data.viewAs || formatTypes.PLAIN_TEXT"
|
||||
@delete="onDelete"
|
||||
@loadall="onLoadAll"
|
||||
@loadmore="onLoadMore"
|
||||
|
||||
Reference in New Issue
Block a user