左侧导航栏修复正常

This commit is contained in:
2025-07-25 22:01:12 +08:00
parent ab0d544c41
commit daf513f6a0
6 changed files with 137 additions and 17 deletions

View File

@@ -0,0 +1,38 @@
<template>
<!-- Iconify Icons -->
<Icon v-if="isIconName(name)" :name="name" :size="size" />
<!-- Emojis -->
<span
v-else-if="isEmoji(name)"
:style="`font-size: ${size}px;`"
>{{ name }}</span>
<!-- Link -->
<NuxtImg
v-else
:src="name"
:style="`width: ${size}px; height: ${size}px;`"
class="inline"
/>
</template>
<script setup lang="ts">
const { size = 16 } = defineProps<{
name: string;
size?: number;
}>();
function isIconName(name: string): boolean {
if (name.includes('http'))
return false;
// 简单的图标名称检查,以 i- 开头或包含常见图标集
return name.startsWith('i-') ||
name.includes('lucide') ||
name.includes('heroicons') ||
name.includes('simple-icons');
}
function isEmoji(name: string): boolean {
return /(\u00a9|\u00ae|[\u2000-\u3300]|\ud83c[\ud000-\udfff]|\ud83d[\ud000-\udfff]|\ud83e[\ud000-\udfff])/g.test(name);
}
</script>