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)
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
// ============================================================
|
||
// ImageListInput — imageList → Dragger(多张图片拖拽上传)
|
||
// 用于图生图模型的多图输入场景
|
||
// ============================================================
|
||
|
||
import { Upload } from 'antd';
|
||
import { InboxOutlined } from '@ant-design/icons';
|
||
import type { UploadFile } from 'antd/es/upload';
|
||
import type { WidgetProps } from './types';
|
||
import { createImageBeforeUpload } from './ImageInput';
|
||
import { useFileUpload } from '@/hooks/use-api';
|
||
|
||
const { Dragger } = Upload;
|
||
|
||
export function ImageListInput({ value, onChange, disabled, config }: WidgetProps) {
|
||
const fileList = (value as UploadFile[]) || [];
|
||
const maxSizeMb = (config.maxFileSizeMb as number) || 10;
|
||
const maxCount = (config.maxFiles as number) || 10;
|
||
const filters = config.fileFilter as string[] | undefined;
|
||
|
||
const { customRequest } = useFileUpload();
|
||
|
||
return (
|
||
<Dragger
|
||
multiple
|
||
listType="picture"
|
||
accept={
|
||
filters
|
||
? filters.map((ext) => `image/${ext}`).join(',')
|
||
: 'image/png,image/jpg,image/jpeg,image/webp'
|
||
}
|
||
fileList={fileList}
|
||
customRequest={customRequest}
|
||
onChange={({ fileList: newList }) => onChange?.(newList)}
|
||
disabled={disabled}
|
||
beforeUpload={createImageBeforeUpload(maxSizeMb)}
|
||
maxCount={maxCount}
|
||
>
|
||
<p className="ant-upload-drag-icon">
|
||
<InboxOutlined />
|
||
</p>
|
||
<p className="ant-upload-text">点击或拖拽图片到此区域上传</p>
|
||
<p className="ant-upload-hint">
|
||
支持 {filters?.join(' / ').toUpperCase() || 'PNG / JPG / WebP'}
|
||
,单张不超过 {maxSizeMb}MB
|
||
</p>
|
||
</Dragger>
|
||
);
|
||
}
|