diff --git a/client/src/App.vue b/client/src/App.vue index 45ebd87..331bf35 100644 --- a/client/src/App.vue +++ b/client/src/App.vue @@ -1,43 +1,51 @@ + +// 应用网站配置到meta标签(页面标题由路由守卫处理) +const applySiteSettings = async () => { + try { + const settings = await getPublicSettings() + + // 更新meta标签 + const updateMetaTag = (name: string, content: string) => { + if (!content) return + + let meta = document.querySelector(`meta[name="${name}"]`) + if (!meta) { + meta = document.createElement('meta') + meta.setAttribute('name', name) + document.head.appendChild(meta) + } + meta.setAttribute('content', content) + } + + // 更新description + if (settings.site_description) { + updateMetaTag('description', settings.site_description) + } + + // 更新keywords + if (settings.site_keywords) { + updateMetaTag('keywords', settings.site_keywords) + } + + // 更新author + if (settings.site_author) { + updateMetaTag('author', settings.site_author) + } + } catch (error) { + console.error('Failed to load site settings:', error) + // 使用默认标题,不抛出错误 + } +} + +onMounted(() => { + // 只在非管理页面应用设置 + if (!isAdminOrLogin.value) { + applySiteSettings() + } +}) + \ No newline at end of file diff --git a/client/src/components/Header.vue b/client/src/components/Header.vue index e5ce17c..cabc623 100644 --- a/client/src/components/Header.vue +++ b/client/src/components/Header.vue @@ -2,7 +2,7 @@
- 年糕崽崽.Dev + {{ siteTitle || '年糕崽崽.Dev' }}