From 2d5b8c35b8a90a29051040e685b45bc693b81044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A5=80=E6=A2=A6?= <3501646051@qq.com> Date: Sun, 29 Mar 2026 10:05:49 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E7=A7=BB=E9=99=A4=20LeetCode=20?= =?UTF-8?q?=E7=AC=94=E8=AE=B0=E5=B9=B6=E5=8A=A0=E5=85=A5=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E4=B8=8E=20Agent=20=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 从 collections、导航移除 LeetCode,删除 docs/notes/programming/leetcode 下页面 - devDependencies 显式加入 @vuepress/helper@rc.123,配合 overrides 降低 Vite 预构建白屏风险 - 新增 npm run docs:verify 与 scripts/verify-site.mjs(构建后检查首页 hero) - .cursor/rules/agent-workflow-verify-and-git.mdc:每次修改须验证;用户未明确说不要提交时默认 commit Made-with: Cursor --- .../rules/agent-workflow-verify-and-git.mdc | 30 ++++++++++++++ docs/.vuepress/collections.ts | 17 -------- docs/.vuepress/navbar.ts | 4 -- docs/notes/programming/leetcode/README.md | 40 ------------------- docs/notes/programming/leetcode/beginner.md | 13 ------ package-lock.json | 1 + package.json | 2 + scripts/verify-site.mjs | 27 +++++++++++++ 8 files changed, 60 insertions(+), 74 deletions(-) create mode 100644 .cursor/rules/agent-workflow-verify-and-git.mdc delete mode 100644 docs/notes/programming/leetcode/README.md delete mode 100644 docs/notes/programming/leetcode/beginner.md create mode 100644 scripts/verify-site.mjs diff --git a/.cursor/rules/agent-workflow-verify-and-git.mdc b/.cursor/rules/agent-workflow-verify-and-git.mdc new file mode 100644 index 0000000..6bca25c --- /dev/null +++ b/.cursor/rules/agent-workflow-verify-and-git.mdc @@ -0,0 +1,30 @@ +--- +description: 每次站点相关修改后须本地构建/启动并验证;Git 提交默认策略(除非用户明确不要提交) +alwaysApply: true +--- + +# Agent 工作流:验证站点与 Git 提交 + +## 修改后必须自行验证(硬性要求) + +凡改动 **VuePress / Plume 配置、`docs/` 下内容与主题相关代码** 等会影响站点展示或 dev/build 的行为时,**在本轮任务结束前必须**完成下列至少一项,并确认 **首页等主要页面非白屏**、**无控制台致命报错**(开发模式下可 F12 查看): + +1. **推荐(与线上最接近)**:在项目根执行 + `npm run docs:build` + 然后执行 + `npm run docs:verify` + (会检查 `docs/.vuepress/dist/index.html` 是否包含首页 hero 结构。) + +2. **若重点验证热更新 / 开发体验**:执行 + `npm run docs:dev-clean` + (`--clean-cache --clean-temp` 可避免 **Vite 预构建缓存** 仍指向旧版 `@vuepress/helper`,从而触发 **`encodeSVG` 导出缺失、整站白屏**。) + 在浏览器打开本地地址,确认首页 hero 与导航正常。 + +**白屏常见原因速记**:`@vuepress/plugin-markdown-chart` 等依赖需要 `@vuepress/helper/client` 导出 `encodeSVG`;若 `docs/.vuepress/.cache` 里预打包了过旧的 helper,会出现 **仅 dev 白屏、build 正常**。处理:删缓存或用 `docs:dev-clean` / `docs:build`(脚本已带 clean)。 + +## Git 提交策略 + +- **默认**:在用户**未**于本轮对话中明确要求 **「不要提交」「暂不 commit」「仅改代码不要 git」** 等前提下,在 **验证通过** 后 **应执行 `git add` + `git commit`**,用清晰的中文说明提交内容。 +- **例外**:用户明确只要改代码、**由其本人审核后再提交**时,**不执行** commit。 + +**注意**:构建产物目录 **`docs/.vuepress/dist`**、缓存 **`.cache` / `.temp`** 已在 `.gitignore` 中,**不要**将编译输出提交进源码仓。 diff --git a/docs/.vuepress/collections.ts b/docs/.vuepress/collections.ts index dec3de3..5aed9e4 100644 --- a/docs/.vuepress/collections.ts +++ b/docs/.vuepress/collections.ts @@ -28,23 +28,6 @@ export default defineCollections([ })), }), - defineCollection({ - type: 'doc', - dir: 'notes/programming/leetcode', - title: 'LeetCode', - linkPrefix: '/programming/leetcode/', - sidebar: [ - { text: 'LeetCode 指南', link: '/programming/leetcode/' }, - { - text: '刷题题单', - prefix: '/question_sheet', - items: [ - { text: 'LeetCode 入门题单~(≧∇≦)ノ', link: '/programming/leetcode/question_sheet/beginner/' }, - ], - }, - ], - }), - defineCollection({ type: 'doc', dir: 'notes/subject/english', diff --git a/docs/.vuepress/navbar.ts b/docs/.vuepress/navbar.ts index 6434dfe..5141647 100644 --- a/docs/.vuepress/navbar.ts +++ b/docs/.vuepress/navbar.ts @@ -25,10 +25,6 @@ export default defineNavbarConfig([ { text: '编程笔记', items: [ - { - text: 'LeetCode', - link: '/programming/leetcode/', - }, { text: 'Solidity', link: '/programming/solidity/', diff --git a/docs/notes/programming/leetcode/README.md b/docs/notes/programming/leetcode/README.md deleted file mode 100644 index a2c9fbe..0000000 --- a/docs/notes/programming/leetcode/README.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: LeetCode 题解笔记 -description: 记录LeetCode算法题的解题思路和代码实现 -createTime: 2025/09/22 08:09:52 -permalink: /programming/leetcode/ ---- - -# LeetCode 题解笔记 - -这里是我在LeetCode刷题过程中记录的解题思路和代码实现。通过整理这些题解,希望能够提高自己的算法水平和编程能力。 - -## 题解分类 - -### 数组与字符串 - -- [两数之和](https://leetcode-cn.com/problems/two-sum/) -- [三数之和](https://leetcode-cn.com/problems/3sum/) - -### 链表 - -- [反转链表](https://leetcode-cn.com/problems/reverse-linked-list/) -- [合并两个有序链表](https://leetcode-cn.com/problems/merge-two-sorted-lists/) - -### 动态规划 - -- [爬楼梯](https://leetcode-cn.com/problems/climbing-stairs/) -- [最长回文子串](https://leetcode-cn.com/problems/longest-palindromic-substring/) - -## 解题技巧 - -1. **双指针法**:常用于数组、链表问题,如两数之和、反转链表等 -2. **滑动窗口**:处理字符串子串问题 -3. **动态规划**:将原问题分解为子问题,自底向上求解 -4. **分治法**:将问题分成若干子问题,分别求解后合并结果 - -## 学习资源 - -- [LeetCode官方题解](https://leetcode-cn.com/problemset/all/) -- [代码随想录](https://programmercarl.com/) -- [算法导论](https://mitpress.mit.edu/books/introduction-algorithms) diff --git a/docs/notes/programming/leetcode/beginner.md b/docs/notes/programming/leetcode/beginner.md deleted file mode 100644 index 36b1375..0000000 --- a/docs/notes/programming/leetcode/beginner.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: LeetCode 入门题单~(≧∇≦)ノ -description: 给算法初学者的题目推荐和学习路径 -createTime: 2025年9月22日 08:52:52 -permalink: /programming/leetcode/question_sheet/beginner/ ---- -# LeetCode 入门题单~(๑>◡<๑) - -作为算法初学者,选择合适的题目开始练习真的超~级重要哦!这里给大家推荐一份超棒的入门题单——[「新」动计划 · 编程入门](https://leetcode.cn/studyplan/primers-list/) ~这份题单就像给小树苗精心准备的阳光和雨露一样,特别适合刚开始算法之旅的你~(悄悄告诉你,里面有两题是数据库基础,暂时可以跳过哦~) - -我的小建议是:先自己试着挑战一下,如果遇到困难了,再来看题解也没关系~重要的是享受这个成长的过程呀~(♡˙︶˙♡) - -## 基础语法 & 数据类型 ٩(๑>◡<๑)۶ diff --git a/package-lock.json b/package-lock.json index 4cb227a..1258f77 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ }, "devDependencies": { "@vuepress/bundler-vite": "2.0.0-rc.26", + "@vuepress/helper": "2.0.0-rc.123", "@vuepress/plugin-umami-analytics": "2.0.0-rc.112", "artalk": "^2.9.1", "http-server": "^14.1.1", diff --git a/package.json b/package.json index 887f11a..b8a95f6 100644 --- a/package.json +++ b/package.json @@ -14,10 +14,12 @@ "docs:dev": "vuepress dev docs", "docs:dev-clean": "vuepress dev docs --clean-cache --clean-temp", "docs:build": "vuepress build docs --clean-cache --clean-temp", + "docs:verify": "node scripts/verify-site.mjs", "docs:preview": "http-server docs/.vuepress/dist", "vp-update": "npx vp-update" }, "devDependencies": { + "@vuepress/helper": "2.0.0-rc.123", "@vuepress/bundler-vite": "2.0.0-rc.26", "@vuepress/plugin-umami-analytics": "2.0.0-rc.112", "artalk": "^2.9.1", diff --git a/scripts/verify-site.mjs b/scripts/verify-site.mjs new file mode 100644 index 0000000..f276f53 --- /dev/null +++ b/scripts/verify-site.mjs @@ -0,0 +1,27 @@ +import { readFileSync, existsSync } from 'node:fs' +import { spawnSync } from 'node:child_process' +import { fileURLToPath } from 'node:url' +import { dirname, join } from 'node:path' + +const root = join(dirname(fileURLToPath(import.meta.url)), '..') +const indexHtml = join(root, 'docs', '.vuepress', 'dist', 'index.html') + +const build = spawnSync('npm', ['run', 'docs:build'], { + cwd: root, + shell: true, + stdio: 'inherit', +}) +if (build.status !== 0) process.exit(build.status ?? 1) + +if (!existsSync(indexHtml)) { + console.error('verify-site: dist/index.html missing after build') + process.exit(1) +} + +const html = readFileSync(indexHtml, 'utf8') +if (!html.includes('hero-name') || !html.includes('仲夏夜之梦')) { + console.error('verify-site: home hero markers missing in dist/index.html (possible theme/render failure)') + process.exit(1) +} + +console.log('verify-site: OK (home hero present in production build)')