From b9c6308d591168bd8c4060c1fee4cf761d22a81f Mon Sep 17 00:00:00 2001 From: zhongyingmin Date: Sun, 14 Sep 2025 11:45:45 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20ModuleSwitcher=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=8F=8A=E5=85=B6=E5=AD=90=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=20Husky=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HUSKY_SETUP.md | 86 +++++++++++++++++++ src/views/home/action.vue | 2 +- .../ModuleSwitcher/ModuleButton.vue | 0 .../ModuleSwitcher/ModuleSwitcher.vue | 0 .../home}/components/ModuleSwitcher/index.ts | 0 5 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 HUSKY_SETUP.md rename src/{ => views/home}/components/ModuleSwitcher/ModuleButton.vue (100%) rename src/{ => views/home}/components/ModuleSwitcher/ModuleSwitcher.vue (100%) rename src/{ => views/home}/components/ModuleSwitcher/index.ts (100%) diff --git a/HUSKY_SETUP.md b/HUSKY_SETUP.md new file mode 100644 index 0000000..21a3f72 --- /dev/null +++ b/HUSKY_SETUP.md @@ -0,0 +1,86 @@ +# Husky 配置说明 + +## 已安装的依赖 + +- `husky`: Git hooks 管理工具 +- `lint-staged`: 对暂存文件运行 linters +- `@commitlint/cli`: Commit 信息验证工具 +- `@commitlint/config-conventional`: 约定式提交规范 + +## 配置内容 + +### 1. Pre-commit 钩子 + +在每次 commit 前自动执行: + +- ESLint 检查和自动修复 +- Prettier 代码格式化 + +### 2. Commit-msg 钩子 + +验证 commit 信息格式,必须符合约定式提交规范: + +**格式**: `(): ` + +**允许的 type 类型**: + +- `feat`: 新功能 +- `fix`: 修复 bug +- `docs`: 文档更新 +- `style`: 代码格式调整 +- `refactor`: 代码重构 +- `perf`: 性能优化 +- `test`: 测试相关 +- `build`: 构建相关 +- `ci`: CI/CD 相关 +- `chore`: 其他杂务 +- `revert`: 回滚提交 + +**规则**: + +- subject 最大长度: 50 字符 +- body 每行最大长度: 100 字符 +- subject 不能使用句首大写、帕斯卡命名等格式 + +### 3. Prettier 配置 + +已创建 `.prettierrc` 配置文件,统一代码格式: + +- 不使用分号 +- 使用单引号 +- 缩进 2 个空格 +- 行宽限制 100 字符 +- 不使用尾随逗号 + +## 使用方法 + +### 正常提交 + +```bash +git add . +git commit -m "feat: 添加新功能" +``` + +### 如果 commit 信息不符合规范 + +```bash +git commit -m "invalid message" +# 会提示错误并要求修改 +``` + +### 手动运行检查 + +```bash +# 检查代码格式 +npx lint-staged + +# 检查 commit 信息 +echo "feat: 测试" | npx commitlint +``` + +## 注意事项 + +1. 确保使用 `nvm use 22.14` 切换到正确的 Node.js 版本 +2. 使用 `pnpm` 作为包管理器 +3. 所有代码在提交前会自动进行格式化和检查 +4. 如果检查失败,commit 会被阻止,需要修复后重新提交 diff --git a/src/views/home/action.vue b/src/views/home/action.vue index 23a880b..d48098c 100644 --- a/src/views/home/action.vue +++ b/src/views/home/action.vue @@ -1,7 +1,7 @@