PRINTFILM: AI short-video marketing and AI short-drama creation platform
ui修改
增瑞 田7238e0ee5f9a
diff --git a/admin/src/features/marketplace/MarketplaceAdmin.tsx b/admin/src/features/marketplace/MarketplaceAdmin.tsxindex 668b423..6199c7e 100644--- a/admin/src/features/marketplace/MarketplaceAdmin.tsx+++ b/admin/src/features/marketplace/MarketplaceAdmin.tsx@@ -2,6 +2,7 @@ import CategoryForm from './CategoryForm'import { useEffect, useState, type FormEvent } from 'react'import { request, assetUrl, letterFile, useMarketplaceEnabled, type Item, type Listing } from './api'import { PaginationBar } from '@/components/PaginationBar'+import { AdminModal } from '@/components/admin/AdminModal'import { RefreshCw, Film, ShieldCheck, Users, Flag, CircleAlert, MessageCircle, Inbox } from 'lucide-react'import './marketplace-admin.css'@@ -34,19 +35,20 @@ function WorkPreviewLink({ id }: { id: number }) {function AuthorizationLink({ details }: { details: unknown }) {const id = details && typeof details === 'object' && 'authorization_id' in details ? Number(details.authorization_id) : 0const [preview, setPreview] = useState<{ url: string; image: boolean } | null>(null)+ const [open, setOpen] = useState(false)+ const [loading, setLoading] = useState(false)const [error, setError] = useState('')- useEffect(() => {- if (!id) return- let active = true- let objectUrl = ''- letterFile(id).then(blob => {- if (!active) return- objectUrl = URL.createObjectURL(blob)- setPreview({ url: objectUrl, image: blob.type.startsWith('image/') })- }).catch(e => { if (active) setError((e as Error).message) })- return () => { active = false; if (objectUrl) URL.revokeObjectURL(objectUrl) }- }, [id])+ useEffect(() => () => { if (preview?.url) URL.revokeObjectURL(preview.url) }, [preview?.url])if (!id) return null+ async function openLetter() {+ setLoading(true); setError('')+ try {+ const blob = await letterFile(id)+ const url = URL.createObjectURL(blob)+ setPreview(current => { if (current?.url) URL.revokeObjectURL(current.url); return { url, image: blob.type.startsWith('image/') } })+ setOpen(true)+ } catch (e) { setError((e as Error).message) } finally { setLoading(false) }+ }function downloadLetter() {if (!preview) returnconst link = document.createElement('a')@@ -54,7 +56,20 @@ function AuthorizationLink({ details }: { details: unknown }) {link.download = preview.image ? '授权函.png' : '授权函.pdf'link.click()}- return <div className="market-ops-file"><button type="button" onClick={downloadLetter} disabled={!preview}>下载授权函</button>{preview && (preview.image ? <img src={preview.url} alt="已签署授权函" /> : <iframe className="market-ops-letter-frame" src={preview.url} title="授权函预览" />)}{error && <p role="alert">{error}</p>}</div>+ return <div className="market-ops-file">+ <button type="button" onClick={() => void openLetter()} disabled={loading}>{loading ? '加载授权函…' : '预览授权函'}</button>+ {preview && <button type="button" onClick={downloadLetter}>下载授权函</button>}+ {error && <p role="alert">{error}</p>}+ <AdminModal open={open} onOpenChange={setOpen} title="授权函预览" subtitle="仅用于后台审核查看,不会自动下载文件。" size="xl" className="market-ops-letter-modal" bodyClassName="market-ops-letter-modal-body">+ <div className="market-ops-letter-preview">+ <div className="market-ops-letter-preview-head"><strong>PrintFilm 作品授权函</strong><span>{preview?.image ? '图片文件' : 'PDF 文件'} · 在线查看</span></div>+ <div className="market-ops-letter-preview-canvas">+ {preview ? (preview.image ? <img className="market-ops-letter-image" src={preview.url} alt="已签署授权函" /> : <iframe className="market-ops-letter-frame" src={preview.url} title="授权函预览" />) : <p>授权函尚未加载。</p>}+ </div>+ </div>+ {preview && <div className="market-ops-letter-modal-actions"><button type="button" onClick={downloadLetter}>下载授权函</button></div>}+ </AdminModal>+ </div>}function CoverImage({ id }: { id?: number }) {diff --git a/admin/src/features/marketplace/marketplace-admin.css b/admin/src/features/marketplace/marketplace-admin.cssindex fe3ee9d..60f94eb 100644--- a/admin/src/features/marketplace/marketplace-admin.css+++ b/admin/src/features/marketplace/marketplace-admin.css@@ -53,7 +53,18 @@.market-ops-back { align-self:flex-start; }.market-ops-file { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }.market-ops-file video,.market-ops-file img { flex-basis:100%; width:100%; }-.market-ops-letter-frame { flex-basis:100%; width:100%; height:72vh; min-height:480px; border:0; background:#fff; border-radius:12px; }+.market-ops-letter-modal { background:linear-gradient(145deg,#ffffff 0%,#f6faf6 100%) !important; }+.market-ops-letter-modal .admin-modal-header { background:linear-gradient(135deg,#f1f8f2 0%,#ffffff 78%); border-bottom:1px solid #dfeae1; }+.market-ops-letter-modal-body { min-height:0; padding:18px 22px 20px !important; background:#f5f8f4; }+.market-ops-letter-preview { overflow:hidden; border:1px solid #dce8df; border-radius:14px; background:#fff; box-shadow:0 8px 24px rgb(39 98 78 / 8%); }+.market-ops-letter-preview-head { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 16px; color:#2d5f4b; background:#edf6ef; border-bottom:1px solid #dce8df; font-size:13px; }+.market-ops-letter-preview-head span { color:#769082; font-size:11px; }+.market-ops-letter-preview-canvas { padding:10px; background:#e9eeea; }+.market-ops-letter-frame { display:block; width:100%; height:min(67vh,700px); min-height:430px; border:1px solid #d9e1da; background:#fff; border-radius:9px; }+.market-ops-letter-image { display:block; max-width:100%; max-height:min(67vh,700px); margin:0 auto; object-fit:contain; border-radius:9px; background:#fff; }+.market-ops-letter-modal-actions { display:flex; justify-content:flex-end; margin-top:14px; }+.market-ops-letter-modal-actions button { border-color:#b7d0c2; background:#27624e; color:#fff; }+.market-ops-letter-modal-actions button:hover:not(:disabled) { border-color:#1d4d3c; background:#1d4d3c; }.market-ops-file button,.market-ops-file a { align-self:flex-start; border:1px solid #b7d0c2; background:#f3faf6; color:#27624e; text-decoration:none; border-radius:8px; padding:8px 14px; font-size:13px; }.market-ops-stage-layout { display:grid; grid-template-columns:minmax(0,1fr) 340px; gap:22px; align-items:start; }.market-ops-stage-player { min-height:360px; background:#111714; border-radius:16px; overflow:hidden; display:flex; flex-direction:column; color:#d5ddd6; }diff --git a/frontend/src/features/marketplace/AuthorizationPanel.tsx b/frontend/src/features/marketplace/AuthorizationPanel.tsxindex 39ded54..607d3d2 100644--- a/frontend/src/features/marketplace/AuthorizationPanel.tsx+++ b/frontend/src/features/marketplace/AuthorizationPanel.tsx@@ -1,5 +1,7 @@import { useEffect, useRef, useState, type PointerEvent } from 'react'+import { Download, Eye, FileCheck2, ShieldCheck } from 'lucide-react'import { date, letterFile, request } from './api'+import Modal from '../../components/ui/Modal'type Signed = { id: number; signer_name: string; created_at: string; template_version: string }type Status = { template: { version: string; title: string; notices: string[]; body: string }; current: Signed | null }@@ -12,6 +14,8 @@ export default function AuthorizationPanel({ onSigned }: { onSigned?: () => voidconst [error, setError] = useState('')const [busy, setBusy] = useState(false)const [preview, setPreview] = useState<Preview | null>(null)+ const [previewOpen, setPreviewOpen] = useState(false)+ const [previewBusy, setPreviewBusy] = useState(false)const [name, setName] = useState('')const [adult, setAdult] = useState(false)const [readAll, setReadAll] = useState(false)@@ -21,17 +25,18 @@ export default function AuthorizationPanel({ onSigned }: { onSigned?: () => voidconst drawing = useRef<number | null>(null)const ready = adult && readAll && acceptKey && name.trim().length >= 2useEffect(() => { let active = true; request<Status>('/authorization').then(value => { if (active) setStatus(value) }).catch(e => { if (active) setError(e.message) }); return () => { active = false } }, [])+ const previewUrl = useRef('')useEffect(() => {- const id = status?.current?.id- if (!id) return- let active = true- let objectUrl = ''- letterFile(id).then(blob => {- if (!active) return- objectUrl = URL.createObjectURL(blob)- setPreview({ url: objectUrl, image: blob.type.startsWith('image/') })- }).catch(e => { if (active) setError((e as Error).message) })- return () => { active = false; if (objectUrl) URL.revokeObjectURL(objectUrl) }+ setPreview(null)+ setPreviewOpen(false)+ if (previewUrl.current) {+ URL.revokeObjectURL(previewUrl.current)+ previewUrl.current = ''+ }+ return () => {+ if (previewUrl.current) URL.revokeObjectURL(previewUrl.current)+ previewUrl.current = ''+ }}, [status?.current?.id])function point(e: PointerEvent<HTMLCanvasElement>): Point {const rect = e.currentTarget.getBoundingClientRect()@@ -46,12 +51,38 @@ export default function AuthorizationPanel({ onSigned }: { onSigned?: () => voidif (ctx) { ctx.lineWidth = 3; ctx.lineCap = 'round'; ctx.beginPath(); ctx.moveTo(...previous); ctx.lineTo(...next); ctx.stroke() }stroke.push(next)}- function downloadLetter() {- if (!preview) return+ async function loadPreview() {+ if (preview) return preview+ const id = status?.current?.id+ if (!id) return null+ setPreviewBusy(true)+ setError('')+ try {+ const blob = await letterFile(id)+ const url = URL.createObjectURL(blob)+ previewUrl.current = url+ const value = { url, image: blob.type.startsWith('image/') }+ setPreview(value)+ return value+ } catch (e) {+ setError((e as Error).message)+ return null+ } finally {+ setPreviewBusy(false)+ }+ }+ async function openPreview() {+ const value = await loadPreview()+ if (value) setPreviewOpen(true)+ }+ async function downloadLetter() {+ const value = await loadPreview()+ if (!value) returnconst link = document.createElement('a')- link.href = preview.url- link.download = preview.image ? '授权函.png' : '授权函.pdf'+ link.href = value.url+ link.download = value.image ? '授权函.png' : '授权函.pdf'link.click()+ link.remove()}async function sign() {if (!status || !ready) return@@ -72,8 +103,23 @@ export default function AuthorizationPanel({ onSigned }: { onSigned?: () => void<div className="pf-market-letter">{status.template.body}</div>{status.current ? <><p className="pf-market-notice">已签署:{status.current.signer_name} · {date(status.current.created_at)}。下面是存档预览,不会自动下载。</p>- <div className="pf-market-letter-actions"><button type="button" onClick={downloadLetter} disabled={!preview}>下载授权函</button></div>- {preview && (preview.image ? <img className="pf-market-letter-image" src={preview.url} alt="已签署授权函" /> : <iframe className="pf-market-letter-frame" src={preview.url} title="授权函预览" />)}+ <div className="pf-market-letter-actions"><button type="button" onClick={() => { void openPreview() }} disabled={previewBusy}>{previewBusy ? '正在打开…' : '预览授权函'}</button><button type="button" onClick={() => { void downloadLetter() }} disabled={previewBusy}>{previewBusy ? '处理中…' : '下载授权函'}</button></div>+ <Modal open={previewOpen} onClose={() => setPreviewOpen(false)} title="授权函预览" size="xl" className="pf-market-letter-modal">+ <div className="pf-market-letter-modal-summary">+ <div className="pf-market-letter-modal-summary-top">+ <span className="pf-market-letter-modal-eyebrow"><ShieldCheck size={14} /> PRINTFILM · 数字资产市场</span>+ <span className="pf-market-letter-modal-status"><FileCheck2 size={13} /> 已签署</span>+ </div>+ <strong>账号授权函</strong>+ <span className="pf-market-letter-modal-meta">签署人:{status.current.signer_name} · {date(status.current.created_at)} · 条款 {status.current.template_version}</span>+ <p>授权函仅用于核验作品发布权属,在线预览不会自动下载文件。</p>+ </div>+ <div className="pf-market-letter-preview-surface">+ <div className="pf-market-letter-preview-label"><Eye size={14} /> 文档预览</div>+ {preview && (preview.image ? <img className="pf-market-letter-image" src={preview.url} alt="已签署授权函" /> : <iframe className="pf-market-letter-frame" src={preview.url} title="授权函预览" />)}+ </div>+ <div className="pf-market-letter-modal-actions"><button type="button" className="pf-market-letter-modal-secondary" onClick={() => setPreviewOpen(false)}>关闭</button><button type="button" className="pf-market-letter-modal-primary" onClick={() => { void downloadLetter() }} disabled={previewBusy}><Download size={14} /> {previewBusy ? '处理中…' : '下载授权函'}</button></div>+ </Modal></> : <div className="pf-market-fields"><label>签署人真实姓名<input value={name} minLength={2} maxLength={80} onChange={e => setName(e.target.value)} disabled={busy} /></label><p>在下方手写签名(支持鼠标或触屏)</p>diff --git a/frontend/src/features/marketplace/marketplace.css b/frontend/src/features/marketplace/marketplace.cssindex 1d6392e..95a3ee7 100644--- a/frontend/src/features/marketplace/marketplace.css+++ b/frontend/src/features/marketplace/marketplace.css@@ -181,8 +181,31 @@ body:has(.pf-market-shell) .pf-wx-fab-root { display:none; }.pf-market-letter-actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0; }.pf-market-letter-frame { width: 100%; height: 72vh; min-height: 480px; border: 1px solid #dedfd8; border-radius: 12px; background: #fff; }.pf-market-letter-image { width: 100%; max-height: 72vh; object-fit: contain; background: #f5f5f0; border-radius: 12px; }+.pf-market-letter-modal.pf-modal-panel { width:min(1040px,96vw); max-height:min(92dvh,900px); color:#34432f; background:#f6f8f2; border:1px solid #dfe7d4; border-radius:22px; box-shadow:0 28px 90px rgba(31,48,27,.24); }+.pf-market-letter-modal .pf-modal-head { padding:18px 24px 15px; background:linear-gradient(135deg,#fff 0%,#f3f8e9 100%); border-bottom:1px solid #dfe7d4; }+.pf-market-letter-modal .pf-modal-head h3 { color:#24301f; font-family:inherit; font-size:18px; font-weight:750; letter-spacing:-.2px; }+.pf-market-letter-modal .pf-modal-close { color:#66745f; background:#edf3e7; }+.pf-market-letter-modal .pf-modal-close:hover { color:#2c3d25; background:#e2edd7; }+.pf-market-letter-modal .pf-modal-body { display:flex; flex-direction:column; gap:14px; min-height:0; padding:18px 22px 20px; background:#f6f8f2; }+.pf-market-letter-modal-summary { display:flex; flex-direction:column; gap:6px; padding:14px 16px; border:1px solid #dbe7cc; border-radius:12px; background:#fff; color:#6b7566; font-size:12px; line-height:1.5; }+.pf-market-letter-modal-summary-top { display:flex; align-items:center; justify-content:space-between; gap:12px; }+.pf-market-letter-modal-summary strong { color:#2c3d25; font-size:14px; font-weight:700; }+.pf-market-letter-modal-eyebrow { display:inline-flex; align-items:center; gap:6px; color:#678729; font-size:10px; font-weight:750; letter-spacing:1.6px; text-transform:uppercase; }+.pf-market-letter-modal-status { display:inline-flex; align-items:center; gap:5px; padding:4px 8px; border-radius:999px; color:#35684b; background:#eaf6ed; font-size:11px; font-weight:650; white-space:nowrap; }+.pf-market-letter-modal-meta { color:#5f6f5b; }+.pf-market-letter-modal-summary p { margin:2px 0 0; color:#899585; font-size:11px; }+.pf-market-letter-preview-surface { min-height:0; padding:12px; border:1px solid #dfe5d8; border-radius:15px; background:linear-gradient(145deg,#e9eee4,#f8faf6); box-shadow:inset 0 1px 2px rgba(46,64,38,.05); }+.pf-market-letter-preview-label { display:flex; align-items:center; gap:6px; margin:0 0 9px 2px; color:#66785e; font-size:11px; font-weight:650; }+.pf-market-letter-modal .pf-market-letter-frame { display:block; width:100%; height:min(65dvh,680px); min-height:420px; border:1px solid #d7ded0; border-radius:10px; background:#fff; box-shadow:0 8px 22px rgba(35,47,31,.12); }+.pf-market-letter-modal .pf-market-letter-image { display:block; width:auto; max-width:100%; height:min(65dvh,680px); max-height:none; margin:0 auto; border:1px solid #d7ded0; border-radius:10px; background:#fff; box-shadow:0 8px 22px rgba(35,47,31,.12); }+.pf-market-letter-modal-actions { display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap; }+.pf-market-letter-modal-actions button { display:inline-flex; align-items:center; gap:7px; border:1px solid #c9d5bd; border-radius:10px; padding:10px 16px; color:#34422f; background:#fff; font:inherit; font-size:13px; font-weight:650; cursor:pointer; transition:background .16s,border-color .16s,transform .16s; }+.pf-market-letter-modal-actions button:hover:not(:disabled) { border-color:#93ad62; background:#f5f8ee; transform:translateY(-1px); }+.pf-market-letter-modal-actions .pf-market-letter-modal-primary { border-color:#536b23; background:#536b23; color:#fff; }+.pf-market-letter-modal-actions .pf-market-letter-modal-primary:hover:not(:disabled) { border-color:#40541a; background:#40541a; }+.pf-market-letter-modal-actions button:disabled { cursor:not-allowed; opacity:.55; }.pf-market-signature { display: block; width: 100%; max-width: 800px; aspect-ratio: 10 / 3; border: 1px dashed #888; border-radius: 10px; background: #fff; touch-action: none; }-@media (max-width: 600px) { .pf-market-file-preview iframe, .pf-market-letter-frame { height: 70vh; min-height: 360px; } .pf-market-rights-route, .pf-market-authorization { padding: 16px; } }+@media (max-width: 600px) { .pf-market-file-preview iframe, .pf-market-letter-frame { height: 70vh; min-height: 360px; } .pf-market-rights-route, .pf-market-authorization { padding: 16px; } .pf-market-letter-modal.pf-modal-panel { width:calc(100vw - 20px); max-height:calc(100dvh - 20px); border-radius:16px; }.pf-market-letter-modal .pf-modal-head { padding:15px 17px 12px; }.pf-market-letter-modal .pf-modal-body { padding:12px; gap:10px; }.pf-market-letter-modal-summary { padding:11px 12px; }.pf-market-letter-preview-surface { padding:7px; }.pf-market-letter-modal .pf-market-letter-frame { height:calc(100dvh - 230px); min-height:300px; }.pf-market-letter-modal .pf-market-letter-image { height:auto; max-height:calc(100dvh - 230px); }.pf-market-letter-modal-actions { justify-content:stretch; }.pf-market-letter-modal-actions button { flex:1; } }.pf-market-editor-main { min-width:0; }.pf-market-editor-main > .pf-market-form { margin-top:0; max-width:none; }.pf-market-editor-rights,.pf-market-publishing { border:1px solid var(--pf-line); border-radius:14px; background:var(--pf-card); padding:24px; margin:22px 0; min-width:0; }