Add corrected image generation
这个提交包含在:
@@ -14,6 +14,8 @@ type AssignmentSummary = {
|
||||
score: number;
|
||||
imagePath?: string;
|
||||
imagePaths?: string[];
|
||||
correctedImagePath?: string;
|
||||
correctedImagePaths?: string[];
|
||||
createdAt: string;
|
||||
};
|
||||
|
||||
@@ -23,6 +25,8 @@ type AssignmentDetail = AssignmentSummary & {
|
||||
feedback: string;
|
||||
imagePath?: string;
|
||||
imagePaths?: string[];
|
||||
correctedImagePath?: string;
|
||||
correctedImagePaths?: string[];
|
||||
};
|
||||
|
||||
type ImageItem = {
|
||||
@@ -394,9 +398,15 @@ export default function HomePage() {
|
||||
const imageUrlFor = (id: number, index = 0) =>
|
||||
`${apiBase}/assignments/${id}/image?username=${encodeURIComponent(savedUser)}&index=${index}`;
|
||||
|
||||
const correctedImageUrlFor = (id: number, index = 0) =>
|
||||
`${apiBase}/assignments/${id}/corrected?username=${encodeURIComponent(savedUser)}&index=${index}`;
|
||||
|
||||
const imageCountFor = (item: AssignmentSummary) =>
|
||||
item.imagePaths?.length ?? (item.imagePath ? 1 : 0);
|
||||
|
||||
const correctedImageCountFor = (item: AssignmentSummary) =>
|
||||
item.correctedImagePaths?.length ?? (item.correctedImagePath ? 1 : 0);
|
||||
|
||||
const selectedImagePaths =
|
||||
selected?.imagePaths && selected.imagePaths.length > 0
|
||||
? selected.imagePaths
|
||||
@@ -404,6 +414,13 @@ export default function HomePage() {
|
||||
? [selected.imagePath]
|
||||
: [];
|
||||
|
||||
const selectedCorrectedPaths =
|
||||
selected?.correctedImagePaths && selected.correctedImagePaths.length > 0
|
||||
? selected.correctedImagePaths
|
||||
: selected?.correctedImagePath
|
||||
? [selected.correctedImagePath]
|
||||
: [];
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="page">
|
||||
@@ -574,6 +591,19 @@ export default function HomePage() {
|
||||
保存图片{imageCountFor(item) > 1 ? ` (${imageCountFor(item)}张)` : ""}
|
||||
</a>
|
||||
)}
|
||||
{correctedImageCountFor(item) > 0 && (
|
||||
<a
|
||||
className="button secondary"
|
||||
href={correctedImageUrlFor(item.id, 0)}
|
||||
download={`assignment-${item.id}-corrected-1.jpg`}
|
||||
onClick={(event) => event.stopPropagation()}
|
||||
>
|
||||
保存订正图
|
||||
{correctedImageCountFor(item) > 1
|
||||
? ` (${correctedImageCountFor(item)}张)`
|
||||
: ""}
|
||||
</a>
|
||||
)}
|
||||
<button
|
||||
className="button secondary"
|
||||
onClick={(event) => {
|
||||
@@ -636,6 +666,31 @@ export default function HomePage() {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{selectedCorrectedPaths.length > 0 && (
|
||||
<div style={{ display: "grid", gap: 12 }}>
|
||||
<div className="assignment-meta">
|
||||
<span>订正效果图(共 {selectedCorrectedPaths.length} 张)</span>
|
||||
</div>
|
||||
<div className="image-grid">
|
||||
{selectedCorrectedPaths.map((_, index) => (
|
||||
<div key={`${selected.id}-corrected-${index}`} className="image-card">
|
||||
<img
|
||||
className="preview"
|
||||
src={correctedImageUrlFor(selected.id, index)}
|
||||
alt={`订正图 ${index + 1}`}
|
||||
/>
|
||||
<a
|
||||
className="button secondary"
|
||||
href={correctedImageUrlFor(selected.id, index)}
|
||||
download={`assignment-${selected.id}-corrected-${index + 1}.jpg`}
|
||||
>
|
||||
保存订正第 {index + 1} 张
|
||||
</a>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="markdown">
|
||||
<ReactMarkdown>{selected.markdown}</ReactMarkdown>
|
||||
</div>
|
||||
|
||||
在新工单中引用
屏蔽一个用户