Replace approximate recipes with 27 source-matched component layouts
wiki CI and deployment / verify-and-deploy (push) Successful in 16m40s

This commit is contained in:
2026-10-26 16:02:03 +08:00
parent f81aed8ce8
commit a8515e575a
674 changed files with 18935 additions and 622 deletions
@@ -0,0 +1,19 @@
import {readFile,writeFile,mkdir,cp,rm} from 'node:fs/promises';
import path from 'node:path';
import {spawnSync} from 'node:child_process';
import {tmpdir} from 'node:os';
import {guidanceMarkdown} from '../src/content/skills/guidance';
import {layouts,nextExample} from '../src/content/layouts/documents';
async function main(){
const root=path.resolve(import.meta.dirname,'..'),stage=path.join(tmpdir(),'prompt-layout-reference-toolkit');await rm(stage,{recursive:true,force:true});await mkdir(stage,{recursive:true});
const put=async(name:string,text:string)=>{const file=path.join(stage,name);await mkdir(path.dirname(file),{recursive:true});await writeFile(file,text+'\n')};
await cp(path.join(root,'public/layout-reference'),path.join(stage,'public/layout-reference'),{recursive:true,filter:source=>!source.endsWith('.zip')});
for(const file of ['ReferenceLayout.tsx','manifest.json'])await put('components/reference-layouts/'+file,await readFile(path.join(root,'src/content/layouts/reference',file),'utf8'));
for(const l of layouts){await put('documents/'+l.id+'.md',guidanceMarkdown('premium-layout/'+l.id)!);await put('app/designs/'+l.id+'/page.tsx',nextExample(l.id))}
await put('documents/router.md',guidanceMarkdown('premium-layout/router')!);
await put('app/layout.tsx',`import type {ReactNode} from 'react';\nexport default function RootLayout({children}:{children:ReactNode}){return <html lang="zh-CN"><body>{children}</body></html>}`);
await put('README.md',`# 27 张原图一一对应排版\n\n先读 documents/router.md,再选定 ref-01 至 ref-27 中的固定 ID。\n\n原始参考拼图是 736×980,每张约 112×173;素材保留原像素,不能恢复缺失的小字。默认 ReferenceLayout 逐层重组原图;文字仍是分类明确的原字形资产,不是已恢复成精确字体的矢量文字。text 属性可按完整构件键替换为 DOM 文本,未辨识细字不要猜写。\n\nHTML 检查器位于 public/layout-reference/index.html,需要通过静态服务器提供 public 目录。React 项目将 components 和 public 素材合入现有项目;Next.js 项目同时可使用 app/designs 下各个固定路由页。已有根布局应合并,不覆盖;@/ 指向源码根。\n\n包中没有 package.json,供合入现有 React / Next.js 项目。保留 manifest.json 与所有素材的相对路径。调用 ref-01 时只允许 ref-01/Txx 和 ref-01/Ixx;组件会验证类型与归属。弧形文字替换须专门建立该版面的 SVG 文字路径,通用组件会拒绝直接改成横排。\n\n原作者与素材许可未提供;本包用于用户提供参考图的识别、设计分析与原图对照,不声明模板所有权。\n`);
const result=spawnSync('python3',['-c',`import pathlib,zipfile,sys\nroot=pathlib.Path(sys.argv[1]);out=pathlib.Path(sys.argv[2])\nwith zipfile.ZipFile(out,'w',zipfile.ZIP_DEFLATED) as z:\n for p in sorted(root.rglob('*')):\n if p.is_file():z.write(p,p.relative_to(root))`,stage,path.join(root,'public/layout-reference/layout-reference-toolkit.zip')],{stdio:'inherit'});
if(result.status!==0)throw Error('ZIP packaging failed');console.log('Packaged 27 layouts, 28 documents, React, Next.js and classified source assets.');
}
main().catch(e=>{console.error(e);process.exitCode=1});