From 86a1a3369371a96c670a69cc92b4314758e765fb Mon Sep 17 00:00:00 2001 From: db_huang <18006480240@163.com> Date: Fri, 18 Sep 2026 18:08:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=94=B9=E4=B8=BA=E9=BB=8F=E8=B4=B4=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/CreateAskTasksPage.jsx | 45 +++++++++++++++++++++++++++-- frontend/src/TaskBoardPage.jsx | 13 +++++++++ frontend/src/admin.css | 19 ++++++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/frontend/src/CreateAskTasksPage.jsx b/frontend/src/CreateAskTasksPage.jsx index 599d8a9..878b95f 100644 --- a/frontend/src/CreateAskTasksPage.jsx +++ b/frontend/src/CreateAskTasksPage.jsx @@ -79,6 +79,7 @@ export default function CreateAskTasksPage({ api, librarySelection = [], onLibra const [addDialog, setAddDialog] = useState(null); const [publishOpen, setPublishOpen] = useState(false); const [linkCopied, setLinkCopied] = useState(false); + const productQrPasteRef = useRef(null); const processingLibrarySelection = useRef(false); const consumedLibrarySelectionKey = useRef(""); useEffect(() => { @@ -160,6 +161,35 @@ export default function CreateAskTasksPage({ api, librarySelection = [], onLibra if (productQrInputRef.current) productQrInputRef.current.value = ""; } + useEffect(() => { + if (!publishOpen) return undefined; + const pasteProductQr = (event) => { + const imageItem = Array.from(event.clipboardData?.items || []).find((item) => + item.kind === "file" && item.type.startsWith("image/"), + ); + if (!imageItem) return; + const blob = imageItem.getAsFile?.(); + if (!blob) { + setError("读取剪贴板图片失败,请重新复制后再试"); + return; + } + const extension = blob.type === "image/jpeg" ? "jpg" : blob.type.split("/")[1] || "png"; + const pastedFile = new File( + [blob], + `product-qr-${Date.now()}.${extension}`, + { type: blob.type, lastModified: Date.now() }, + ); + event.preventDefault(); + selectProductQr(pastedFile); + }; + window.addEventListener("paste", pasteProductQr); + const focusTimer = window.setTimeout(() => productQrPasteRef.current?.focus(), 0); + return () => { + window.clearTimeout(focusTimer); + window.removeEventListener("paste", pasteProductQr); + }; + }, [publishOpen]); + function clearAll() { if (busy) return; clearPageCache("create-ask-task"); @@ -814,12 +844,21 @@ export default function CreateAskTasksPage({ api, librarySelection = [], onLibra {form.product_qr_image ? (
商品二维码预览 -
{form.product_qr_image_name || "商品二维码"}已上传商品二维码
+
{form.product_qr_image_name || "商品二维码"}已上传商品二维码,可粘贴图片替换
) : ( - + )} - 淘口令和二维码至少填写一种,也可以两者都填写 + 淘口令和二维码至少填写一种,也可以两者都填写;复制二维码图片后可直接按 Ctrl+V 粘贴