Skip to content

PRINTFILM: AI short-video marketing and AI short-drama creation platform

授权函

增瑞 田c4ec89d23674
diff --git a/admin/src/features/marketplace/MarketplaceAdmin.tsx b/admin/src/features/marketplace/MarketplaceAdmin.tsx
index 79f45d7..cbfdc2f 100644
--- a/admin/src/features/marketplace/MarketplaceAdmin.tsx
+++ b/admin/src/features/marketplace/MarketplaceAdmin.tsx
@@ -32,10 +32,10 @@ function WorkPreviewLink({ id }: { id: number }) {
return <div className="market-ops-file"><button type="button" onClick={async () => { try { setUrl((await request<{ url: string }>(`/api/marketplace/media/work/${id}/preview`)).url); setError('') } catch (e) { setError((e as Error).message) } }}>查看水印试看</button>{url && <video src={url} controls className="my-3 max-h-[500px] w-full" />}{error && <p role="alert">{error}</p>}</div>
}
function AuthorizationLink({ details }: { details: unknown }) {
- const [url, setUrl] = useState(''); const [error, setError] = useState('')
+ const [url, setUrl] = useState(''); const [filename, setFilename] = useState('授权函.pdf'); const [error, setError] = useState('')
const id = details && typeof details === 'object' && 'authorization_id' in details ? Number(details.authorization_id) : 0
if (!id) return null
- return <div className="market-ops-file"><button type="button" onClick={async () => { try { setUrl((await request<{ url: string }>(`/api/marketplace/authorizations/${id}/letter`)).url); setError('') } catch (e) { setError((e as Error).message) } }}>查看授权函</button>{url && <a href={url} target="_blank" rel="noreferrer"><img src={url} alt="已签署授权函" className="my-3 max-h-[600px] max-w-full object-contain" /></a>}{error && <p role="alert">{error}</p>}</div>
+ return <div className="market-ops-file"><button type="button" onClick={async () => { try { const value = await request<{ url: string; filename?: string }>(`/api/marketplace/authorizations/${id}/letter`); setUrl(value.url); setFilename(value.filename || '授权函.pdf'); setError('') } catch (e) { setError((e as Error).message) } }}>查看授权函</button>{url && (filename.endsWith('.pdf') ? <a href={url} target="_blank" rel="noreferrer">下载授权函 PDF</a> : <a href={url} target="_blank" rel="noreferrer"><img src={url} alt="已签署授权函" className="my-3 max-h-[600px] max-w-full object-contain" /></a>)}{error && <p role="alert">{error}</p>}</div>
}
function CoverImage({ id }: { id?: number }) {
diff --git a/backend/app/assets/fonts/NotoSansSC-Regular.ttf b/backend/app/assets/fonts/NotoSansSC-Regular.ttf
new file mode 100644
index 0000000..af123f5
Binary files /dev/null and b/backend/app/assets/fonts/NotoSansSC-Regular.ttf differ
diff --git a/backend/app/assets/fonts/OFL.txt b/backend/app/assets/fonts/OFL.txt
new file mode 100644
index 0000000..d952d62
--- /dev/null
+++ b/backend/app/assets/fonts/OFL.txt
@@ -0,0 +1,92 @@
+This Font Software is licensed under the SIL Open Font License,
+Version 1.1.
+
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font
+creation efforts of academic and linguistic communities, and to
+provide a free and open framework in which fonts may be shared and
+improved in partnership with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply to
+any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software
+components as distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to,
+deleting, or substituting -- in part or in whole -- any of the
+components of the Original Version, by changing formats or by porting
+the Font Software to a new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed,
+modify, redistribute, and sell modified and unmodified copies of the
+Font Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components, in
+Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the
+corresponding Copyright Holder. This restriction only applies to the
+primary font name as presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created using
+the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/backend/app/marketplace/authorization.py b/backend/app/marketplace/authorization.py
index 67c7784..fa2318e 100644
--- a/backend/app/marketplace/authorization.py
+++ b/backend/app/marketplace/authorization.py
@@ -12,7 +12,7 @@ from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from . import storage
-from .config import get_marketplace_settings
+from .config import get_marketplace_settings, resolve_cjk_font
from .dependencies import Actor, DB, storage_ready
from .models import Authorization
from .schemas import Input
@@ -57,36 +57,84 @@ def summary(item):
return data(item, "id", "template_version", "signer_name", "created_at", "body_hash") if item else None
-def render_and_store(body: SignInput, signed_at: str, owner_id: int) -> tuple[str, str]:
- """服务端合成全文和签名,先完成私有 OSS 写入再登记签署成功。"""
- from PIL import Image, ImageDraw, ImageFont
- font = ImageFont.truetype(get_marketplace_settings().watermark_font, 26)
- lines = []
- for paragraph in [TITLE, f"版本:{VERSION}", *BODY.splitlines(), f"签署人:{body.signer_name}", f"账号:{owner_id} 签署时间(UTC):{signed_at}", "手写签名:"]:
+def _pdf_font(path: str) -> str:
+ """注册本次签署使用的中文字体。ttc 取第一个字面。"""
+ from reportlab.pdfbase import pdfmetrics
+ from reportlab.pdfbase.ttfonts import TTFont
+ name = f"MarketplaceCJK{uuid.uuid4().hex[:8]}"
+ pdfmetrics.registerFont(TTFont(name, path, subfontIndex=0))
+ return name
+
+
+def _wrap(text: str, font_name: str, size: float, width: float) -> list[str]:
+ from reportlab.pdfbase import pdfmetrics
+ lines: list[str] = []
+ for paragraph in text.splitlines() or [""]:
line = ""
for char in paragraph:
- if font.getlength(line + char) > 1000:
+ if pdfmetrics.stringWidth(line + char, font_name, size) > width:
lines.append(line)
line = ""
line += char
- lines.extend([line, ""])
- signature = Image.new("RGB", (800, 240), "white")
- draw = ImageDraw.Draw(signature)
- for stroke in body.strokes:
- draw.line(stroke, fill="black", width=3, joint="curve")
- letter = Image.new("RGB", (1120, 100 + len(lines)*40 + 260), "white")
- draw = ImageDraw.Draw(letter)
- for i, line in enumerate(lines):
- draw.text((60, 50 + i*40), line, font=font, fill="black")
- letter.paste(signature, (60, 50 + len(lines)*40))
+ lines.append(line)
+ return lines
+
+
+def render_and_store(body: SignInput, signed_at: str, owner_id: int) -> str:
+ """把条款和手写签名直接写成 PDF,再存入私有 OSS。"""
+ from reportlab.pdfgen import canvas
+ try:
+ font_name = _pdf_font(resolve_cjk_font())
+ except (OSError, FileNotFoundError):
+ fail("服务器未找到可用的中文字体,暂时无法生成授权函。请安装 Noto CJK 或文泉驿字体后重试。", 503)
prefix = f"marketplace/authorizations/u{owner_id}/{uuid.uuid4().hex}"
+ key = f"{prefix}/letter.pdf"
with tempfile.TemporaryDirectory(prefix="printfilm-authorization-") as folder:
- for name, image in (("signature", signature), ("letter", letter)):
- path = Path(folder) / f"{name}.png"
- image.save(path)
- storage.upload(f"{prefix}/{name}.png", path, "image/png")
- return f"{prefix}/signature.png", f"{prefix}/letter.png"
+ path = Path(folder) / "letter.pdf"
+ _write_letter(path, font_name, body, signed_at, owner_id)
+ storage.upload(key, path, "application/pdf")
+ return key
+
+
+def _write_letter(path: Path, font_name: str, body: SignInput, signed_at: str, owner_id: int) -> None:
+ """按 A4 排版全文,签名用矢量笔画,不另存图片。"""
+ from reportlab.lib.pagesizes import A4
+ from reportlab.pdfgen import canvas
+ page_width, page_height = A4
+ margin, size, leading = 48, 11, 16
+ text_width = page_width - margin * 2
+ document = canvas.Canvas(str(path), pagesize=A4)
+ document.setTitle(TITLE)
+ document.setFont(font_name, size)
+ y = page_height - margin
+ paragraphs = [TITLE, f"版本:{VERSION}", *BODY.splitlines(), f"签署人:{body.signer_name}", f"账号:{owner_id} 签署时间(UTC):{signed_at}", "手写签名:"]
+ for paragraph in paragraphs:
+ for line in _wrap(paragraph, font_name, size, text_width) or [""]:
+ if y < margin + 150:
+ document.showPage()
+ document.setFont(font_name, size)
+ y = page_height - margin
+ document.drawString(margin, y, line)
+ y -= leading
+ y -= 4
+ scale = text_width / 800
+ signature_height = 240 * scale
+ if y - signature_height < margin:
+ document.showPage()
+ document.setFont(font_name, size)
+ y = page_height - margin
+ document.setLineWidth(1.4)
+ document.setLineCap(1)
+ document.setLineJoin(1)
+ for stroke in body.strokes:
+ pen = document.beginPath()
+ start_x, start_y = stroke[0]
+ pen.moveTo(margin + start_x * scale, y - start_y * scale)
+ for point_x, point_y in stroke[1:]:
+ pen.lineTo(margin + point_x * scale, y - point_y * scale)
+ document.drawPath(pen, stroke=1, fill=0)
+ document.save()
@router.get("/authorization", response_model=dict)
@@ -102,9 +150,9 @@ async def sign(body: SignInput, request: Request, db: DB, user: Actor):
if existing:
return summary(existing)
signed_at = now()
- signature_key, letter_key = await asyncio.to_thread(render_and_store, body, signed_at.isoformat(), user.id)
+ letter_key = await asyncio.to_thread(render_and_store, body, signed_at.isoformat(), user.id)
item = Authorization(owner_id=user.id, template_version=VERSION, signer_name=body.signer_name,
- body=BODY, body_hash=hashlib.sha256(BODY.encode()).hexdigest(), signature_key=signature_key,
+ body=BODY, body_hash=hashlib.sha256(BODY.encode()).hexdigest(), signature_key=letter_key,
letter_key=letter_key, created_at=signed_at, client_ip=(request.client.host if request.client else "")[:64],
user_agent=request.headers.get("user-agent", "")[:512])
db.add(item)
@@ -126,7 +174,8 @@ async def letter(record_id: int, db: DB, user: Actor):
item = await db.get(Authorization, record_id)
if not item or (item.owner_id != user.id and user.role != "admin"):
fail("授权函不存在或无权查看", 404)
- url = await asyncio.to_thread(storage.signed, item.letter_key, "image/png")
+ pdf = item.letter_key.lower().endswith(".pdf")
+ url = await asyncio.to_thread(storage.signed, item.letter_key, "application/pdf" if pdf else "image/png")
event(db, user.id, "authorization", item.id, "read")
await db.commit()
- return {"url": url, "expires_in": get_marketplace_settings().signed_url_seconds}
+ return {"url": url, "expires_in": get_marketplace_settings().signed_url_seconds, "filename": "授权函.pdf" if pdf else "授权函.png"}
diff --git a/backend/app/marketplace/config.py b/backend/app/marketplace/config.py
index 03fc313..70bbd4e 100644
--- a/backend/app/marketplace/config.py
+++ b/backend/app/marketplace/config.py
@@ -34,3 +34,15 @@ def is_marketplace_enabled() -> bool:
"""菜单和接口以系统设置里的开关为准;还没保存过时回落到 MARKETPLACE_ENABLED。"""
from app.config import get_settings
return bool(get_settings().marketplace_enabled)
+
+
+def resolve_cjk_font() -> str:
+ """优先使用已配置且存在的字体;否则用仓库内置或系统中的中文字体。"""
+ configured = Path(get_marketplace_settings().watermark_font)
+ if configured.is_file():
+ return str(configured)
+ from app.services.ffmpeg_compose import _find_cjk_font
+ found = _find_cjk_font()
+ if not found:
+ raise FileNotFoundError("未找到中文字体")
+ return found
diff --git a/backend/app/marketplace/preview_worker.py b/backend/app/marketplace/preview_worker.py
index de72d45..11b77d6 100644
--- a/backend/app/marketplace/preview_worker.py
+++ b/backend/app/marketplace/preview_worker.py
@@ -60,8 +60,10 @@ async def render_preview(snapshot):
if limit <= 0:
raise ValueError("视频过短,无法生成受限试看")
limit_args = ["-t", str(limit)]
- font = Path(settings.watermark_font)
- if not font.is_file():
+ from .config import resolve_cjk_font
+ try:
+ font = Path(resolve_cjk_font())
+ except (OSError, FileNotFoundError):
raise ValueError("水印字体不可用")
escaped_font = str(font.resolve()).replace("\\", "/").replace(":", "\\:").replace("'", "\\'")
# 作者名已去掉转码特殊字符;上下两处烧录。
diff --git a/backend/app/services/ffmpeg_compose.py b/backend/app/services/ffmpeg_compose.py
index 3546570..a598279 100644
--- a/backend/app/services/ffmpeg_compose.py
+++ b/backend/app/services/ffmpeg_compose.py
@@ -358,13 +358,15 @@ def _canvas(opts: ComposeOptions) -> tuple[int, int]:
def _find_cjk_font() -> str | None:
"""Return a path usable by drawtext fontfile=…(优先环境变量与仓库内置字体)。"""
- bundled = (
- Path(__file__).resolve().parents[1] / "assets" / "fonts" / "NotoSansSC-Regular.otf"
- )
+ bundled_dir = Path(__file__).resolve().parents[1] / "assets" / "fonts"
+ bundled = [
+ bundled_dir / "NotoSansSC-Regular.ttf",
+ bundled_dir / "NotoSansSC-Regular.otf",
+ ]
candidates = [
os.environ.get("FRAMECUT_FONT"),
- # 仓库内置(部署时可放入 backend/assets/fonts)
- str(bundled) if bundled.exists() else None,
+ # 仓库内置(部署时随代码带走,服务器不必再安装字体)
+ *[str(path) for path in bundled if path.is_file()],
r"C:\Windows\Fonts\msyhbd.ttc",
r"C:\Windows\Fonts\msyh.ttc",
r"C:\Windows\Fonts\simhei.ttf",
diff --git a/backend/requirements-marketplace.txt b/backend/requirements-marketplace.txt
index e190cfb..27fe817 100644
--- a/backend/requirements-marketplace.txt
+++ b/backend/requirements-marketplace.txt
@@ -1,3 +1,4 @@
-# 下游授权函图像合成依赖;原项目依赖文件保持独立。
+# 下游授权函生成 PDF;原项目依赖文件保持独立。
-r requirements.txt
Pillow==11.3.0
+reportlab==4.4.4
diff --git a/backend/tests/test_marketplace.py b/backend/tests/test_marketplace.py
index 0d87a91..6308d5e 100644
--- a/backend/tests/test_marketplace.py
+++ b/backend/tests/test_marketplace.py
@@ -413,6 +413,28 @@ def signing_body():
"strokes": [[[20 + i * 12, 60 + (i % 3) * 20] for i in range(25)]]}
+def test_bundled_cjk_font_is_used_when_configured_path_missing(monkeypatch):
+ """没有系统字体、配置路径也不存在时,使用仓库内置的 Noto Sans SC。"""
+ from pathlib import Path
+ from reportlab.pdfbase.ttfonts import TTFont
+ from app.marketplace.config import resolve_cjk_font
+ monkeypatch.setattr(get_marketplace_settings(), "watermark_font", "Z:/missing-font.ttf")
+ monkeypatch.delenv("FRAMECUT_FONT", raising=False)
+ found = resolve_cjk_font()
+ assert Path(found).name == "NotoSansSC-Regular.ttf"
+ assert Path(found).is_file()
+ TTFont("BundledCJKTest", found, subfontIndex=0)
+
+
+def test_letter_font_falls_back_when_configured_path_missing(monkeypatch):
+ """配置路径和系统字体都不存在时,明确报缺少字体。"""
+ from app.marketplace.config import resolve_cjk_font
+ monkeypatch.setattr(get_marketplace_settings(), "watermark_font", "Z:/missing-font.ttf")
+ monkeypatch.setattr("app.services.ffmpeg_compose._find_cjk_font", lambda: None)
+ with pytest.raises(FileNotFoundError):
+ resolve_cjk_font()
+
+
def source_details(source):
return {"source": source, "author": "测试作者", "holder": "测试权利人", "relationship": "本人",
"acquisition": "original", "scope": "展示和线下洽谈", "third_party": "无第三方素材",
@@ -421,15 +443,13 @@ def source_details(source):
async def test_printfilm_signed_letter_review_and_public_flow(ctx, monkeypatch):
- """真实渲染签名图,OSS 仅用传输替身;签署不能自动批准作品。"""
- from PIL import Image
+ """真实生成授权函 PDF,OSS 仅用传输替身;签署不能自动批准作品。"""
from app.marketplace.models import Authorization
fake_oss(monkeypatch)
uploaded = []
def capture(key, path, content_type):
- with Image.open(path) as image:
- assert image.format == "PNG" and image.width >= 800
- assert key.startswith("marketplace/authorizations/") and content_type == "image/png"
+ assert path.read_bytes().startswith(b"%PDF")
+ assert key.endswith("/letter.pdf") and content_type == "application/pdf"
uploaded.append(key)
monkeypatch.setattr(storage, "upload", capture)
video = await asset(ctx)
@@ -439,9 +459,9 @@ async def test_printfilm_signed_letter_review_and_public_flow(ctx, monkeypatch):
signed = await ctx.client.post("/api/marketplace/authorization", json=signing_body())
assert signed.status_code == 200, signed.text
authorization_id = signed.json()["id"]
- assert len(uploaded) == 2
+ assert len(uploaded) == 1
assert (await ctx.client.post("/api/marketplace/authorization", json=signing_body())).json()["id"] == authorization_id
- assert len(uploaded) == 2
+ assert len(uploaded) == 1
archive = await ctx.db.get(Authorization, authorization_id)
assert archive.signer_name == "测试签署人" and len(archive.body_hash) == 64 and archive.body
payload["version"] = 0
diff --git a/docs/MARKETPLACE.md b/docs/MARKETPLACE.md
index 968b5ef..8ef98c4 100644
--- a/docs/MARKETPLACE.md
+++ b/docs/MARKETPLACE.md
@@ -165,7 +165,7 @@ cd C:\code\printfilm\backend
## 来源分流与上传预览补充(2026-10-20)
- 授权签署入口:`/marketplace/authorization`,个人工作台与发布作品页均有入口,权属页内也可直接签署。
-- 独立依赖安装:在 backend 目录执行 `.\.venv\Scripts\python.exe -m pip install -r requirements-marketplace.txt`。Pillow 用于服务端合成中文授权函;沿用 MARKETPLACE_WATERMARK_FONT 字体。原依赖文件和锁文件未改。
+- 独立依赖安装:在 backend 目录执行 `.\.venv\Scripts\python.exe -m pip install -r requirements-marketplace.txt`。授权函直接生成 PDF,并把仓库内置的 Noto Sans SC 嵌进文件,服务器和下载方都不必另装字体。若 `MARKETPLACE_WATERMARK_FONT` 指向一个真实存在的文件,则仍优先使用该字体。水印预览使用同一套查找。
- `marketplace_authorizations` 是新增独立表,启用模块启动时创建。签署存储全文、版本、SHA-256 摘要、姓名、时间、账号及必要访问信息;签名与完整授权函 PNG 存到私有 OSS 的 `marketplace/authorizations/`。全文与签名由服务端合成,不信任客户端合成的协议图片。未写入 OSS 不返回签署成功。
- 授权函按账号与版本唯一,逐件权属档案只能由服务端关联本人的签署记录。重新保存材料会重置核验,模板更新须重签及重新关联。只有本人和管理员能获取短时授权函链接。
- 协议采用数字资产市场当前范围:非独家展示、处理和客服撮合;没有自动转让、线上付款、分成或买家下载授权。ReelBay 仅参考流程,不复制它的支付或商业分成条款。
diff --git a/frontend/src/features/marketplace/AuthorizationPanel.tsx b/frontend/src/features/marketplace/AuthorizationPanel.tsx
index 5ded1ad..96ccd16 100644
--- a/frontend/src/features/marketplace/AuthorizationPanel.tsx
+++ b/frontend/src/features/marketplace/AuthorizationPanel.tsx
@@ -11,7 +11,7 @@ export default function AuthorizationPanel({ onSigned }: { onSigned?: () => void
const [status, setStatus] = useState<Status | null>(null)
const [error, setError] = useState('')
const [busy, setBusy] = useState(false)
- const [url, setUrl] = useState('')
+ const [letter, setLetter] = useState<{ url: string; filename: string } | null>(null)
const [name, setName] = useState('')
const [accepted, setAccepted] = useState(false)
const canvas = useRef<HTMLCanvasElement>(null)
@@ -44,7 +44,7 @@ export default function AuthorizationPanel({ onSigned }: { onSigned?: () => void
}
return <section className="pf-market-authorization"><h2>PrintFilm 作品授权函</h2><p>按现行条款签署一次,本账号后续 PrintFilm 作品可引用。无需另外填写创作记录或上传版权证明。</p>
{status && <><details><summary>阅读完整授权函 · {status.template.version}</summary><h3>{status.template.title}</h3><div className="pf-market-letter">{status.template.body}</div></details>
- {status.current ? <><p className="pf-market-notice">已签署:{status.current.signer_name} · {date(status.current.created_at)}。可用于当前视频的发布审核。</p><button type="button" onClick={async () => { try { setUrl((await request<{ url: string }>(`/authorizations/${status.current!.id}/letter`)).url) } catch (e) { setError((e as Error).message) } }}>查看已签授权函</button>{url && <PreviewContent key={url} url={url} filename="授权函.png" />}</> : <div className="pf-market-fields"><label>签署人真实姓名<input value={name} minLength={2} maxLength={80} onChange={e => setName(e.target.value)} disabled={busy} /></label><p>在下方手写签名(支持鼠标或触屏)</p><canvas aria-label="手写签名区域" ref={canvas} width={800} height={240} className="pf-market-signature" onPointerDown={e => { if (busy || drawing.current !== null || strokes.current.length >= 40) return; e.currentTarget.setPointerCapture(e.pointerId); drawing.current = e.pointerId; strokes.current.push([point(e)]) }} onPointerMove={move} onPointerUp={e => { if (drawing.current === e.pointerId) drawing.current = null }} onPointerCancel={() => { drawing.current = null }} /><button type="button" disabled={busy} onClick={() => { strokes.current = []; canvas.current?.getContext('2d')?.clearRect(0, 0, 800, 240) }}>清除签名</button><label><input type="checkbox" checked={accepted} disabled={busy} onChange={e => setAccepted(e.target.checked)} />我已阅读完整授权函,有权签署并确认以上声明;具体交易仍需另行订立合同。</label><button type="button" disabled={busy || !accepted || name.trim().length < 2} onClick={sign}>{busy ? '正在存档…' : '确认签署并保存授权函'}</button></div>}</>}
+ {status.current ? <><p className="pf-market-notice">已签署:{status.current.signer_name} · {date(status.current.created_at)}。可用于当前视频的发布审核。</p><button type="button" onClick={async () => { try { const value = await request<{ url: string; filename?: string }>(`/authorizations/${status.current!.id}/letter`); setLetter({ url: value.url, filename: value.filename || '授权函.pdf' }) } catch (e) { setError((e as Error).message) } }}>查看已签授权函</button>{letter && <PreviewContent key={letter.url} url={letter.url} filename={letter.filename} />}</> : <div className="pf-market-fields"><label>签署人真实姓名<input value={name} minLength={2} maxLength={80} onChange={e => setName(e.target.value)} disabled={busy} /></label><p>在下方手写签名(支持鼠标或触屏)</p><canvas aria-label="手写签名区域" ref={canvas} width={800} height={240} className="pf-market-signature" onPointerDown={e => { if (busy || drawing.current !== null || strokes.current.length >= 40) return; e.currentTarget.setPointerCapture(e.pointerId); drawing.current = e.pointerId; strokes.current.push([point(e)]) }} onPointerMove={move} onPointerUp={e => { if (drawing.current === e.pointerId) drawing.current = null }} onPointerCancel={() => { drawing.current = null }} /><button type="button" disabled={busy} onClick={() => { strokes.current = []; canvas.current?.getContext('2d')?.clearRect(0, 0, 800, 240) }}>清除签名</button><label><input type="checkbox" checked={accepted} disabled={busy} onChange={e => setAccepted(e.target.checked)} />我已阅读完整授权函,有权签署并确认以上声明;具体交易仍需另行订立合同。</label><button type="button" disabled={busy || !accepted || name.trim().length < 2} onClick={sign}>{busy ? '正在存档…' : '确认签署并保存授权函'}</button></div>}</>}
{!status && !error && <p role="status">正在读取授权条款…</p>}{error && <p role="alert">{error}</p>}
</section>
}