修复 UI 编辑器导入提交与恢复边界
为图片和远程素材导入增加服务端数量、单文件及批次总量上限 改为提交成功后推进项目 revision,并保留 reconciliation-required 结果 远程 IPC 改传签名地址并流式限量下载,UI State 使用稳定 previous 恢复副本
This commit is contained in:
@@ -8,7 +8,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
import {
|
||||
loadEditorAssetLibrary,
|
||||
readClientAssetBytes,
|
||||
resolveClientAssetReadUrl,
|
||||
} from '../../services/clientApi';
|
||||
import { ThemedModal } from '../modal/ThemedModal';
|
||||
import {
|
||||
@@ -223,8 +223,9 @@ export function AssetImporter({
|
||||
});
|
||||
const sourcePaths = Array.isArray(paths) ? paths : paths ? [paths] : [];
|
||||
if (!sourcePaths.length) return;
|
||||
if (sourcePaths.length > maxItems)
|
||||
if (sourcePaths.length > maxItems) {
|
||||
throw new Error(`最多选择 ${maxItems} 个文件`);
|
||||
}
|
||||
const result = await invoke<GenericImportResponse>(
|
||||
'import_ui_editor_assets',
|
||||
{
|
||||
@@ -271,18 +272,13 @@ export function AssetImporter({
|
||||
remoteAssets: await Promise.all(
|
||||
remoteChosen.map(async (item) => {
|
||||
const asset = item.asset!;
|
||||
const response = asset.localPath.startsWith('http')
|
||||
? await fetch(asset.localPath)
|
||||
: await readClientAssetBytes(asset.localPath);
|
||||
if (!response.ok)
|
||||
throw new Error(
|
||||
`读取平台素材失败(HTTP ${response.status})`,
|
||||
);
|
||||
const bytes = new Uint8Array(await response.arrayBuffer());
|
||||
const downloadUrl = asset.localPath.startsWith('http')
|
||||
? asset.localPath
|
||||
: await resolveClientAssetReadUrl(asset.localPath);
|
||||
return {
|
||||
assetId: asset.id,
|
||||
objectKey: asset.localPath,
|
||||
bytes: Array.from(bytes),
|
||||
downloadUrl,
|
||||
};
|
||||
}),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user