[fix]:[FL-226][ATP模型上传支持目录]
恢复ATP模型上传时的目录选择功能,同时保持去掉提示信息的改动。 修改内容: - 恢复Upload组件的directory和multiple属性,允许用户选择文件夹 - 将按钮文本从"选择文件"改回"选择文件夹" - 恢复ZIP打包逻辑,将选中的文件夹内容打包成ZIP后上传 - 修复beforeUpload回调,使用prev => [...prev, file]累加文件而不是覆盖 技术细节: 后端upload_asset_files函数已支持ZIP文件自动解压(检测.zip扩展名), 因此前端需要将目录文件打包成ZIP上传,以保留目录结构。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -238,9 +238,14 @@ export default function AtpModelsPage() {
|
|||||||
|
|
||||||
if (values.files.length > 0) {
|
if (values.files.length > 0) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
const JSZip = (await import("jszip")).default;
|
||||||
|
const zip = new JSZip();
|
||||||
for (const file of values.files) {
|
for (const file of values.files) {
|
||||||
formData.append("files", file);
|
const path = (file as any).webkitRelativePath || file.name;
|
||||||
|
zip.file(path, file);
|
||||||
}
|
}
|
||||||
|
const zipBlob = await zip.generateAsync({ type: "blob" });
|
||||||
|
formData.append("files", zipBlob, "model.zip");
|
||||||
|
|
||||||
const uploadResponse = await fetchWithAuth(
|
const uploadResponse = await fetchWithAuth(
|
||||||
`/api/v1/atp/assets/${createdAsset.id}/files`,
|
`/api/v1/atp/assets/${createdAsset.id}/files`,
|
||||||
@@ -1124,12 +1129,14 @@ export default function AtpModelsPage() {
|
|||||||
<div>
|
<div>
|
||||||
<Upload
|
<Upload
|
||||||
beforeUpload={(file) => {
|
beforeUpload={(file) => {
|
||||||
setFileList([file]);
|
setFileList((prev) => [...prev, file]);
|
||||||
return false;
|
return false;
|
||||||
}}
|
}}
|
||||||
|
directory
|
||||||
|
multiple
|
||||||
showUploadList={false}
|
showUploadList={false}
|
||||||
>
|
>
|
||||||
<Button icon={<UploadOutlined />}>选择文件</Button>
|
<Button icon={<UploadOutlined />}>选择文件夹</Button>
|
||||||
</Upload>
|
</Upload>
|
||||||
{fileList.length > 0 && (
|
{fileList.length > 0 && (
|
||||||
<div style={{
|
<div style={{
|
||||||
|
|||||||
Reference in New Issue
Block a user