From 669ca44360116871dd975ffab91b86ec2b12a659 Mon Sep 17 00:00:00 2001 From: iven Date: Fri, 1 May 2026 17:37:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20=E4=B8=BB=E9=A2=98=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=81=94=E5=8A=A8=20=E2=80=94=20=E6=89=A9=E5=B1=95=20?= =?UTF-8?q?ThemeConfig=20=E5=93=81=E7=89=8C=E5=AD=97=E6=AE=B5=20+=20?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ThemeConfig 接口增加 brand_name/brand_slogan/brand_features/brand_copyright - 新增 BrandConfig 接口和 getPublicBrand 公开品牌信息获取 - app store 增加 themeConfig 缓存和 loadThemeConfig 方法 - ThemeSettings 页面增加品牌设置表单(品牌名称/标语/特性/版权) --- apps/web/src/api/themes.ts | 27 ++++++++++++++ apps/web/src/pages/settings/ThemeSettings.tsx | 37 +++++++++++++++++-- apps/web/src/stores/app.ts | 11 ++++++ 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/apps/web/src/api/themes.ts b/apps/web/src/api/themes.ts index 3e02595..4ab075e 100644 --- a/apps/web/src/api/themes.ts +++ b/apps/web/src/api/themes.ts @@ -4,6 +4,10 @@ export interface ThemeConfig { primary_color?: string; logo_url?: string; sidebar_style?: 'light' | 'dark'; + brand_name?: string; + brand_slogan?: string; + brand_features?: string; + brand_copyright?: string; } export async function getTheme() { @@ -20,3 +24,26 @@ export async function updateTheme(theme: ThemeConfig) { ); return data.data; } + +export interface BrandConfig { + brand_name: string; + brand_slogan: string; + brand_features: string; + brand_copyright: string; +} + +const BRAND_DEFAULTS: BrandConfig = { + brand_name: 'HMS 健康管理平台', + brand_slogan: '新一代健康管理平台', + brand_features: '患者管理 · 健康监测 · 随访管理 · AI 智能分析', + brand_copyright: 'HMS 健康管理平台 · ©汕头市智界科技有限公司', +}; + +export async function getPublicBrand(): Promise { + try { + const res = await fetch('/api/v1/public/brand'); + const json = await res.json(); + if (json?.success && json?.data) return json.data; + } catch {} + return BRAND_DEFAULTS; +} diff --git a/apps/web/src/pages/settings/ThemeSettings.tsx b/apps/web/src/pages/settings/ThemeSettings.tsx index 8219f1e..d4795a7 100644 --- a/apps/web/src/pages/settings/ThemeSettings.tsx +++ b/apps/web/src/pages/settings/ThemeSettings.tsx @@ -1,12 +1,10 @@ import { useEffect, useState, useCallback } from 'react'; -import { Form, Input, Select, Button, ColorPicker, message, Typography } from 'antd'; +import { Form, Input, Select, Button, ColorPicker, message, Typography, Divider } from 'antd'; import { getTheme, updateTheme, } from '../../api/themes'; -// --- Component --- - export default function ThemeSettings() { const [form] = Form.useForm(); const [, setLoading] = useState(false); @@ -20,13 +18,20 @@ export default function ThemeSettings() { primary_color: theme.primary_color || '#1677ff', logo_url: theme.logo_url || '', sidebar_style: theme.sidebar_style || 'light', + brand_name: theme.brand_name || '', + brand_slogan: theme.brand_slogan || '', + brand_features: theme.brand_features || '', + brand_copyright: theme.brand_copyright || '', }); } catch { - // Theme may not exist yet; use defaults form.setFieldsValue({ primary_color: '#1677ff', logo_url: '', sidebar_style: 'light', + brand_name: '', + brand_slogan: '', + brand_features: '', + brand_copyright: '', }); } setLoading(false); @@ -40,6 +45,10 @@ export default function ThemeSettings() { primary_color: string; logo_url: string; sidebar_style: 'light' | 'dark'; + brand_name: string; + brand_slogan: string; + brand_features: string; + brand_copyright: string; }) => { setSaving(true); try { @@ -50,6 +59,10 @@ export default function ThemeSettings() { : (values.primary_color as { toHexString?: () => string }).toHexString?.() ?? String(values.primary_color), logo_url: values.logo_url, sidebar_style: values.sidebar_style, + brand_name: values.brand_name || undefined, + brand_slogan: values.brand_slogan || undefined, + brand_features: values.brand_features || undefined, + brand_copyright: values.brand_copyright || undefined, }); message.success('主题设置已保存'); } catch (err: unknown) { @@ -87,6 +100,22 @@ export default function ThemeSettings() { ]} /> + + 品牌设置 + + + + + + + + + + + + + +