数据结构优化

This commit is contained in:
李琦
2026-01-20 11:12:01 +08:00
parent b088ba48be
commit 4aa757082b
9 changed files with 519 additions and 51 deletions

View File

@@ -100,7 +100,7 @@
<script setup lang="ts">
import { ref, onMounted, computed, nextTick, onBeforeUnmount } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { fetchPost, Post } from '../services/api'
import { fetchPost, Post, getPublicSettings } from '../services/api'
import { useScrollAnimation } from '../composables/useScrollAnimation'
// 引入 Markdown 解析依赖
@@ -345,6 +345,19 @@ const addCopyListeners = () => {
})
}
// 更新页面标题
const updatePageTitle = async (articleTitle: string) => {
try {
const settings = await getPublicSettings()
const siteTitle = settings.site_title || '年糕崽崽.Dev'
document.title = `${siteTitle} | ${articleTitle}`
} catch (error) {
console.error('Failed to update page title:', error)
// 即使获取配置失败,也更新标题
document.title = `年糕崽崽.Dev | ${articleTitle}`
}
}
const fetchBlogDetail = async () => {
loading.value = true
error.value = ''
@@ -352,6 +365,12 @@ const fetchBlogDetail = async () => {
const postData = await fetchPost(postId)
if (postData) {
post.value = postData
// 更新页面标题
if (postData.title) {
await updatePageTitle(postData.title)
}
// 初始化动画、事件监听和目录 - 在数据加载完成后
nextTick(() => {
setTimeout(() => {