Skip to content

Commit

Permalink
perf: lazy load config items
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Apr 5, 2024
1 parent e5c7108 commit b42ee54
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/components/ConfigItem.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, defineModel } from 'vue'
import { isGridView } from '../composables/state'
import { isGridView } from '~/composables/state'
import { stringifyUnquoted } from '~/composables/strings'
import { filtersRules } from '~/composables/state'
import { useRouter } from '#app/composables/router'
Expand All @@ -13,6 +13,7 @@ const props = defineProps<{
active?: boolean
}>()
const emit = defineEmits<{
badgeClick: [string]
}>()
Expand All @@ -21,6 +22,16 @@ const open = defineModel('open', {
default: true,
})
const hasShown = ref(open.value)
if (!hasShown.value) {
const stop = watchEffect(() => {
if (open.value) {
hasShown.value = true
stop()
}
})
}
const router = useRouter()
function gotoPlugin(name: string) {
filtersRules.plugin = name
Expand Down Expand Up @@ -97,7 +108,7 @@ const extraConfigs = computed(() => {
#{{ index + 1 }}
</div>

<div px4 py3 flex="~ col gap-4" of-auto>
<div v-if="hasShown" px4 py3 flex="~ col gap-4" of-auto>
<div v-if="config.files" flex="~ gap-2 items-start">
<div i-ph-file-magnifying-glass-duotone my1 flex-none />
<div flex="~ col gap-2">
Expand Down

0 comments on commit b42ee54

Please sign in to comment.