forked from zhongyidian/super_video
feat: 添加 ModuleSwitcher 组件及其子组件,更新 Husky 配置文档
This commit is contained in:
1 parent
cf7a5d5e81
commit
b9c6308d59
5 files changed
+87
-1
No files matched your search
@@ -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>(<scope>): <subject>`
|
||||||
|
|
||||||
|
**允许的 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 会被阻止,需要修复后重新提交
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getBackgroundImage, IMAGE_PATHS } from '@/utils'
|
import { getBackgroundImage, IMAGE_PATHS } from '@/utils'
|
||||||
import { ImgButton } from '@/components/Button'
|
import { ImgButton } from '@/components/Button'
|
||||||
import { ModuleSwitcher } from '@/components/ModuleSwitcher'
|
import { ModuleSwitcher } from './components/ModuleSwitcher'
|
||||||
import { computed, ref, onMounted } from 'vue'
|
import { computed, ref, onMounted } from 'vue'
|
||||||
|
|
||||||
// 响应式状态
|
// 响应式状态
|
||||||
|
|||||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user