|
@@ -914,11 +914,11 @@ const ProjectDetail = () => {
|
914
|
914
|
console.log(`当前已完成的图片数量: ${existingCompletedCount}`);
|
915
|
915
|
setCompletedDrawings(existingCompletedCount);
|
916
|
916
|
|
917
|
|
- if (isForceRedraw) {
|
|
917
|
+ if (isForceRedraw) {
|
918
|
918
|
// 重绘:处理所有有描述词的分镜
|
919
|
|
- const segmentsToRedraw = segments.filter(
|
920
|
|
- segment => segment.description && segment.description.trim() !== ''
|
921
|
|
- );
|
|
919
|
+ const segmentsToRedraw = segments.filter(
|
|
920
|
+ segment => segment.description && segment.description.trim() !== ''
|
|
921
|
+ );
|
922
|
922
|
|
923
|
923
|
console.log(`重绘: 选择${segmentsToRedraw.length}个有描述词的分镜`);
|
924
|
924
|
|
|
@@ -952,7 +952,8 @@ const ProjectDetail = () => {
|
952
|
952
|
const segmentsToQueue = segments.filter(
|
953
|
953
|
segment => segment.description &&
|
954
|
954
|
segment.description.trim() !== '' &&
|
955
|
|
- !segment.image_path
|
|
955
|
+ !segment.image_path &&
|
|
956
|
+ segment.draw_status !== 2 // 确保不是已完成状态
|
956
|
957
|
);
|
957
|
958
|
|
958
|
959
|
console.log(`继续绘画: 选择${segmentsToQueue.length}个有描述词但没有图片的分镜`);
|
|
@@ -961,8 +962,8 @@ const ProjectDetail = () => {
|
961
|
962
|
if (segmentsToQueue.length === 0) {
|
962
|
963
|
toast.info('没有需要绘制的分镜');
|
963
|
964
|
setIsGenerating(false);
|
964
|
|
- return;
|
965
|
|
- }
|
|
965
|
+ return;
|
|
966
|
+ }
|
966
|
967
|
|
967
|
968
|
// 更新所有需要处理的分镜状态为排队状态
|
968
|
969
|
await Promise.all(segmentsToQueue.map(segment =>
|
|
@@ -977,7 +978,6 @@ const ProjectDetail = () => {
|
977
|
978
|
// 计算总进度
|
978
|
979
|
const totalSegmentsToProcess = segmentsToProcess.length;
|
979
|
980
|
setTotalDrawableSegments(totalSegmentsToProcess);
|
980
|
|
- setCompletedDrawings(0);
|
981
|
981
|
|
982
|
982
|
// 设置UI状态
|
983
|
983
|
setGeneratingImages(true);
|
|
@@ -1044,15 +1044,15 @@ const ProjectDetail = () => {
|
1044
|
1044
|
});
|
1045
|
1045
|
|
1046
|
1046
|
// 调用API生成图片
|
1047
|
|
- const response = await cozeInstance.generateImage(
|
1048
|
|
- segment.description, // 描述词作为prompt
|
1049
|
|
- selectedStyle, // 项目设置的画风
|
1050
|
|
- {
|
1051
|
|
- width: 1024,
|
1052
|
|
- height: 1024,
|
1053
|
|
- num_images: 1
|
1054
|
|
- }
|
1055
|
|
- );
|
|
1047
|
+ const response = await cozeInstance.generateImage(
|
|
1048
|
+ segment.description, // 描述词作为prompt
|
|
1049
|
+ selectedStyle, // 项目设置的画风
|
|
1050
|
+ {
|
|
1051
|
+ width: 1024,
|
|
1052
|
+ height: 1024,
|
|
1053
|
+ num_images: 1
|
|
1054
|
+ }
|
|
1055
|
+ );
|
1056
|
1056
|
|
1057
|
1057
|
// 每次API调用后检查是否被暂停
|
1058
|
1058
|
const statusAfterAPI = await checkGenerationStatus();
|
|
@@ -1085,7 +1085,7 @@ const ProjectDetail = () => {
|
1085
|
1085
|
console.log(`分镜ID ${segment.id} 的图片生成成功: ${imagePath}`);
|
1086
|
1086
|
successCount++;
|
1087
|
1087
|
|
1088
|
|
- // 更新处理进度 - 修复进度计算问题
|
|
1088
|
+ // 更新处理进度
|
1089
|
1089
|
setCompletedDrawings(prevCount => {
|
1090
|
1090
|
const newCount = prevCount + 1;
|
1091
|
1091
|
console.log(`已完成图片数量更新:${prevCount} -> ${newCount}`);
|
|
@@ -1129,7 +1129,7 @@ const ProjectDetail = () => {
|
1129
|
1129
|
console.error(`处理分镜ID ${segment.id} 时出错:`, error);
|
1130
|
1130
|
|
1131
|
1131
|
// 将状态设回排队,允许重试
|
1132
|
|
- await bookInfoService.updateBookInfo(segment.id, {
|
|
1132
|
+ await bookInfoService.updateBookInfo(segment.id, {
|
1133
|
1133
|
draw_status: 0
|
1134
|
1134
|
});
|
1135
|
1135
|
}
|
|
@@ -1159,10 +1159,6 @@ const ProjectDetail = () => {
|
1159
|
1159
|
toast.warning(`图片生成结束,成功${successCount}张,失败${errorCount}张`);
|
1160
|
1160
|
}
|
1161
|
1161
|
}
|
1162
|
|
-
|
1163
|
|
- // 最后刷新项目数据
|
1164
|
|
- await loadProjectDetail(true);
|
1165
|
|
-
|
1166
|
1162
|
} catch (error) {
|
1167
|
1163
|
console.error('批量生成图片过程中发生错误:', error);
|
1168
|
1164
|
toast.error('图片生成失败: ' + error.message);
|