mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
feat: 支持系统设置中自定义全站名称和副标题
新增 site_name 和 site_subtitle 两个系统配置项,允许管理员在后台自定义 站点品牌名称(默认 Aether)和副标题(默认 AI Gateway)。 - 后端:DEFAULT_CONFIGS 新增配置项,公开 /api/public/site-info 端点 - 后端:邮件发送 app_name 回退链增加 site_name - 前端:新增 useSiteInfo composable 全局缓存站点信息 - 前端:首页、后台布局、登录页、指南页面全部改为动态读取 - 前端:系统设置页新增「站点信息」配置区块 - 前端:配置导出文件名跟随站点名称 - 优化:请求失败允许重试,保存后即时生效无需刷新页面 - 优化:document.title 随站点名称动态更新 Closes #176 Co-authored-by: LewisPen <LewisPen@nyadoo.com>
This commit is contained in:
44
frontend/src/composables/useSiteInfo.ts
Normal file
44
frontend/src/composables/useSiteInfo.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { ref, watch } from 'vue'
|
||||
import apiClient from '@/api/client'
|
||||
|
||||
interface SiteInfo {
|
||||
site_name: string
|
||||
site_subtitle: string
|
||||
}
|
||||
|
||||
// 模块级缓存,所有组件共享同一份数据
|
||||
const siteName = ref('Aether')
|
||||
const siteSubtitle = ref('AI Gateway')
|
||||
const loaded = ref(false)
|
||||
let fetchPromise: Promise<void> | null = null
|
||||
|
||||
async function fetchSiteInfo() {
|
||||
try {
|
||||
const response = await apiClient.get<SiteInfo>('/api/public/site-info')
|
||||
siteName.value = response.data.site_name
|
||||
siteSubtitle.value = response.data.site_subtitle
|
||||
loaded.value = true
|
||||
} catch {
|
||||
// 加载失败时保持默认值,允许后续重试
|
||||
fetchPromise = null
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshSiteInfo() {
|
||||
fetchPromise = null
|
||||
loaded.value = false
|
||||
fetchPromise = fetchSiteInfo()
|
||||
await fetchPromise
|
||||
}
|
||||
|
||||
export function useSiteInfo() {
|
||||
if (!loaded.value && !fetchPromise) {
|
||||
fetchPromise = fetchSiteInfo()
|
||||
}
|
||||
return { siteName, siteSubtitle, refreshSiteInfo }
|
||||
}
|
||||
|
||||
// 站点名称变化时同步更新 document.title
|
||||
watch(siteName, (name) => {
|
||||
document.title = name
|
||||
}, { immediate: true })
|
||||
Reference in New Issue
Block a user