-
← 返回学习站
+
← 成长记录
}>{page}{!isKnowledge &&
一键反馈}>;
+ const page = is3D ?
: isKnowledge ?
: isArt ?
: isLearning ?
:
;
+ return <>
正在载入学习空间…}>{page}{isLearning &&
一键反馈}>;
}
createRoot(document.getElementById("root")!).render(
);
diff --git a/scripts/archive.test.mjs b/scripts/archive.test.mjs
new file mode 100644
index 0000000..864ca91
--- /dev/null
+++ b/scripts/archive.test.mjs
@@ -0,0 +1,84 @@
+import test from "node:test";
+import assert from "node:assert/strict";
+import {mkdtemp,readFile} from "node:fs/promises";
+import os from "node:os";
+import path from "node:path";
+import {createRequire} from "node:module";
+import {CONSENT,OWNER_ID,MAX_BYTES,parseArtwork,safeAssetUrl,downloadImage} from "./gallery-model.mjs";
+import {buildGallery,listIssues,transformImage} from "./build-gallery.mjs";
+import {cleanGraph,parseRecord,RECORD_CONSENT,allowedContent} from "./record-model.mjs";
+import {syncRecords} from "./sync-records.mjs";
+const sharp=createRequire(path.join(process.env.GALLERY_TOOLS_DIR,"package.json"))("sharp");
+const url="https://github.com/user-attachments/assets/11111111-1111-1111-1111-111111111111";
+const art=()=>({number:7,title:"[画作] 测试",state:"open",user:{id:OWNER_ID},body:"### 作品名称\n测试图片\n\n### 创作日期\n2026-09-05\n\n### 作品图片\n\n\n### 作品故事\n文字不是 HTML:\n\n### 公开确认\n- [x] "+CONSENT});
+const graph=()=>({version:1,title:"阅读笔记",nodes:[{id:"n1",text:"事实",position:{x:1,y:2}},{id:"n2",text:"解释",position:{x:200,y:2}}],relations:[{id:"e",sourceId:"n1",targetId:"n2",label:"",sourceHandle:"right",targetHandle:"left"}]});
+const knowledge=(number=20)=>({number,state:"open",title:"[知识] 测试",user:{id:OWNER_ID},updated_at:"2026-09-05T12:00:00Z",body:"### 知识数据\n"+JSON.stringify({version:1,spaceId:"test-space",graph:graph()})+"\n\n### 公开确认\n- [x] "+RECORD_CONSENT});
+test("owner-only publication and consent",()=>{
+ assert.equal(parseArtwork({...art(),user:{id:1}}),null);
+ assert.equal(parseArtwork({...art(),state:"closed"}),null);
+ assert.equal(parseArtwork({...art(),pull_request:{}}),null);
+ assert.throws(()=>parseArtwork({...art(),body:art().body.replace("[x]","[ ]")}));
+ assert.equal(parseArtwork(art()).id,7);
+});
+test("date validity, unknown date and HTML image markup",()=>{
+ assert.throws(()=>parseArtwork({...art(),body:art().body.replace("2026-09-05","2026-02-30")}));
+ assert.equal(parseArtwork({...art(),body:art().body.replace("2026-09-05","_No response_")}).date,null);
+ assert.equal(parseArtwork({...art(),body:art().body.replace("",'

')}).assetUrl,url);
+});
+test("reject SSRF, credentials, unexpected ports and hosts",()=>{
+ for(const u of ["http://127.0.0.1","https://github.com.evil.test/a","https://github.com/login","https://user:password@github.com/user-attachments/assets/11111111-1111-1111-1111-111111111111","https://github.com:444/user-attachments/assets/11111111-1111-1111-1111-111111111111"])assert.throws(()=>safeAssetUrl(u));
+});
+test("image download rejects external redirect, oversized and wrong mime",async()=>{
+ await assert.rejects(()=>downloadImage(url,async()=>new Response(null,{status:302,headers:{location:"http://127.0.0.1"}})));
+ await assert.rejects(()=>downloadImage(url,async()=>new Response("html",{headers:{"content-type":"text/html"}})));
+ await assert.rejects(()=>downloadImage(url,async()=>new Response("x",{headers:{"content-type":"image/png","content-length":String(MAX_BYTES+1)}})));
+ await assert.rejects(()=>downloadImage(url,async()=>new Response(new Uint8Array(MAX_BYTES+1),{headers:{"content-type":"image/png"}})));
+});
+test("API pagination and errors do not silently create empty gallery",async()=>{
+ let calls=0;
+ const result=await listIssues(async()=>new Response(JSON.stringify(++calls===1?Array.from({length:100},(_,i)=>({number:i})):[])),null);
+ assert.equal(result.length,100);assert.equal(calls,2);
+ await assert.rejects(()=>listIssues(async()=>new Response("",{status:500}),null));
+});
+test("real image pipeline preserves portrait / landscape / square and removes EXIF",async()=>{
+ for(const [width,height] of [[600,1200],[1200,600],[600,600]]){
+ const input=await sharp({create:{width,height,channels:3,background:"#123456"}}).jpeg().withMetadata().toBuffer();
+ const out=await transformImage(input,sharp);
+ assert.equal(out.full.info.width/out.full.info.height,width/height);
+ const meta=await sharp(out.full.data).metadata();assert.equal(meta.exif,undefined);assert.equal(meta.format,"webp");
+ }
+});
+test("gallery integration generates local assets and manifest, excludes strangers",async()=>{
+ const output=await mkdtemp(path.join(os.tmpdir(),"gallery-test-"));
+ const png=await sharp({create:{width:200,height:400,channels:3,background:"#123456"}}).png().toBuffer();
+ const report=await buildGallery({issues:[art(),{...art(),number:8,user:{id:1}}],output,sharp,fetcher:async()=>new Response(png,{headers:{"content-type":"image/png"}})});
+ const manifest=JSON.parse(await readFile(path.join(output,"manifest.json"),"utf8"));
+ assert.equal(report.count,1);assert.equal(manifest.artworks[0].height,400);
+ assert.ok(manifest.artworks[0].image.startsWith("/art-data/images/7-"));
+ assert.ok(!("assetUrl" in manifest.artworks[0]));
+});
+test("graph validates references, finite positions and unique ids",()=>{
+ assert.equal(cleanGraph(graph()).nodes.length,2);
+ const g=graph();g.nodes[0].position.x=Infinity;assert.throws(()=>cleanGraph(g));
+ const dup=graph();dup.nodes.push(dup.nodes[0]);assert.throws(()=>cleanGraph(dup));
+ const bad=graph();bad.relations[0].targetId="missing";assert.throws(()=>cleanGraph(bad));
+ assert.equal(parseRecord({...knowledge(),user:{id:1}}),null);
+ assert.throws(()=>parseRecord({...knowledge(),body:knowledge().body.replace("test-space","../escape")}));
+});
+test("excluded projects are not included in public records",()=>{
+ for(const term of ["贝贝","王洁","营养师","瑜伽","普拉提"])assert.equal(allowedContent(term),false);
+ assert.throws(()=>parseRecord({...knowledge(),body:knowledge().body.replace("阅读笔记","普拉提")}));
+});
+test("knowledge is written to repository content and newest snapshot wins",async()=>{
+ const root=await mkdtemp(path.join(os.tmpdir(),"records-test-"));
+ const newer=knowledge(21);newer.body=newer.body.replace("阅读笔记","新的理解");
+ await syncRecords([knowledge(20),newer],root);
+ const saved=JSON.parse(await readFile(path.join(root,"content/knowledge/test-space.json"),"utf8"));
+ assert.equal(saved.graph.title,"新的理解");assert.equal(saved.issue,21);
+ const index=JSON.parse(await readFile(path.join(root,"github-pages/public/records/index.json"),"utf8"));
+ assert.equal(index.knowledge.length,1);
+ await syncRecords([{...knowledge(),state:"closed"}],root);
+ const empty=JSON.parse(await readFile(path.join(root,"content/index.json"),"utf8"));
+ assert.equal(empty.knowledge.length,0);
+ assert.equal(JSON.parse(await readFile(path.join(root,"content/knowledge/test-space.json"),"utf8")).graph.title,"新的理解");
+});
diff --git a/scripts/build-gallery.mjs b/scripts/build-gallery.mjs
new file mode 100644
index 0000000..b3034fa
--- /dev/null
+++ b/scripts/build-gallery.mjs
@@ -0,0 +1,76 @@
+import { mkdir, writeFile, readFile } from "node:fs/promises";
+import path from "node:path";
+import { createHash } from "node:crypto";
+import { createRequire } from "node:module";
+import { fileURLToPath } from "node:url";
+import { REPOSITORY, parseArtwork, downloadImage } from "./gallery-model.mjs";
+
+export async function transformImage(bytes, sharp) {
+ const metadata = await sharp(bytes, { limitInputPixels: 80000000 }).metadata();
+ if (!["jpeg","png","webp","gif"].includes(metadata.format)) throw new Error("请上传 JPG、PNG、WebP 或 GIF,不支持 SVG 或 HEIC");
+ const make = width => sharp(bytes, { limitInputPixels: 80000000 }).rotate()
+ .resize({ width, height: width, fit: "inside", withoutEnlargement: true })
+ .webp({ quality: 88 }).toBuffer({ resolveWithObject: true });
+ const full = await make(2400);
+ const thumb = await make(720);
+ return { full, thumb };
+}
+
+export async function listIssues(fetcher = fetch, token = process.env.GITHUB_TOKEN) {
+ const issues = [];
+ for (let page=1; page<=100; page++) {
+ const response = await fetcher("https://api.github.com/repos/" + REPOSITORY + "/issues?state=open&per_page=100&page=" + page, {
+ headers: { Accept: "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28", ...(token ? { Authorization: "Bearer " + token } : {}) },
+ signal: AbortSignal.timeout(30000)
+ });
+ if (!response.ok) throw new Error("读取作品记录失败(HTTP " + response.status + "),保留上次线上版本");
+ const batch = await response.json();
+ if (!Array.isArray(batch)) throw new Error("作品记录返回格式异常");
+ issues.push(...batch);
+ if (batch.length < 100) return issues;
+ }
+ throw new Error("作品记录分页超出限制");
+}
+
+export async function buildGallery({ issues, output, sharp, fetcher = fetch }) {
+ const art = []; const errors = [];
+ await mkdir(path.join(output, "images"), { recursive: true });
+ for (const issue of issues) {
+ let record;
+ try { record = parseArtwork(issue); } catch (error) {
+ errors.push({ id: issue.number, message: error.message }); continue;
+ }
+ if (!record) continue;
+ // A download failure must not silently remove a previously published work.
+ const bytes = await downloadImage(record.assetUrl, fetcher);
+ const { full, thumb } = await transformImage(bytes, sharp);
+ const hash = createHash("sha256").update(full.data).digest("hex").slice(0,16);
+ const stem = record.id + "-" + hash;
+ await writeFile(path.join(output, "images", stem + ".webp"), full.data);
+ await writeFile(path.join(output, "images", stem + "-small.webp"), thumb.data);
+ const { assetUrl, ...publicRecord } = record;
+ art.push({ ...publicRecord, image: "/art-data/images/" + stem + ".webp",
+ thumbnail: "/art-data/images/" + stem + "-small.webp",
+ width: full.info.width, height: full.info.height });
+ }
+ art.sort((a,b) => (b.date ?? "").localeCompare(a.date ?? "") || b.id-a.id);
+ const manifest = { version: 1, generatedAt: new Date().toISOString(), artworks: art };
+ await writeFile(path.join(output, "manifest.json"), JSON.stringify(manifest, null, 2) + "\n");
+ return { count: art.length, publishedIds: art.map(a=>a.id), errors };
+}
+
+async function main() {
+ const sharp = process.env.GALLERY_TOOLS_DIR
+ ? createRequire(path.join(process.env.GALLERY_TOOLS_DIR, "package.json"))("sharp")
+ : (await import("sharp")).default;
+ const issues = process.env.GALLERY_FIXTURE ? JSON.parse(await readFile(process.env.GALLERY_FIXTURE,"utf8")) : await listIssues();
+ const report = await buildGallery({ issues, output: "github-pages/public/art-data", sharp });
+ await writeFile("gallery-report.json", JSON.stringify(report,null,2));
+ if (process.env.GITHUB_STEP_SUMMARY) {
+ const lines = ["## 绘画作品", "已准备 " + report.count + " 幅作品。",
+ ...report.errors.map(e => "- #" + e.id + ":" + e.message)];
+ await writeFile(process.env.GITHUB_STEP_SUMMARY, lines.join("\n") + "\n", {flag:"a"});
+ }
+ console.log("Gallery prepared:", report.count, "works;", report.errors.length, "invalid submissions.");
+}
+if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) main().catch(error => { console.error(error.message); process.exitCode=1; });
diff --git a/scripts/fixtures/empty.json b/scripts/fixtures/empty.json
new file mode 100644
index 0000000..fe51488
--- /dev/null
+++ b/scripts/fixtures/empty.json
@@ -0,0 +1 @@
+[]
diff --git a/scripts/gallery-model.mjs b/scripts/gallery-model.mjs
new file mode 100644
index 0000000..69dd50c
--- /dev/null
+++ b/scripts/gallery-model.mjs
@@ -0,0 +1,70 @@
+export const REPOSITORY = "hulingjun/hulingjun.github.io";
+export const OWNER_ID = 166984918;
+export const CONSENT = "我确认只上传可公开展示的画作,不含孩子的姓名、学校、住址等隐私。";
+export const MAX_BYTES = 10 * 1024 * 1024;
+
+export function section(body, name) {
+ const sections = String(body ?? "").replace(/\r\n/g, "\n").split(/^### /m).slice(1);
+ const found = sections.find(s => s.split("\n")[0].trim() === name);
+ return found ? found.slice(found.indexOf("\n") + 1).trim().replace(/^_No response_$/, "") : "";
+}
+
+export function safeAssetUrl(value, redirect = false) {
+ let url;
+ try { url = new URL(value); } catch { throw new Error("图片链接格式不正确"); }
+ if (url.protocol !== "https:" || url.username || url.password || (url.port && url.port !== "443")) throw new Error("只接受 GitHub 图片附件");
+ const modern = url.hostname === "github.com" && /^\/user-attachments\/assets\/[a-f\d-]{36}$/i.test(url.pathname);
+ const legacy = url.hostname === "user-images.githubusercontent.com" && /^\/\d+\//.test(url.pathname);
+ const redirected = redirect && ["private-user-images.githubusercontent.com", "objects.githubusercontent.com"].includes(url.hostname);
+ if (!(modern || legacy || redirected)) throw new Error("请使用 GitHub 上传的图片附件,不要粘贴外部图片网址");
+ return url.href;
+}
+
+export function parseArtwork(issue) {
+ if (issue.pull_request || issue.state !== "open" || issue.user?.id !== OWNER_ID || !issue.title?.startsWith("[画作]")) return null;
+ if (!Number.isSafeInteger(issue.number) || issue.number < 1) throw new Error("作品编号无效");
+ const title = section(issue.body, "作品名称");
+ const date = section(issue.body, "创作日期");
+ const story = section(issue.body, "作品故事");
+ const confirmation = section(issue.body, "公开确认");
+ if (!title || title.length > 80 || title.includes("\n")) throw new Error("作品名称需为 1–80 个字的一行文字");
+ if (date && (!/^\d{4}-\d{2}-\d{2}$/.test(date) || !Number.isFinite(Date.parse(date)) || new Date(date).toISOString().slice(0,10) !== date)) throw new Error("创作日期请填写有效的 YYYY-MM-DD;不记得可以留空");
+ if (/贝贝|王洁|营养师|瑜伽|普拉提/.test(title+"\n"+story)) throw new Error("这份内容属于已屏蔽的项目或主题,不会公开收录");
+ if (story.length > 1200) throw new Error("作品故事请保持在 1200 字以内");
+ if (!confirmation.includes("- [x] " + CONSENT) && !confirmation.includes("- [X] " + CONSENT)) throw new Error("请勾选公开展示确认");
+ const images = section(issue.body, "作品图片");
+ const urls = [...images.matchAll(/https:\/\/(?:github\.com\/user-attachments\/assets\/[a-f\d-]+|user-images\.githubusercontent\.com\/[^\s<>"')]+)/gi)].map(m => safeAssetUrl(m[0]));
+ const unique = [...new Set(urls)];
+ if (unique.length !== 1) throw new Error("每条记录请上传一张 JPG、PNG、WebP 或 GIF 图片");
+ return { id: issue.number, title, date: date || null, story, assetUrl: unique[0],
+ sourceUrl: "https://github.com/" + REPOSITORY + "/issues/" + issue.number };
+}
+
+export async function downloadImage(url, fetcher = fetch) {
+ let current = safeAssetUrl(url);
+ for (let i = 0; i < 6; i++) {
+ const response = await fetcher(current, { redirect: "manual", signal: AbortSignal.timeout(30000) });
+ if ([301,302,303,307,308].includes(response.status)) {
+ const location = response.headers.get("location");
+ if (!location) throw new Error("图片下载跳转失败");
+ current = safeAssetUrl(new URL(location, current).href, true);
+ continue;
+ }
+ if (!response.ok) throw new Error("图片下载失败(HTTP " + response.status + "),请重新上传图片后编辑记录");
+ if (!/^image\/(?:jpeg|png|webp|gif)(?:;|$)/i.test(response.headers.get("content-type") ?? "")) throw new Error("图片格式不支持,请转为 JPG 或 PNG");
+ if (Number(response.headers.get("content-length") ?? 0) > MAX_BYTES) throw new Error("图片不能超过 10 MB");
+ if (!response.body) throw new Error("图片内容为空");
+ const reader = response.body.getReader();
+ const chunks = []; let size = 0;
+ for (;;) {
+ const {done,value} = await reader.read();
+ if (done) break;
+ size += value.byteLength;
+ if (size > MAX_BYTES) { await reader.cancel(); throw new Error("图片不能超过 10 MB"); }
+ chunks.push(value);
+ }
+ if (!size) throw new Error("图片内容为空");
+ return Buffer.concat(chunks);
+ }
+ throw new Error("图片跳转次数过多");
+}
diff --git a/scripts/record-model.mjs b/scripts/record-model.mjs
new file mode 100644
index 0000000..589ec4a
--- /dev/null
+++ b/scripts/record-model.mjs
@@ -0,0 +1,40 @@
+import { OWNER_ID, section } from "./gallery-model.mjs";
+export const RECORD_CONSENT="我确认这份记录可以在公开网站和 GitHub 仓库中展示。";
+const EXCLUDED=/贝贝|王洁|营养师|瑜伽|普拉提/;
+export function allowedContent(value){return !EXCLUDED.test(value);}
+export function cleanGraph(raw){
+ if(!raw||raw.version!==1||typeof raw.title!=="string"||!raw.title.trim()||raw.title.length>120||!Array.isArray(raw.nodes)||!Array.isArray(raw.relations)||raw.nodes.length>2000||raw.relations.length>6000)throw new Error("知识数据格式不正确或超过 2000 节点 / 6000 关系");
+ const ids=new Set();
+ const nodes=raw.nodes.map(n=>{
+ if(!n||typeof n.id!=="string"||n.id.length>120||!n.id||ids.has(n.id)||typeof n.text!=="string"||n.text.length>12000||!Number.isFinite(n.position?.x)||!Number.isFinite(n.position?.y)||Math.abs(n.position.x)>1e7||Math.abs(n.position.y)>1e7)throw new Error("知识节点不合法或 ID 重复");
+ ids.add(n.id);return{id:n.id,text:n.text,position:{x:n.position.x,y:n.position.y}};
+ });
+ const edgeIds=new Set(),handles=[null,undefined,"left","right","top","bottom"];
+ const relations=raw.relations.map(r=>{
+ if(!r||typeof r.id!=="string"||!r.id||r.id.length>120||edgeIds.has(r.id)||!ids.has(r.sourceId)||!ids.has(r.targetId)||typeof r.label!=="string"||r.label.length>2000||!handles.includes(r.sourceHandle)||!handles.includes(r.targetHandle))throw new Error("知识关系引用或连接点不合法");
+ edgeIds.add(r.id);return{id:r.id,sourceId:r.sourceId,targetId:r.targetId,label:r.label,sourceHandle:r.sourceHandle??null,targetHandle:r.targetHandle??null};
+ });
+ return{version:1,title:raw.title,nodes,relations};
+}
+export function parseRecord(issue){
+ if(issue.pull_request||issue.state!=="open"||issue.user?.id!==OWNER_ID)return null;
+ const knowledge=issue.title?.startsWith("[知识]"),journal=issue.title?.startsWith("[成长]");
+ if(!knowledge&&!journal)return null;
+ if(!Number.isSafeInteger(issue.number)||issue.number<1)throw new Error("记录编号无效");
+ const confirmation=section(issue.body,"公开确认");
+ if(!confirmation.includes("- [x] "+RECORD_CONSENT)&&!confirmation.includes("- [X] "+RECORD_CONSENT))throw new Error("请勾选公开确认");
+ if(knowledge){
+ const text=section(issue.body,"知识数据").replace(/^```(?:json)?\s*\n?/,"").replace(/\n?```$/,"").trim();
+ let data;try{data=JSON.parse(text)}catch{throw new Error("知识数据必须是从编辑器复制的完整 JSON")}
+ if(data.version!==1||typeof data.spaceId!=="string"||!/^[a-zA-Z0-9_-]{1,80}$/.test(data.spaceId))throw new Error("空间编号不合法");
+ const graph=cleanGraph(data.graph);
+ if(!allowedContent(JSON.stringify(graph)))throw new Error("这份内容属于已屏蔽的项目或主题,不会公开收录");
+ return{kind:"knowledge",id:data.spaceId,graph,issue:issue.number,date:issue.updated_at};
+ }
+ const title=section(issue.body,"记录标题"),date=section(issue.body,"记录日期"),content=section(issue.body,"记录正文"),category=section(issue.body,"记录归属");
+ if(!title||title.length>120||title.includes("\n")||!content||content.length>10000)throw new Error("标题限 120 字,正文限 10000 字,均不能为空");
+ if(!/^\d{4}-\d{2}-\d{2}$/.test(date)||!Number.isFinite(Date.parse(date))||new Date(date).toISOString().slice(0,10)!==date)throw new Error("请填写有效的 YYYY-MM-DD 日期");
+ if(!["我的成长","女儿的成长"].includes(category))throw new Error("请选择记录归属");
+ if(!allowedContent(title+"\n"+content))throw new Error("这份内容属于已屏蔽的项目或主题,不会公开收录");
+ return{kind:"journal",id:issue.number,title,date,scope:category==="我的成长"?"mine":"daughter",content,sourceUrl:"https://github.com/hulingjun/hulingjun.github.io/issues/"+issue.number};
+}
diff --git a/scripts/sync-records.mjs b/scripts/sync-records.mjs
new file mode 100644
index 0000000..76ac8ba
--- /dev/null
+++ b/scripts/sync-records.mjs
@@ -0,0 +1,38 @@
+import {mkdir,writeFile,readFile,copyFile} from "node:fs/promises";
+import path from "node:path";
+import {fileURLToPath} from "node:url";
+import {listIssues} from "./build-gallery.mjs";
+import {parseRecord} from "./record-model.mjs";
+export async function syncRecords(issues,root="."){
+ const content=path.join(root,"content"),publicDir=path.join(root,"github-pages/public/records");
+ for(const dir of [content,path.join(content,"knowledge"),path.join(content,"journal"),publicDir,path.join(publicDir,"knowledge")])await mkdir(dir,{recursive:true});
+ const knowledge=new Map(),journal=[],errors=[];
+ for(const issue of issues){
+ let r;try{r=parseRecord(issue)}catch(e){errors.push({id:issue.number,message:e.message});continue}
+ if(!r)continue;
+ if(r.kind==="knowledge"){if(!knowledge.has(r.id)||knowledge.get(r.id).issue
a.id.localeCompare(b.id))){
+ const name=r.id+".json";const document={version:1,spaceId:r.id,graph:r.graph,issue:r.issue,updatedAt:r.date};
+ await writeFile(path.join(content,"knowledge",name),JSON.stringify(document,null,2)+"\n");
+ await copyFile(path.join(content,"knowledge",name),path.join(publicDir,"knowledge",name));
+ index.knowledge.push({id:r.id,title:r.graph.title,nodeCount:r.graph.nodes.length,date:r.date,issue:r.issue,path:"/records/knowledge/"+name});
+ }
+ for(const r of journal.sort((a,b)=>b.id-a.id)){
+ const {kind,...record}=r;
+ await writeFile(path.join(content,"journal",r.id+".json"),JSON.stringify(record,null,2)+"\n");index.journal.push(record);
+ }
+ await writeFile(path.join(content,"index.json"),JSON.stringify(index,null,2)+"\n");
+ await writeFile(path.join(publicDir,"index.json"),JSON.stringify(index,null,2)+"\n");
+ const report={errors,publishedIds:[...knowledge.values()].map(r=>r.issue).concat(journal.map(r=>r.id))};
+ await writeFile(path.join(root,"records-report.json"),JSON.stringify(report,null,2));
+ return report;
+}
+async function main(){
+ const issues=process.env.GALLERY_FIXTURE?JSON.parse(await readFile(process.env.GALLERY_FIXTURE,"utf8")):await listIssues();
+ const result=await syncRecords(issues);
+ if(process.env.GITHUB_STEP_SUMMARY)await writeFile(process.env.GITHUB_STEP_SUMMARY,"\n## 成长档案\n"+result.publishedIds.length+" 份记录已准备。\n"+result.errors.map(e=>"- #"+e.id+":"+e.message).join("\n"),{flag:"a"});
+}
+if(process.argv[1]&&fileURLToPath(import.meta.url)===path.resolve(process.argv[1]))main().catch(e=>{console.error(e.message);process.exitCode=1});
diff --git a/vite.github-pages.config.ts b/vite.github-pages.config.ts
index ec2d7ff..b4dd2bf 100644
--- a/vite.github-pages.config.ts
+++ b/vite.github-pages.config.ts
@@ -11,6 +11,8 @@ export default defineConfig({
emptyOutDir: true,
rollupOptions: {
input: {
+ art: resolve(__dirname, "github-pages/art/index.html"),
+ learning: resolve(__dirname, "github-pages/learning/index.html"),
home: resolve(__dirname, "github-pages/index.html"),
alpha3d: resolve(__dirname, "github-pages/3d-alpha/index.html"),
knowledge: resolve(__dirname, "github-pages/knowledge/index.html"),