perf: add reset handle for all content components

This commit is contained in:
tiny-craft 2023-11-09 20:31:07 +08:00
parent 352e7b714d
commit fa4929cd63
6 changed files with 36 additions and 1 deletions

View File

@ -261,6 +261,12 @@ const onUpdateFilter = (filters, sourceColumn) => {
break break
} }
} }
defineExpose({
reset: () => {
clearFilter()
},
})
</script> </script>
<template> <template>

View File

@ -194,6 +194,12 @@ const clearFilter = () => {
const onUpdateFilter = (filters, sourceColumn) => { const onUpdateFilter = (filters, sourceColumn) => {
valueColumn.filterOptionValue = filters[sourceColumn.key] valueColumn.filterOptionValue = filters[sourceColumn.key]
} }
defineExpose({
reset: () => {
clearFilter()
},
})
</script> </script>
<template> <template>

View File

@ -195,6 +195,12 @@ const clearFilter = () => {
const onUpdateFilter = (filters, sourceColumn) => { const onUpdateFilter = (filters, sourceColumn) => {
valueColumn.filterOptionValue = filters[sourceColumn.key] valueColumn.filterOptionValue = filters[sourceColumn.key]
} }
defineExpose({
reset: () => {
clearFilter()
},
})
</script> </script>
<template> <template>

View File

@ -184,6 +184,12 @@ const onUpdateFilter = (filters, sourceColumn) => {
break break
} }
} }
defineExpose({
reset: () => {
clearFilter()
},
})
</script> </script>
<template> <template>

View File

@ -8,7 +8,7 @@ import ContentValueZset from '@/components/content_value/ContentValueZSet.vue'
import ContentValueStream from '@/components/content_value/ContentValueStream.vue' import ContentValueStream from '@/components/content_value/ContentValueStream.vue'
import { useThemeVars } from 'naive-ui' import { useThemeVars } from 'naive-ui'
import useBrowserStore from 'stores/browser.js' import useBrowserStore from 'stores/browser.js'
import { computed, onMounted, watch } from 'vue' import { computed, onMounted, ref, watch } from 'vue'
import { isEmpty } from 'lodash' import { isEmpty } from 'lodash'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js' import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useDialogStore from 'stores/dialog.js' import useDialogStore from 'stores/dialog.js'
@ -121,10 +121,14 @@ onMounted(() => {
loadData(false, false) loadData(false, false)
}) })
const contentRef = ref(null)
watch( watch(
() => data.value?.keyPath, () => data.value?.keyPath,
() => { () => {
// onReload() // onReload()
if (contentRef.value?.reset != null) {
contentRef.value?.reset()
}
loadData(false, false) loadData(false, false)
}, },
) )
@ -138,6 +142,7 @@ watch(
</n-empty> </n-empty>
<keep-alive v-else> <keep-alive v-else>
<component <component
ref="contentRef"
:is="valueComponents[data.type]" :is="valueComponents[data.type]"
:db="data.db" :db="data.db"
:decode="data.decode || decodeTypes.NONE" :decode="data.decode || decodeTypes.NONE"

View File

@ -299,6 +299,12 @@ const onUpdateFilter = (filters, sourceColumn) => {
break break
} }
} }
defineExpose({
reset: () => {
clearFilter()
},
})
</script> </script>
<template> <template>