Skip to content

Commit 97077be

Browse files
committed
feat: add font size customization to settings and apply it in the main app layout
1 parent 977d541 commit 97077be

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

src/renderer/src/App.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,34 @@ import { ConfigProvider, theme, App as AntdApp } from 'antd'
33
import zhCN from 'antd/locale/zh_CN'
44
import Layout from './components/layout/Layout'
55
import { ZustandAppProvider } from './stores/ZustandAppContext'
6+
import { useSettingsStore } from './stores/settingsStore'
67
import './App.css'
78
import UpdateNotification from './components/common/UpdateNotification'
89

910
function AppContent(): React.JSX.Element {
11+
const { settings } = useSettingsStore()
12+
13+
// 根据字体大小设置获取基础字号
14+
const getFontSize = () => {
15+
switch (settings.fontSize) {
16+
case 'small':
17+
return 12
18+
case 'large':
19+
return 16
20+
case 'medium':
21+
default:
22+
return 14
23+
}
24+
}
25+
1026
return (
1127
<ConfigProvider
1228
locale={zhCN}
1329
theme={{
1430
algorithm: theme.defaultAlgorithm,
1531
token: {
16-
colorPrimary: '#1890ff'
32+
colorPrimary: '#1890ff',
33+
fontSize: getFontSize()
1734
}
1835
}}
1936
>

src/renderer/src/components/settings/AppearanceSettings.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import { Form, Select, Card } from 'antd'
33
import { FormInstance } from 'antd/lib/form'
4+
import { useSettingsStore } from '../../stores/settingsStore'
45

56
const { Option } = Select
67

@@ -9,10 +10,16 @@ interface AppearanceSettingsProps {
910
}
1011

1112
export default function AppearanceSettings({ form }: AppearanceSettingsProps) {
13+
const { setFontSize } = useSettingsStore()
14+
15+
const handleFontSizeChange = (value: 'small' | 'medium' | 'large') => {
16+
setFontSize(value)
17+
}
18+
1219
return (
1320
<Card size="small" title="外观设置">
1421
<Form.Item name="fontSize" label="字体大小">
15-
<Select>
22+
<Select onChange={handleFontSizeChange}>
1623
<Option value="small"></Option>
1724
<Option value="medium"></Option>
1825
<Option value="large"></Option>

0 commit comments

Comments
 (0)