feat(attach): 附件可配置限额、流式落盘与分阶段上传

管理端可配类型/体积;上传改流式避免整文件进内存;发帖先选再传并拦截未上传提交;提高 Next proxy 体积上限。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 07:33:16 +08:00
parent 6cc434f103
commit 61bf9fb48c
24 changed files with 2513 additions and 307 deletions

View File

@@ -47,6 +47,8 @@ type MarkdownEditorProps = {
disabled?: boolean;
onSubmitShortcut?: () => void;
id?: string;
/** 正文插图体积上限(MB),缺省 5 */
imageMaxMB?: number;
};
type EditorMode = "split" | "write" | "preview";
@@ -107,6 +109,7 @@ export default function MarkdownEditor({
disabled,
onSubmitShortcut,
id,
imageMaxMB = 5,
}: MarkdownEditorProps) {
const taRef = useRef<HTMLTextAreaElement>(null);
const fileRef = useRef<HTMLInputElement>(null);
@@ -227,8 +230,9 @@ export default function MarkdownEditor({
toast("仅支持 JPEG / PNG / WebP", "error");
return;
}
if (file.size > 5 * 1024 * 1024) {
toast("图片不能超过 5MB", "error");
const maxBytes = Math.max(1, imageMaxMB) * 1024 * 1024;
if (file.size > maxBytes) {
toast(`图片不能超过 ${imageMaxMB}MB`, "error");
return;
}
setUploading(true);