初始化

This commit is contained in:
李琦
2026-01-15 15:15:49 +08:00
parent cd22f779f5
commit 8e28549ad5
4 changed files with 44 additions and 17 deletions

View File

@@ -60,7 +60,7 @@
</template>
<script setup lang="ts">
import { ref, onMounted, watch } from 'vue'
import { ref, onMounted, onUpdated, watch, nextTick } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
@@ -97,18 +97,26 @@ const updateActiveNav = () => {
else if (path === '/about') activeNav.value = 'about'
}
const refreshIcons = () => {
if ((window as any).lucide) {
(window as any).lucide.createIcons()
}
}
onMounted(() => {
updateActiveNav()
// 初始化Lucide图标
if (window.lucide) {
window.lucide.createIcons()
}
refreshIcons()
})
onUpdated(() => {
refreshIcons()
})
watch(
() => route.path,
() => {
updateActiveNav()
nextTick(refreshIcons)
}
)

View File

@@ -12,6 +12,7 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { onMounted, onUpdated } from 'vue'
const router = useRouter()
@@ -28,4 +29,13 @@ const navigate = (target: string) => {
router.push(target)
toggleMobileMenu()
}
const refreshIcons = () => {
if ((window as any).lucide) {
(window as any).lucide.createIcons()
}
}
onMounted(refreshIcons)
onUpdated(refreshIcons)
</script>