|
@@ -132,8 +132,10 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
let rawTask = {} as Task;
|
|
|
let trackData = [] as TrackItemType[];
|
|
|
let originImgs = [] as ImageItem[];
|
|
|
+ let trackFiles = [] as ImageItem[];
|
|
|
let curStudentId = '';
|
|
|
- const isOnlyOrigin = checkOnlyOrigin();
|
|
|
+ const hasOrigin = trackConfig.pictureType.includes('origin');
|
|
|
+ const hasTrack = trackConfig.pictureType.includes('track');
|
|
|
const hasPdf = trackConfig.pictureType.includes('pdf');
|
|
|
|
|
|
const defaultColorConfig = {
|
|
@@ -167,21 +169,22 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
addLog(`[${curStudentId}] 02-获取任务数据成功`);
|
|
|
|
|
|
originImgs = await downloadImages(rawTask.sheetUrls);
|
|
|
- if (isOnlyOrigin) {
|
|
|
- return true;
|
|
|
- }
|
|
|
addLog(`[${curStudentId}] 02-1-图片下载成功`);
|
|
|
|
|
|
- await parseDrawList();
|
|
|
- addLog(`[${curStudentId}] 03-解析绘制数据成功`);
|
|
|
+ if (hasTrack || hasPdf) {
|
|
|
+ await parseDrawList();
|
|
|
+ addLog(`[${curStudentId}] 03-解析绘制数据成功`);
|
|
|
|
|
|
- const trackFiles = await drawTask();
|
|
|
- addLog(`[${curStudentId}] 04-绘制成功`);
|
|
|
+ trackFiles = await drawTask();
|
|
|
+ addLog(`[${curStudentId}] 04-绘制成功`);
|
|
|
|
|
|
- if (hasPdf) {
|
|
|
- await window.api.imagesToPdf(trackFiles, getOutputPath('pdf'));
|
|
|
- addLog(`[${curStudentId}] 05-生成pdf成功`);
|
|
|
+ if (hasPdf) {
|
|
|
+ await window.api.imagesToPdf(trackFiles, getOutputPath('pdf'));
|
|
|
+ addLog(`[${curStudentId}] 05-生成pdf成功`);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ clearResult();
|
|
|
} catch (error) {
|
|
|
const e = error as Error;
|
|
|
console.log(e);
|
|
@@ -211,14 +214,17 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
trackData = [] as TrackItemType[];
|
|
|
answerMap = {} as AnswerMap;
|
|
|
originImgs = [] as ImageItem[];
|
|
|
+ trackFiles = [] as ImageItem[];
|
|
|
curStudentId = '';
|
|
|
}
|
|
|
|
|
|
- function checkOnlyOrigin() {
|
|
|
- return (
|
|
|
- trackConfig.pictureType.length === 1 &&
|
|
|
- trackConfig.pictureType[0] === 'origin'
|
|
|
- );
|
|
|
+ function clearResult() {
|
|
|
+ if (!hasOrigin) {
|
|
|
+ window.api.clearFilesSync(originImgs.map((item) => item.url));
|
|
|
+ }
|
|
|
+ if (!hasTrack && trackFiles.length) {
|
|
|
+ window.api.clearFilesSync(trackFiles.map((item) => item.url));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
async function getTaskData(studentId: string) {
|
|
@@ -229,7 +235,7 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
},
|
|
|
];
|
|
|
|
|
|
- if (!isOnlyOrigin) {
|
|
|
+ if (hasTrack || hasPdf) {
|
|
|
funcs.push(async () => {
|
|
|
// 获取客观题选项信息
|
|
|
const objectiveData = await studentObjectiveConfirmData(studentId);
|
|
@@ -271,6 +277,7 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
filename += `-${index}`;
|
|
|
}
|
|
|
filename += type === 'pdf' ? '.pdf' : '.jpg';
|
|
|
+
|
|
|
const paths = [
|
|
|
trackConfig.curOutputDir,
|
|
|
task.semesterName,
|
|
@@ -278,9 +285,14 @@ export default function useDraw(drawConfig: DrawConfig) {
|
|
|
`${rawTask.courseName}(${rawTask.courseCode})`,
|
|
|
rawTask.paperNumber,
|
|
|
taskDetail.className,
|
|
|
- PICTURE_TYPE[type],
|
|
|
- filename,
|
|
|
];
|
|
|
+ if (trackConfig.pictureType.includes(type)) {
|
|
|
+ paths.push(PICTURE_TYPE[type]);
|
|
|
+ } else {
|
|
|
+ filename = `${type}-${filename}`;
|
|
|
+ }
|
|
|
+ paths.push(filename);
|
|
|
+
|
|
|
return window.api.joinPath(paths);
|
|
|
}
|
|
|
|