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:
+5
-17
@@ -2,19 +2,18 @@
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<link rel="icon" type="image/svg+xml" media="(prefers-color-scheme: dark)" href="/logo.svg" />
|
||||
<link rel="icon" type="image/svg+xml" media="(prefers-color-scheme: light)" href="/logo-black.svg" />
|
||||
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>加载中...</title>
|
||||
<title>{{.SiteName}}</title>
|
||||
<meta name="description" content="{{.SiteDescription}}" />
|
||||
|
||||
<!-- Google Fonts - Inter -->
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
|
||||
<!-- 后端注入的系统配置(生产环境由后端渲染) -->
|
||||
<!-- 后端注入的系统配置 -->
|
||||
<script>
|
||||
// 后端渲染时会注入这些变量,开发环境使用默认值
|
||||
window.__SITE_CONFIG__ = {
|
||||
siteName: '{{.SiteName}}',
|
||||
siteDescription: '{{.SiteDescription}}',
|
||||
@@ -22,21 +21,10 @@
|
||||
logoDark: '{{.LogoDark}}',
|
||||
favicon: '{{.Favicon}}',
|
||||
};
|
||||
|
||||
// 检测是否是开发环境(模板变量未被替换)
|
||||
if (window.__SITE_CONFIG__.siteName.indexOf('{{') === 0) {
|
||||
window.__SITE_CONFIG__ = {
|
||||
siteName: '',
|
||||
siteDescription: '',
|
||||
logoLight: '',
|
||||
logoDark: '',
|
||||
favicon: '',
|
||||
};
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
Reference in New Issue
Block a user