品牌化设置 + Claude米色衬线体主题 + 全站中文
- 品牌设置API: GET/PUT /api/settings/brand (名称/标语/Logo) - 管理页系统设置: 品牌编辑器表单(名称/标语/Logo URL) - 恢复Anthropic风格: 米色(#FBF9F6) 底色, Source Serif 4 + Noto Serif SC 衬线体 - 暖棕(#C2693A) 主色调, 更充裕的间距与留白, 庄重大气 - 全站中文: antd zhCN locale, 所有页面文本汉化 - 数据存储在 Config singleton, 运行时更新
This commit is contained in:
1 parent
409e5d314e
commit
efde5597bd
16 files changed
+403
-672
No files matched your search
@@ -1,27 +1,28 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import {
|
||||
Card, Select, Switch, Typography, message, Space, Descriptions, Button,
|
||||
} from 'antd'
|
||||
import { Card, Select, Switch, Form, Input, Button, Typography, message, Divider } from 'antd'
|
||||
import api from '../../api/client'
|
||||
|
||||
const { Title } = Typography
|
||||
const { Title, Text } = Typography
|
||||
|
||||
const strategies = [
|
||||
{ value: 'subnet', label: 'Subnet-Aware (Recommended)' },
|
||||
{ value: 'weighted', label: 'Weighted' },
|
||||
{ value: 'round-robin', label: 'Round-Robin' },
|
||||
{ value: 'least-conn', label: 'Least Connections' },
|
||||
{ value: 'subnet', label: '子网优先(推荐)' },
|
||||
{ value: 'weighted', label: '权重均衡' },
|
||||
{ value: 'round-robin', label: '轮询' },
|
||||
{ value: 'least-conn', label: '最少连接' },
|
||||
]
|
||||
|
||||
export default function SettingsPage() {
|
||||
const [strategy, setStrategy] = useState('weighted')
|
||||
const [strategy, setStrategy] = useState('subnet')
|
||||
const [multicastEnabled, setMulticastEnabled] = useState(true)
|
||||
const [multicastAvailable, setMulticastAvailable] = useState(false)
|
||||
const [saving, setSaving] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
loadSettings()
|
||||
}, [])
|
||||
const [brandName, setBrandName] = useState('StreamCore')
|
||||
const [brandTagline, setBrandTagline] = useState('企业级直播平台')
|
||||
const [brandLogoUrl, setBrandLogoUrl] = useState('')
|
||||
const [brandSaving, setBrandSaving] = useState(false)
|
||||
|
||||
useEffect(() => { loadSettings(); loadBrand() }, [])
|
||||
|
||||
async function loadSettings() {
|
||||
try {
|
||||
@@ -29,56 +30,70 @@ export default function SettingsPage() {
|
||||
setStrategy(data.strategy)
|
||||
setMulticastEnabled(data.multicast_enabled)
|
||||
setMulticastAvailable(data.multicast_available)
|
||||
} catch { /* ignore */ }
|
||||
} catch { /* */ }
|
||||
}
|
||||
async function loadBrand() {
|
||||
try {
|
||||
const { data } = await api.get('/settings/brand')
|
||||
setBrandName(data.brand_name || 'StreamCore')
|
||||
setBrandTagline(data.brand_tagline || '')
|
||||
setBrandLogoUrl(data.brand_logo_url || '')
|
||||
} catch { /* */ }
|
||||
}
|
||||
|
||||
async function saveStrategy(val: string) {
|
||||
setSaving(true)
|
||||
try {
|
||||
await api.put('/nodes/strategy', { strategy: val, multicast_enabled: multicastEnabled })
|
||||
setStrategy(val)
|
||||
message.success('Strategy updated')
|
||||
} catch { message.error('Update failed') }
|
||||
try { await api.put('/nodes/strategy', { strategy: val, multicast_enabled: multicastEnabled }); setStrategy(val); message.success('策略已更新') }
|
||||
catch { message.error('更新失败') }
|
||||
setSaving(false)
|
||||
}
|
||||
|
||||
async function toggleMulticast(val: boolean) {
|
||||
setMulticastEnabled(val)
|
||||
try { await api.put('/nodes/strategy', { strategy, multicast_enabled: val }); message.success('组播设置已更新') }
|
||||
catch { message.error('更新失败') }
|
||||
}
|
||||
async function saveBrand() {
|
||||
setBrandSaving(true)
|
||||
try {
|
||||
await api.put('/nodes/strategy', { strategy, multicast_enabled: val })
|
||||
message.success('Multicast settings updated')
|
||||
} catch { message.error('Update failed') }
|
||||
await api.put('/settings/brand', { brand_name: brandName, brand_tagline: brandTagline, brand_logo_url: brandLogoUrl })
|
||||
message.success('品牌设置已保存')
|
||||
} catch { message.error('保存失败') }
|
||||
setBrandSaving(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ maxWidth: 720 }}>
|
||||
<Title level={3} style={{ marginBottom: 24, fontWeight: 600 }}>System Settings</Title>
|
||||
<Title level={3} style={{ marginBottom: 24 }}>系统设置</Title>
|
||||
|
||||
<Card title="Load Balancing" style={{ marginBottom: 24, borderRadius: 12 }}>
|
||||
<Descriptions column={1} labelStyle={{ width: 120 }}>
|
||||
<Descriptions.Item label="Strategy">
|
||||
<Select
|
||||
value={strategy}
|
||||
onChange={saveStrategy}
|
||||
options={strategies}
|
||||
loading={saving}
|
||||
style={{ width: 280 }}
|
||||
/>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Card title="负载均衡" style={{ marginBottom: 24, borderRadius: 10 }}>
|
||||
<Form layout="vertical">
|
||||
<Form.Item label="均衡策略" help="子网优先:根据客户端IP所属子网自动选择最近节点">
|
||||
<Select value={strategy} onChange={saveStrategy} options={strategies} loading={saving} style={{ width: 280 }} />
|
||||
</Form.Item>
|
||||
<Form.Item label="组播">
|
||||
<Switch checked={multicastEnabled} onChange={toggleMulticast} />
|
||||
<Text type="secondary" style={{ marginLeft: 12 }}>
|
||||
{multicastAvailable ? '可用 — 优先使用组播分发' : '不可用 — 回退至单播'}
|
||||
</Text>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
<Card title="Multicast" style={{ borderRadius: 12 }}>
|
||||
<Descriptions column={1} labelStyle={{ width: 120 }}>
|
||||
<Descriptions.Item label="Enable">
|
||||
<Switch checked={multicastEnabled} onChange={toggleMulticast} />
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="Network Status">
|
||||
<span style={{ color: multicastAvailable ? '#2E7D32' : '#999' }}>
|
||||
{multicastAvailable ? 'Available - using multicast' : 'Unavailable - fallback to unicast'}
|
||||
</span>
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
<Card title="品牌设置" style={{ borderRadius: 10 }}>
|
||||
<Form layout="vertical">
|
||||
<Form.Item label="平台名称">
|
||||
<Input value={brandName} onChange={e => setBrandName(e.target.value)} placeholder="StreamCore" />
|
||||
</Form.Item>
|
||||
<Form.Item label="标语">
|
||||
<Input value={brandTagline} onChange={e => setBrandTagline(e.target.value)} placeholder="企业级直播平台" />
|
||||
</Form.Item>
|
||||
<Form.Item label="Logo 图片地址">
|
||||
<Input value={brandLogoUrl} onChange={e => setBrandLogoUrl(e.target.value)} placeholder="https://..." />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" loading={brandSaving} onClick={saveBrand}>保存品牌设置</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Card>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user