数据结构优化
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
<template>
|
||||
<component
|
||||
:is="iconComponent"
|
||||
:class="className"
|
||||
:style="style"
|
||||
:size="iconSize"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { computed, h } from 'vue'
|
||||
import * as LucideIcons from 'lucide-vue-next'
|
||||
import type { LucideProps } from 'lucide-vue-next'
|
||||
|
||||
interface Props {
|
||||
name: string
|
||||
@@ -31,11 +23,6 @@ const toPascalCase = (str: string) => {
|
||||
).join('')
|
||||
}
|
||||
|
||||
const iconComponent = computed(() => {
|
||||
const iconName = toPascalCase(props.name) as keyof typeof LucideIcons
|
||||
return LucideIcons[iconName] || LucideIcons.AlertCircle
|
||||
})
|
||||
|
||||
// 确保 size 是 number 类型
|
||||
const iconSize = computed(() => {
|
||||
if (typeof props.size === 'string') {
|
||||
@@ -44,4 +31,18 @@ const iconSize = computed(() => {
|
||||
}
|
||||
return props.size ?? 24
|
||||
})
|
||||
</script>
|
||||
|
||||
const iconComponent = computed(() => {
|
||||
const iconName = toPascalCase(props.name) as keyof typeof LucideIcons
|
||||
const Icon = LucideIcons[iconName] || LucideIcons.AlertCircle
|
||||
return () => h(Icon as any, {
|
||||
class: props.className,
|
||||
style: props.style,
|
||||
size: iconSize.value
|
||||
} as LucideProps)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<component :is="iconComponent" />
|
||||
</template>
|
||||
@@ -243,7 +243,7 @@ const handleClick = (e: MouseEvent) => {
|
||||
}
|
||||
|
||||
// 3. 点击触发流星
|
||||
createMeteor(true)
|
||||
createMeteor()
|
||||
}
|
||||
|
||||
const handleResize = () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<section id="blog-detail" class="page-section block">
|
||||
<div class="max-w-[90rem] mx-auto pt-20 md:pt-32 px-4 md:px-6 pb-12 md:pb-20 relative overflow-hidden">
|
||||
<div class="max-w-[90rem] mx-auto pt-20 md:pt-32 px-4 md:px-6 pb-12 md:pb-20 relative ">
|
||||
<!-- 返回按钮 -->
|
||||
<button
|
||||
@click="$router.push('/blog')"
|
||||
@@ -177,7 +177,7 @@
|
||||
:key="recPost.id"
|
||||
:to="`/blog/${recPost.id}`"
|
||||
custom
|
||||
v-slot="{ href, navigate }"
|
||||
v-slot="{ href }"
|
||||
>
|
||||
<a
|
||||
:href="href"
|
||||
|
||||
Reference in New Issue
Block a user