refactor: 重组 components/ 和 pages/ 文件结构,按职责分层

components/ 拆为三层:
  - providers/   — 状态管理(App/Theme/SettingsProvider)
  - shell/       — 应用外壳(Layout/NavBar/PageDispatcher)
  - ui/          — 通用 UI 原子(FloatingPanel/LegalTextModal)

pages/ 重命名 + 重组:
  - headers/ → panels/        NavBar 触发的面板页
  - login/   → auth/          认证模块(含注册/忘记密码)
  - settings/blocks/ → sections/
  - home/components/ → panels/ features/ controls/ hooks/
    按职责分:panels(布局壳) + features(功能面板) + controls(表单控件) + hooks

其他清理:
  - 删除空占位 Test3.tsx
  - HomeContext 从 HomeContent 拆出独立文件
  - uploadValidation 内联到 ImageInput
  - 修复过时注释(useUI → controls)
This commit is contained in:
2026-06-15 11:19:06 +08:00
parent bc33b81121
commit 0e6d996718
63 changed files with 123 additions and 123 deletions

View File

@@ -0,0 +1,55 @@
// ============================================================
// controls/index.ts — Widget 注册表
//
// 职责:
// 1. 定义 WidgetProps 统一接口
// 2. 维护 Qt 控件名 → React 组件的 WIDGET_MAP 映射
// 3. 导出 WidgetType 联合类型供外部使用
//
// 新增控件类型只需两步:
// ① 在 controls/ 下创建组件文件
// ② 在 WIDGET_MAP 中加一行
// ============================================================
import type { ComponentType } from 'react';
import type { WidgetProps } from './types';
import { TextInput } from './TextInput';
import { LineInput } from './LineInput';
import { ComboBox } from './ComboBox';
import { Checkbox } from './Checkbox';
import { SpinBox } from './SpinBox';
import { DoubleSpinBox } from './DoubleSpinBox';
import { ImageInput } from './ImageInput';
import { ImageListInput } from './ImageListInput';
import { AudioListInput } from './AudioListInput';
import { SeedanceContent } from './SeedanceContent';
export type { WidgetProps } from './types';
// ---------- 注册表 ----------
/**
* Qt 控件名 → React 组件的映射表。
*
* 键来自 API param_schema[].ui.widget 字段(原 Python Qt 客户端的组件类名),
* 值为 useUI/ 下的对应 React 组件。
*/
export const WIDGET_MAP: Record<string, ComponentType<WidgetProps>> = {
textEdit: TextInput,
lineEdit: LineInput,
comboBox: ComboBox,
checkbox: Checkbox,
spinBox: SpinBox,
doubleSpinBox: DoubleSpinBox,
imageInput: ImageInput,
imageList: ImageListInput,
audioList: AudioListInput,
seedance2Content: SeedanceContent,
};
/** 已知的 widget 类型字面量联合 */
export type WidgetType = keyof typeof WIDGET_MAP;
/** 未知控件类型的兜底组件(渲染为普通 Input */
export const FALLBACK_WIDGET: ComponentType<WidgetProps> = LineInput;