From fa911a5f21530be14365dfac5dfe6a6e33d1b72f Mon Sep 17 00:00:00 2001 From: cflmy Date: Wed, 2 Dec 2026 14:25:41 +0800 Subject: [PATCH] feat(site): implement approved Marqdo website design Align the homepage grid and document demo, render the traced Three.js hero, and reorganize the ecosystem, research, and download pages. Refs cflmy/marqdo#84 and #1. --- docs/BASELINE.md | 8 + index.mq.md | 4 +- package-lock.json | 67 ++++- package.json | 4 +- scripts/verify-dist.mjs | 11 +- src/components/Demo.astro | 31 +-- src/components/EcosystemMap.astro | 42 +++ src/components/Footer.astro | 4 +- src/components/Header.astro | 6 +- src/components/HeroArt.astro | 60 ++++ src/components/Home.astro | 135 +++------ src/components/Releases.astro | 37 ++- src/components/Section.astro | 23 -- src/components/pages/DownloadPage.astro | 62 ++--- src/components/pages/EcosystemPage.astro | 156 ++++++----- src/components/pages/ResearchPage.astro | 109 ++++---- src/layouts/Site.astro | 16 +- src/lib/hero-art.ts | 9 + src/lib/hero-particles.ts | 126 +++++++++ src/lib/hero-points.json | 332 +++++++++++++++++++++++ src/pages/assets/hero-particles.svg.ts | 9 + src/styles/components.css | 60 ++-- src/styles/demo.css | 34 ++- src/styles/home.css | 125 ++++----- src/styles/layout.css | 3 +- src/styles/site.css | 227 ++++++++++++++-- src/styles/typography.css | 8 +- tests/site.spec.mjs | 114 +++++++- 28 files changed, 1337 insertions(+), 485 deletions(-) create mode 100644 src/components/EcosystemMap.astro create mode 100644 src/components/HeroArt.astro delete mode 100644 src/components/Section.astro create mode 100644 src/lib/hero-art.ts create mode 100644 src/lib/hero-particles.ts create mode 100644 src/lib/hero-points.json create mode 100644 src/pages/assets/hero-particles.svg.ts diff --git a/docs/BASELINE.md b/docs/BASELINE.md index 8074ea9..7611f47 100644 --- a/docs/BASELINE.md +++ b/docs/BASELINE.md @@ -46,3 +46,11 @@ - 生产域名 `https://marqdo.com/` 复核 27/27 通过:首页 H1、页脚两栏中轴误差 0 CSS px、头像位于姓名之上、演示模式切换与计算、非法输入阻断、Wiki 直达与 `/docs/` 迁移、360/390/768/1024/1440 px 无横向溢出、真实 404。 - `www.marqdo.com` 的 DNS 仍走 `a1.initaf.com`(ESA)链路,实测已返回本次构建(12,175 B、含新页脚与演示);正式解析、证书与备案归属仍由维护者确认。 - 当前站点为未接入公开发行数据的构建:`noindex`,下载页显示「尚未接入主仓公开发行快照」,不展示虚构版本或资产。 + +## 官网设计稿对齐候选(2026-12-02) + +- 责任仓为 `cflmy/marqdo-site`,按 [官网 #1](https://git.cflmy.cn/cflmy/marqdo-site/issues/1) 和 [视觉工单 #84](https://git.cflmy.cn/cflmy/marqdo/issues/84) 验收。基线 SHA 为 `ff63306610491fbb932ed99b3674bc4be8683e0c`。在 1440 px Chromium 中打开基线首页,导航与首屏的外框为 x=120 px、宽 1200 px,演示框为 x=40 px、宽 1360 px。 +- 候选按批准的中文浅色稿实现首页(桌面和移动)、生态、研究和下载。验收点覆盖共同外框 x=120 px / 1200 px、桌面演示 38:34:28、移动端标题与操作先于静态插画、生态按职责分组与真实依赖、研究锚点和下载产品选择。中文与英文、深浅主题使用同一套布局。真实文稿、Logo、头像、站点身份和发布快照继续由现有输入提供。图稿按静态版式参照,实际字体渲染、动效帧和真实内容会产生像素差异。 +- Linux x86_64,Node.js 24.22.3、npm 11.19.1。以下命令在候选上退出码均为 0:`npm ci --offline --no-audit`、`npm run check`(36 文件,无诊断)、`npm test`(5 项)、`python3 -B -m unittest discover -s tests -p '*_test.py'`(11 项)、`bash scripts/prepare-example.sh`、`npm run build`(21 个页面)、`npm run test:e2e -- --workers=2`(Chromium,18 项)。固定 CLI/View 归档通过摘要校验,圆面积 0、1、3 的真实调用和 View 静态导出通过。 +- Chromium 截图覆盖 1440 px 桌面及 390 px 移动首页、生态、研究、下载和深色首页。用 SwiftShader WebGL 2 渲染两次不同粒子帧,再触发上下文丢失验证海报恢复。手机、减少动态效果偏好及无 WebGL 的静态路径已验收。构建首页入口脚本 2688 B gzip,静态海报 20041 B gzip,延迟加载的 Three.js 场景 147610 B gzip。Vite 仍会提示该延迟块的未压缩体积超过 500 kB。 +- 本地 `dist/index.html` SHA-256 为 `a850edff8a07a720d1eba419a4636e89f278f431c19c1bf12b336bc4cf65fdf3`。静态海报 SHA-256 为 `7b1a2c34ebed7f05203291ad6a78b7e1b1ff84e49562ec592be73ea8302bc57c`。候选 Woodpecker 与 EdgeOne 预览、生产发布为 UNVERIFIED。 diff --git a/index.mq.md b/index.mq.md index 7f28543..8981316 100644 --- a/index.mq.md +++ b/index.mq.md @@ -15,9 +15,9 @@ ## 视觉体系 -语义颜色、字体、容器和间距分别由 `src/styles/tokens.css`、`typography.css`、`layout.css`、`components.css` 定义;首页与三栏文稿演示的专用样式在 `home.css`、`demo.css`。页面不得自行引入色值、字号或宽度。 +语义颜色、字体、容器和间距分别由 `src/styles/tokens.css`、`typography.css`、`layout.css`、`components.css` 定义;首页与三栏文稿演示的专用样式在 `home.css`、`demo.css`。导航、主要页面内容与页脚共用 1200 CSS px 容器,窄屏保留至少 16 px 侧边距。 -首页保留「从一篇文稿开始」的源码 / 知识阅读 / 交互计算三栏演示与四种查看模式;宽屏默认并排,窄屏默认单栏但保留全部模式。浏览器演示使用固定圆面积公式,与 CLI 实测证据相互独立。 +首页保留「从一篇文稿开始」的源码 / 知识阅读 / 交互计算三栏演示与四种查看模式;宽屏默认 38:34:28 并排,窄屏默认「知识阅读」,四种模式均可切换。首屏的设计点阵同时提供静态海报与 Three.js 动效,宽屏可见且允许动画、支持 WebGL 2 时才加载动效模块。浏览器演示使用固定圆面积公式,与 CLI 实测证据相互独立。 ## 运行 diff --git a/package-lock.json b/package-lock.json index adfd3f0..e29fb87 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,14 @@ "dependencies": { "@astrojs/check": "0.9.12", "astro": "7.4.14", + "three": "0.187.0", "typescript": "6.0.3", "zod": "4.6.7" }, "devDependencies": { "@playwright/test": "1.65.2", - "@types/node": "24.19.4" + "@types/node": "24.19.4", + "@types/three": "0.187.0" }, "engines": { "node": "24.22.3" @@ -714,6 +716,13 @@ "node": ">= 20.12.0" } }, + "node_modules/@dimforge/rapier3d-compat": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/@dimforge/rapier3d-compat/-/rapier3d-compat-0.12.0.tgz", + "integrity": "sha512-uekIGetywIgopfD97oDL5PfeezkFpNhwlzlaEYNOA0N6ghdsOvh/HYjSMek5Q2O1PYvRSDFcqFVJl4r4ZBwOow==", + "dev": true, + "license": "Apache-2.0" + }, "node_modules/@emmetio/abbreviation": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/@emmetio/abbreviation/-/abbreviation-2.3.3.tgz", @@ -1783,6 +1792,13 @@ "integrity": "sha512-cVBuhDQjBZaNMTwBquYfPydrUP+E3hE6oYGasx8h6ZrODIM7/r+gxLDXdd66oszbrggZHEntdE6j+5gYIVyMWQ==", "license": "MIT" }, + "node_modules/@tweenjs/tween.js": { + "version": "23.1.3", + "resolved": "https://registry.npmjs.org/@tweenjs/tween.js/-/tween.js-23.1.3.tgz", + "integrity": "sha512-vJmvvwFxYuGnF2axRtPYocag6Clbb5YS7kLL+SO/TeVFzHqDIWrNKYtcsPMibjDx9O+bu+psAy9NKfWklassUA==", + "dev": true, + "license": "MIT" + }, "node_modules/@tybys/wasm-util": { "version": "0.10.5", "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", @@ -1844,12 +1860,41 @@ "undici-types": ">=7.24.0 <7.24.7" } }, + "node_modules/@types/stats.js": { + "version": "0.17.4", + "resolved": "https://registry.npmjs.org/@types/stats.js/-/stats.js-0.17.4.tgz", + "integrity": "sha512-jIBvWWShCvlBqBNIZt0KAshWpvSjhkwkEu4ZUcASoAvhmrgAUI2t1dXrjSL4xXVLB4FznPrIsX3nKXFl/Dt4vA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/three": { + "version": "0.187.0", + "resolved": "https://registry.npmjs.org/@types/three/-/three-0.187.0.tgz", + "integrity": "sha512-v+vKNarUtk4n2QRZ4+CN5ygMM0ARUjXjIQl0R/unMUfmStFeVqGbgqarbrpoGTXRZoulSH16ePrVJVxPJEbMUA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@dimforge/rapier3d-compat": "~0.12.0", + "@tweenjs/tween.js": "~23.1.3", + "@types/stats.js": "*", + "@types/webxr": ">=0.5.17", + "fflate": "~0.8.3", + "meshoptimizer": "~1.1.1" + } + }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", "integrity": "sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==", "license": "MIT" }, + "node_modules/@types/webxr": { + "version": "0.5.24", + "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.5.24.tgz", + "integrity": "sha512-h8fgEd/DpoS9CBrjEQXR+dIDraopAEfu4wYVNY2tEPwk60stPWhvZMf4Foo5FakuQ7HFZoa8WceaWFervK2Ovg==", + "dev": true, + "license": "MIT" + }, "node_modules/@ungap/structured-clone": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.4.0.tgz", @@ -2667,6 +2712,13 @@ } } }, + "node_modules/fflate": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.8.3.tgz", + "integrity": "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA==", + "dev": true, + "license": "MIT" + }, "node_modules/flattie": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/flattie/-/flattie-1.1.1.tgz", @@ -3208,6 +3260,13 @@ "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==", "license": "CC0-1.0" }, + "node_modules/meshoptimizer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/meshoptimizer/-/meshoptimizer-1.1.1.tgz", + "integrity": "sha512-oRFNWJRDA/WTrVj7NWvqa5HqE1t9MYDj2VaWirQCzCCrAd2GHrqR/sQezCxiWATPNlKTcRaPRHPJwIRoPBAp5g==", + "dev": true, + "license": "MIT" + }, "node_modules/micromark-util-character": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", @@ -3962,6 +4021,12 @@ "url": "https://opencollective.com/svgo" } }, + "node_modules/three": { + "version": "0.187.0", + "resolved": "https://registry.npmjs.org/three/-/three-0.187.0.tgz", + "integrity": "sha512-Qiu7R+Cmh8CstZsY1uJOSWnVlfo7ZtNLV7mF8Jltk3LB3AtDu9cRZlcnRKkAk8Y4z6KKw35z7Y7Urd7jWY8etA==", + "license": "MIT" + }, "node_modules/tiny-inflate": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/tiny-inflate/-/tiny-inflate-1.0.3.tgz", diff --git a/package.json b/package.json index 829f54d..3596d4c 100644 --- a/package.json +++ b/package.json @@ -2,12 +2,14 @@ "dependencies": { "@astrojs/check": "0.9.12", "astro": "7.4.14", + "three": "0.187.0", "typescript": "6.0.3", "zod": "4.6.7" }, "devDependencies": { "@playwright/test": "1.65.2", - "@types/node": "24.19.4" + "@types/node": "24.19.4", + "@types/three": "0.187.0" }, "name": "marqdo-site", "version": "0.1.0", diff --git a/scripts/verify-dist.mjs b/scripts/verify-dist.mjs index 0767ef0..a56772b 100644 --- a/scripts/verify-dist.mjs +++ b/scripts/verify-dist.mjs @@ -33,7 +33,7 @@ for (const [path, html] of documents) { } } -for (const file of ['assets/logo.svg', 'assets/cflmy.jpg', 'assets/social.png', 'assets/geometry.mq.md', 'robots.txt', 'sitemap.xml']) { +for (const file of ['assets/logo.svg', 'assets/hero-particles.svg', 'assets/cflmy.jpg', 'assets/social.png', 'assets/geometry.mq.md', 'robots.txt', 'sitemap.xml']) { assert.ok(existsSync(join(dist, file)), `Missing ${file}`); } // The documentation search index was removed with the in-site docs body. @@ -58,5 +58,12 @@ assert.match(home, /查看 CLI 命令与实测依据/); const homeScripts = [...home.matchAll(/]* src="(\/[^"]+)"/g)].map(hit => hit[1]); const compressed = homeScripts.reduce((size, file) => size + gzipSync(readFileSync(dist + file)).length, 0); assert.ok(compressed <= 150 * 1024, `Home JS exceeds 150 KiB: ${compressed}`); +const particleChunks = readdirSync(join(dist, '_astro')).filter(name => /^hero-particles\.[\w-]+\.js$/.test(name)); +assert.equal(particleChunks.length, 1, 'Expected one lazy hero particle chunk'); +assert.ok(!home.includes(particleChunks[0]), 'The particle chunk must not appear in initial homepage HTML'); +const particleBytes = gzipSync(readFileSync(join(dist, '_astro', particleChunks[0]))).length; +assert.ok(particleBytes < 180 * 1024, `Lazy particle bundle exceeds 180 KiB: ${particleBytes}`); +const posterBytes = gzipSync(readFileSync(join(dist, 'assets/hero-particles.svg'))).length; +assert.ok(posterBytes < 25 * 1024, `Hero poster exceeds 25 KiB: ${posterBytes}`); assert.ok(!readdirSync(dist).some(name => name.startsWith('.') || name === 'data'), 'Unexpected output root entries'); -console.log(`Verified ${paths.length} HTML pages, local references and anchors; homepage JS ${compressed} bytes gzip.`); +console.log(`Verified ${paths.length} HTML pages, local references and anchors; initial homepage JS ${compressed} bytes gzip, lazy particles ${particleBytes} bytes gzip, poster ${posterBytes} bytes gzip.`); diff --git a/src/components/Demo.astro b/src/components/Demo.astro index 569213e..bd2056e 100644 --- a/src/components/Demo.astro +++ b/src/components/Demo.astro @@ -1,5 +1,6 @@ --- import source from '../../examples/geometry.mq.md?raw'; +import { circleArea } from '../lib/geometry.mts'; import { choose, url, type Locale } from '../config/site'; const { locale } = Astro.props as { locale: Locale }; const t = (zh: T, en: T) => choose(locale, zh, en); @@ -16,6 +17,8 @@ const highlighted = source.trim().split('\n').map(line => { return escaped; }).join('\n'); +const initialRadius = 3; +const initialArea = circleArea(initialRadius); const modes = [ { id: 'compare', label: t('并排查看', 'Compare') }, { id: 'source', label: t('源码', 'Source') }, @@ -64,16 +67,15 @@ const modes = [
- {t('浏览器演示 · 固定公式', 'Browser demo · fixed formula')}

{t('计算圆的面积', 'Calculate the area')}

@@ -114,10 +116,10 @@ const modes = [ buttons.forEach(button => { button.addEventListener('click', () => { mode = button.dataset.mode!; render(); }); }); - // Narrow screens cannot read three columns at once: open in source view but + // Narrow screens cannot read three columns at once: open in reading view but // keep every mode available. Resizing does not silently reset the demo. - const narrow = window.matchMedia('(max-width: 74.9375rem)'); - if (narrow.matches) { mode = 'source'; render(); } + const narrow = window.matchMedia('(width < 68rem)'); + if (narrow.matches) { mode = 'reading'; render(); } const form = demo.querySelector('[data-geometry]')!; const input = form.querySelector('input')!; @@ -129,7 +131,7 @@ const modes = [ const radiusLabel = circleGroup.querySelector('text.radius-label')!; const error = demo.dataset.error!; const stale = demo.dataset.stale!; - let executed: number | null = null; + let hasResult = true; form.hidden = false; @@ -153,7 +155,7 @@ const modes = [ input.addEventListener('input', () => { input.removeAttribute('aria-invalid'); - if (executed !== null) { + if (hasResult) { status.textContent = stale; status.className = 'status status--stale'; output.dataset.stale = 'true'; @@ -169,21 +171,18 @@ const modes = [ const area = circleArea(submitted); if (area === null) { input.setAttribute('aria-invalid', 'true'); - executed = null; + hasResult = false; output.hidden = true; status.textContent = error; status.className = 'status status--error'; return; } input.removeAttribute('aria-invalid'); - executed = submitted; + hasResult = true; output.dataset.stale = 'false'; - output.replaceChildren(); - const value = document.createElement('strong'); - value.textContent = `S = ${area.toFixed(6)}`; - const meta = document.createElement('span'); - meta.textContent = `${'r ='} ${submitted} · ${area}`; - output.append(value, meta); + const value = output.querySelector('strong')!; + value.textContent = area.toFixed(4); + value.title = String(area); output.hidden = false; status.textContent = ''; status.className = 'status'; diff --git a/src/components/EcosystemMap.astro b/src/components/EcosystemMap.astro new file mode 100644 index 0000000..7563986 --- /dev/null +++ b/src/components/EcosystemMap.astro @@ -0,0 +1,42 @@ +--- +import { choose, url, type Locale } from '../config/site'; +interface Props { locale: Locale; compact?: boolean; catalogRef?: string; } +const { locale, compact = false, catalogRef } = Astro.props; +const t = (zh: T, en: T) => choose(locale, zh, en); +const groups: { label: string; tiles: { title: string; detail?: string }[] }[] = [ + { + label: t('语言核心', 'Language core'), + tiles: [{ title: 'Marqdo CLI', detail: t('解析、编译与执行', 'Parsing, compilation, and execution') }], + }, + { + label: t('生态组件', 'Ecosystem components'), + tiles: [{ title: t('标准库', 'Standard libraries') }, { title: t('扩展', 'Extensions') }, { title: t('工具', 'Tools') }], + }, + { + label: t('应用入口', 'Application entry'), + tiles: [{ title: 'MQDH', detail: t('面向用户的应用', 'User-facing application') }], + }, +]; +--- +
+
+ {compact ? t('按职责分组', 'Grouped by responsibility') : t('按职责分组 · 运行依赖见组件登记', 'Grouped by responsibility · See the component catalog for runtime dependencies')} + {compact + ? {t('探索完整生态', 'Explore the ecosystem')} + : {t('主仓组件登记', 'Root component catalog')}} +
+
+ {groups.map(({ label, tiles }) => ( +
+
{label}
+
+
    + {tiles.map(({ title, detail }) => ( +
  • {title}{!compact && detail && {detail}}
  • + ))} +
+
+
+ ))} +
+
diff --git a/src/components/Footer.astro b/src/components/Footer.astro index 53f979b..027ae2f 100644 --- a/src/components/Footer.astro +++ b/src/components/Footer.astro @@ -4,7 +4,7 @@ const { locale } = Astro.props as { locale: Locale }; const t = (zh: T, en: T) => choose(locale, zh, en); ---