fix: 修复回填更新与截图刷新

This commit is contained in:
巫凤萍
2026-08-16 22:22:50 +08:00
parent 74671a9b9f
commit cac6c5e83b
5 changed files with 34 additions and 9 deletions

View File

@@ -186,7 +186,12 @@ async function handleGet(request: Request) {
}
const headers = new Headers();
object.writeHttpMetadata(headers);
headers.set("Cache-Control", "private, max-age=3600");
const isMutableEvidence =
imageKind === "publish" || imageKind === "creator";
headers.set(
"Cache-Control",
isMutableEvidence ? "private, no-store" : "private, max-age=3600",
);
if (imageKind === "video") {
headers.set("Content-Type", "video/mp4");
}

View File

@@ -1792,6 +1792,11 @@ footer {
font-weight: 620;
}
.toast.success {
color: var(--green-deep);
font-weight: 720;
}
.loading-shell {
display: flex;
align-items: center;

View File

@@ -127,6 +127,11 @@ function statusLabel(item: Assignment, taskType = "content_publish") {
}
const MAX_TASK_RESULT_SCREENSHOTS = 9;
const PUBLISH_BACKFILL_SUCCESS = "这篇笔记的发布记录回填成功啦~";
function toastClassName(message: string) {
return message === PUBLISH_BACKFILL_SUCCESS ? "toast success" : "toast";
}
function resultScreenshotKeys(value: string | null) {
const text = String(value ?? "").trim();
@@ -594,6 +599,11 @@ export default function Home() {
index: "1",
kind,
});
const evidenceKey =
kind === "publish"
? item.publish_screenshot_key
: item.creator_screenshot_key;
if (evidenceKey) params.set("v", evidenceKey);
if (delegationToken) params.set("share", delegationToken);
else {
params.set("task", taskToken);
@@ -1013,7 +1023,7 @@ export default function Home() {
});
}, 120);
}
setToast("这篇笔记已回填,不会与其他笔记错配");
setToast(PUBLISH_BACKFILL_SUCCESS);
} catch (reason) {
setToast(reason instanceof Error ? reason.message : "回填失败");
} finally {
@@ -1283,7 +1293,7 @@ export default function Home() {
</form>
</div>
<ImageLightbox image={previewImage} onClose={() => setPreviewImage(null)} />
{toast && <div className="toast">{toast}</div>}
{toast && <div className={toastClassName(toast)}>{toast}</div>}
</main>
);
}
@@ -1610,7 +1620,6 @@ export default function Home() {
value={creatorExposure}
onChange={(event) => setCreatorExposure(event.target.value)}
placeholder="填写截图中的曝光量"
required
/>
</label>
<label>
@@ -1624,7 +1633,6 @@ export default function Home() {
value={creatorViews}
onChange={(event) => setCreatorViews(event.target.value)}
placeholder="填写截图中的阅读量"
required
/>
</label>
</div>
@@ -1650,7 +1658,7 @@ export default function Home() {
</form>
</div>
<ImageLightbox image={previewImage} onClose={() => setPreviewImage(null)} />
{toast && <div className="toast">{toast}</div>}
{toast && <div className={toastClassName(toast)}>{toast}</div>}
</main>
);
}
@@ -1957,7 +1965,7 @@ export default function Home() {
? "请保存当前分享链接;完成任务后通过此链接上传截图即可。"
: "请保存当前分享链接发布后仍需通过此链接回填第7天截图、曝光量和阅读量。"}
</div>
{toast && <div className="toast">{toast}</div>}
{toast && <div className={toastClassName(toast)}>{toast}</div>}
</main>
);
}
@@ -2104,7 +2112,7 @@ export default function Home() {
<div><span>3</span><strong>{payload.task.type === "screenshot_collect" ? "上传截图" : "单篇回填"}</strong><p>{payload.task.type === "screenshot_collect" ? "每份任务与截图一一对应" : "昵称、链接、截图一一对应"}</p></div>
</section>
<footer> KOC LOOP </footer>
{toast && <div className="toast">{toast}</div>}
{toast && <div className={toastClassName(toast)}>{toast}</div>}
</main>
);
}

View File

@@ -70,7 +70,9 @@ test("keeps claiming minimal and backfill one-to-one", async () => {
assert.match(page, /找回领取记录/);
assert.match(page, /action:\s*"recover"/);
assert.match(page, /同一任务多次领取会分批展示/);
assert.match(page, /这篇笔记已回填,不会与其他笔记错配/);
assert.match(page, /这篇笔记的发布记录回填成功啦~/);
assert.match(page, /toastClassName\(toast\)/);
assert.match(styles, /\.toast\.success/);
assert.match(page, /笔记内容已收起/);
assert.match(page, /展开笔记内容/);
assert.match(page, /收起笔记内容/);
@@ -92,6 +94,7 @@ test("keeps claiming minimal and backfill one-to-one", async () => {
assert.match(page, /creatorViews/);
assert.match(page, /截图仅用于运营核对不再自动OCR/);
assert.match(page, /evidenceImageUrl/);
assert.match(page, /params\.set\("v", evidenceKey\)/);
assert.match(page, /evidenceImageUrl\(selected, "publish"\)/);
assert.match(page, /evidenceImageUrl\(selected, "creator"\)/);
assert.match(page, /ImageLightbox/);
@@ -100,6 +103,8 @@ test("keeps claiming minimal and backfill one-to-one", async () => {
assert.match(page, /creatorScreenshotPreview/);
assert.match(page, /曝光量/);
assert.match(page, /阅读量/);
assert.match(page, /placeholder="填写截图中的曝光量"\s*\/>/);
assert.match(page, /placeholder="填写截图中的阅读量"\s*\/>/);
assert.doesNotMatch(page, /recognizeCreatorMetrics/);
assert.match(page, /note-index \$\{\(isScreenshotTask \? item\.result_submitted_at : item\.publish_url\) \? "done" : ""\}/);
assert.match(packageJson, /"fflate":\s*"0\.7\.4"/);

View File

@@ -200,6 +200,8 @@ test("issues external task links and supports one-to-one note submissions", asyn
assert.match(imageRoute, /creator-center\//);
assert.match(imageRoute, /imageKind === "publish"/);
assert.match(imageRoute, /imageKind === "creator"/);
assert.match(imageRoute, /isMutableEvidence/);
assert.match(imageRoute, /"private, no-store"/);
assert.match(imageRoute, /Content-Type", "video\/mp4"/);
assert.match(imageRoute, /video-\$\{imageIndex\}\.mp4/);
assert.match(imageRoute, /downloadRequested \? "attachment" : "inline"/);