From 4ba7eb7db73811469664a6f473a0dc06dda99992 Mon Sep 17 00:00:00 2001 From: Codex Bot Date: Mon, 26 Oct 2026 20:26:17 +0800 Subject: [PATCH] Expose Studio cover rendering API and add three source-based layout tools --- .../studio/src/components/LayoutSelection.tsx | 13 + apps/studio/src/components/SourceCover.tsx | 21 ++ apps/studio/src/components/TemplateTrial.tsx | 4 +- apps/studio/src/content/ideas.ts | 4 +- .../src/content/templates/selection.json | 353 ++++++++++++++++++ apps/studio/src/content/tool-links.ts | 2 + apps/studio/src/lib/api-documentation.ts | 15 +- apps/studio/src/lib/render-cover.ts | 22 ++ apps/studio/src/pages/api/export/[slug].ts | 29 +- apps/studio/src/pages/ideas/[slug].tsx | 4 +- apps/studio/src/pages/index.tsx | 8 +- apps/studio/src/styles/globals.css | 1 + 12 files changed, 455 insertions(+), 21 deletions(-) create mode 100644 apps/studio/src/components/LayoutSelection.tsx create mode 100644 apps/studio/src/components/SourceCover.tsx create mode 100644 apps/studio/src/content/templates/selection.json create mode 100644 apps/studio/src/content/tool-links.ts create mode 100644 apps/studio/src/lib/render-cover.ts diff --git a/apps/studio/src/components/LayoutSelection.tsx b/apps/studio/src/components/LayoutSelection.tsx new file mode 100644 index 0000000..3bda054 --- /dev/null +++ b/apps/studio/src/components/LayoutSelection.tsx @@ -0,0 +1,13 @@ +import {useState} from 'react'; +import Head from 'next/head'; +import {SourceCover,selections,type CoverValues} from './SourceCover'; +import {tutorialPost} from '../content/tool-links'; +export function LayoutSelection(){ + const [active,setActive]=useState(0),[values,setValues]=useState(selections.map(l=>({fields:Object.fromEntries(Object.entries(l.fields).filter(([,v])=>v!==undefined)) as Record,color:'#83918a',accent:'#c3cec5'}))),[guides,setGuides]=useState(false),[status,setStatus]=useState(''); + const layout=selections[active],current=values[active]; + function update(patch:Partial){setValues(old=>old.map((v,i)=>i===active?{...v,...patch}:v));} + async function download(format:'svg'|'json'){ + try{setStatus('正在生成…');const r=await fetch('/studio/api/export/layout-selection?format='+format,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({layoutId:layout.id,...current})});if(!r.ok)throw Error();const url=URL.createObjectURL(await r.blob()),a=document.createElement('a');a.href=url;a.download=layout.id+'.'+format;a.click();setTimeout(()=>URL.revokeObjectURL(url),500);setStatus('已导出当前模板。')}catch{setStatus('导出失败,请重试。')} + } + return
三种排版 · Studio 工具
← waterfall-wiki 使用教程STUDIO / LAYOUT SELECTION
REF-01 / REF-07 / REF-26

三个构图,各有位置。

切换真实原图对应的模板,分别试文字与配色。图位蒙版与装饰来自教程的分层资产;当前只放占位内容。