fix: 修复系统设置动态注入到静态文件
- 简化前端 useSiteSettings,直接使用后端注入的 window.__SITE_CONFIG__ - 修复后端 serveIndexHTML 中的设置 key 名,与前端的 key 名一致 - site_name 替换为正确的数据库字段名 - logo 和 favicon 使用 site_logo 和 site_favicon - 添加 getLogo 函数根据主题自动选择 logo Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
<script lang="ts" setup>
|
||||
import { Boxes, Code, CreditCard, DollarSign, FileLock, Gauge, GitBranch, HardDrive, Hash, Key, KeyRound, Mail, Megaphone, MessageSquare, Monitor, Network, Plug, ScrollText, Settings, Shield, Smartphone, Users, Variable } from 'lucide-vue-next'
|
||||
import { computed, onMounted, onUnmounted, reactive, watch } from 'vue'
|
||||
import { Boxes, Code, CreditCard, DollarSign, FileLock, Gauge, GitBranch, HardDrive, Hash, Key, KeyRound, Mail, Megaphore, MessageSquare, Monitor, Network, Plug, ScrollText, Settings, Shield, Smartphone, Users, Variable } from 'lucide-vue-next'
|
||||
import { computed, onMounted, reactive, watch } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { usePreferredDark } from '@vueuse/core'
|
||||
|
||||
import NavTeam from '@/components/app-sidebar/nav-team.vue'
|
||||
import TeamSwitcher from '@/components/app-sidebar/team-switcher.vue'
|
||||
@@ -9,7 +10,8 @@ import NavFooter from '@/components/admin-sidebar/nav-footer.vue'
|
||||
import { useSiteSettings } from '@/composables/use-site-settings'
|
||||
|
||||
const { t } = useI18n()
|
||||
const { siteSettings } = useSiteSettings()
|
||||
const { siteSettings, getLogo } = useSiteSettings()
|
||||
const isDark = usePreferredDark()
|
||||
|
||||
const user = reactive({
|
||||
name: t('nav.admin'),
|
||||
@@ -20,31 +22,32 @@ const user = reactive({
|
||||
|
||||
const teams = reactive([
|
||||
{
|
||||
name: t('nav.adminDashboard'),
|
||||
logo: Code as any,
|
||||
name: '',
|
||||
logo: '' as any,
|
||||
},
|
||||
])
|
||||
|
||||
// 计算当前 logo
|
||||
const currentLogo = computed(() => {
|
||||
if (siteSettings.logoLight || siteSettings.logoDark || siteSettings.siteLogo) {
|
||||
return getLogo(isDark.value)
|
||||
}
|
||||
return Code // 默认图标
|
||||
})
|
||||
|
||||
// 监听系统设置变化
|
||||
watch(() => siteSettings.siteName, (newName) => {
|
||||
if (newName) {
|
||||
teams[0].name = newName
|
||||
} else {
|
||||
teams[0].name = t('nav.adminDashboard')
|
||||
}
|
||||
})
|
||||
}, { immediate: true })
|
||||
|
||||
watch(() => siteSettings.siteLogo, (newLogo) => {
|
||||
if (newLogo) {
|
||||
teams[0].logo = newLogo
|
||||
}
|
||||
})
|
||||
|
||||
// 初始化时设置
|
||||
if (siteSettings.siteName) {
|
||||
teams[0].name = siteSettings.siteName
|
||||
}
|
||||
if (siteSettings.siteLogo) {
|
||||
teams[0].logo = siteSettings.siteLogo
|
||||
}
|
||||
// 监听 logo 变化
|
||||
watch(currentLogo, (newLogo) => {
|
||||
teams[0].logo = newLogo
|
||||
}, { immediate: true })
|
||||
|
||||
onMounted(() => {
|
||||
const storedUser = localStorage.getItem('user')
|
||||
@@ -62,9 +65,6 @@ onMounted(() => {
|
||||
}
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
})
|
||||
|
||||
const navMain = computed(() => [
|
||||
{
|
||||
title: t('nav.mainFeatures'),
|
||||
|
||||
Reference in New Issue
Block a user