feat: print includes answer only after unlocking solutions
- If solutions already unlocked (full mode), print button shows '打印题目+答案' - If not unlocked, print button shows '打印题目' (problem only) - No longer forces unlock when printing Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
这个提交包含在:
@@ -950,14 +950,18 @@ export default function ProblemDetailPage() {
|
||||
|
||||
const printProblemWithAnswer = async () => {
|
||||
let resolved = solutionData;
|
||||
if (resolved?.access?.mode !== "full") {
|
||||
const fetched = await loadSolutions("full");
|
||||
if (fetched) resolved = fetched;
|
||||
} else if ((resolved?.items.length ?? 0) === 0) {
|
||||
// If user has already unlocked solutions (full mode), use them directly
|
||||
if (resolved?.access?.mode === "full" && (resolved?.items.length ?? 0) > 0) {
|
||||
// Already have full solutions loaded — use as-is
|
||||
} else if (resolved?.access?.mode === "full") {
|
||||
// Full access but items not loaded yet — fetch
|
||||
const fetched = await loadSolutions("full");
|
||||
if (fetched) resolved = fetched;
|
||||
}
|
||||
setPrintAnswerMarkdown(buildPrintableAnswerMarkdown(resolved, tx));
|
||||
// If not in full mode, just print problem without answer
|
||||
setPrintAnswerMarkdown(
|
||||
resolved?.access?.mode === "full" ? buildPrintableAnswerMarkdown(resolved, tx) : ""
|
||||
);
|
||||
await new Promise<void>((resolve) => {
|
||||
window.requestAnimationFrame(() => {
|
||||
window.requestAnimationFrame(() => resolve());
|
||||
@@ -997,7 +1001,11 @@ export default function ProblemDetailPage() {
|
||||
onClick={() => void printProblemWithAnswer()}
|
||||
disabled={solutionLoading}
|
||||
>
|
||||
{solutionLoading ? tx("卷轴准备中...", "Scribing...") : tx("打印卷轴", "Scribe Scroll")}
|
||||
{solutionLoading
|
||||
? tx("卷轴准备中...", "Scribing...")
|
||||
: solutionData?.access?.mode === "full"
|
||||
? tx("🖨️ 打印题目+答案", "🖨️ Print with Answer")
|
||||
: tx("🖨️ 打印题目", "🖨️ Print Problem")}
|
||||
</button>
|
||||
<button
|
||||
className="mc-btn text-sm py-1"
|
||||
|
||||
在新工单中引用
屏蔽一个用户