From 5dd49a78dd242096d1bdd905094cfd756beafb82 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Thu, 7 Dec 2023 11:11:31 +0800 Subject: [PATCH] perf: add loading status to "redis type tag" --- .../src/components/common/RedisTypeTag.vue | 37 ++++++++++++-- frontend/src/components/icons/Loading.vue | 51 +++++++++++++++++++ .../src/components/sidebar/BrowserTree.vue | 14 ++--- 3 files changed, 88 insertions(+), 14 deletions(-) create mode 100644 frontend/src/components/icons/Loading.vue diff --git a/frontend/src/components/common/RedisTypeTag.vue b/frontend/src/components/common/RedisTypeTag.vue index f567c7e..596add1 100644 --- a/frontend/src/components/common/RedisTypeTag.vue +++ b/frontend/src/components/common/RedisTypeTag.vue @@ -3,6 +3,8 @@ import { computed } from 'vue' import { typesBgColor, typesColor, typesShortName } from '@/consts/support_redis_type.js' import Binary from '@/components/icons/Binary.vue' import { get, toUpper } from 'lodash' +import { useThemeVars } from 'naive-ui' +import Loading from '@/components/icons/Loading.vue' const props = defineProps({ type: { @@ -20,21 +22,24 @@ const props = defineProps({ }, round: Boolean, inverse: Boolean, + loading: Boolean, }) +const themeVars = useThemeVars() + const fontColor = computed(() => { if (props.inverse) { - return typesBgColor[props.type] + return props.loading ? themeVars.value.tagColor : typesBgColor[props.type] } else { - return typesColor[props.type] + return props.loading ? themeVars.value.textColorBase : typesColor[props.type] } }) const backgroundColor = computed(() => { if (props.inverse) { - return typesColor[props.type] + return props.loading ? themeVars.value.textColorBase : typesColor[props.type] } else { - return typesBgColor[props.type] + return props.loading ? themeVars.value.tagColor : typesBgColor[props.type] } }) @@ -49,6 +54,7 @@ const label = computed(() => {