|
|
1 week ago | |
|---|---|---|
| .. | ||
| hooks | 2 months ago | |
| sections | 1 week ago | |
| README.md | 2 months ago | |
| SettingsContent.tsx | 2 months ago | |
| SettingsModal.tsx | 2 weeks ago | |
| SettingsSidebar.tsx | 2 months ago | |
| SettingsTabs.tsx | 2 months ago | |
| config.tsx | 1 week ago | |
| constants.ts | 2 months ago | |
| index.tsx | 2 months ago | |
| types.ts | 2 months ago | |
系统设置模块提供了一个响应式的设置界面,支持 Electron、浏览器和移动端三端适配。
┌─────────────────────────────────────────────┐
│ Modal (1200px) │
├──────────┬──────────────────────────────────┤
│ │ │
│ Sidebar │ Content Area │
│ (240px) │ (Flexible) │
│ │ │
│ Menu │ Section Component │
│ │ │
└──────────┴──────────────────────────────────┘
┌─────────────────────────────────────────────┐
│ Drawer (100%) │
├─────────────────────────────────────────────┤
│ Tabs (48px height) │
├─────────────────────────────────────────────┤
│ │
│ Content Area │
│ (Flexible height) │
│ │
│ - List of Sections (Category view) │
│ OR │
│ - Section Component (Detail view) │
│ │
└─────────────────────────────────────────────┘
SettingsModal/
├── index.tsx # 入口文件
├── SettingsModal.tsx # 主容器组件
├── SettingsSidebar.tsx # 桌面端侧边导航
├── SettingsTabs.tsx # 移动端标签导航
├── SettingsContent.tsx # 内容区域
├── types.ts # 类型定义
├── config.tsx # 配置文件
├── constants.ts # 常量定义
├── hooks/
│ └── useResponsive.ts # 响应式检测 Hook
└── sections/ # 各设置分区组件
├── PlaceholderSection.tsx
├── SystemHome/
├── Preferences/
├── Hardware/
├── Network/
├── Protocol/
└── Statistics/
import React, { useState } from 'react';
import { Button } from 'antd';
import SettingsModal from '@/pages/system/SettingsModal';
function App() {
const [visible, setVisible] = useState(false);
return (
<>
<Button onClick={() => setVisible(true)}>
打开系统设置
</Button>
<SettingsModal
visible={visible}
onClose={() => setVisible(false)}
/>
</>
);
}
<SettingsModal
visible={visible}
onClose={() => setVisible(false)}
defaultCategory="hardware"
defaultSection="camera"
/>
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| visible | boolean | false | 是否显示设置模态框 |
| onClose | () => void | - | 关闭回调函数 |
| defaultCategory | string | - | 默认显示的一级分类 ID |
| defaultSection | string | - | 默认显示的二级分区 ID |
在 sections/ 目录下的对应分类文件中添加:
// sections/SystemHome/index.tsx
export const NewSetting: React.FC = () => (
<div style={{ padding: 24 }}>
<h2>新设置项</h2>
{/* 你的设置内容 */}
</div>
);
在 config.tsx 中添加到对应分类的 sections 数组:
{
id: 'system-home',
title: '系统之家',
icon: <HomeOutlined />,
sections: [
// ... 其他设置项
{
id: 'new-setting',
title: '新设置项',
component: SystemHome.NewSetting,
},
],
}
system-home, preferences, hardware 等site-info, user-account 等在 constants.ts 中配置:
export const BREAKPOINTS = {
MOBILE: 768, // < 768px 为移动端
TABLET: 1024, // < 1024px 为平板端
}
当您提供具体的二级布局内容图片后,我会为每个设置项创建详细的设计文档,包括:
destroyOnClose,关闭时会销毁内部状态