feat(admin): 新增UUID生成工具并优化模板管理

- 新增 uuid.ts 工具函数,提供原生和兼容性 UUID 生成方案
- 更新模板详情页面,使用 generateUUID() 替代 crypto.randomUUID()
- 模板列表新增页码字段显示
- 优化模板列表组件代码格式,改进可读性
- 更新 Git 提交消息规范文档,强制使用中文描述和具体要求
This commit is contained in:
2026-03-19 11:16:01 +08:00
parent d1f6044a6c
commit 7d49143ae0
4 changed files with 39 additions and 7 deletions

View File

@ -4,6 +4,8 @@ inclusion: auto
# Git 提交消息规范
**重要:所有提交消息必须使用中文!**
本项目严格遵循 [Conventional Commits](https://www.conventionalcommits.org/) 规范。
## 提交消息格式
@ -34,6 +36,7 @@ inclusion: auto
- **revert**: 回退之前的提交
#### Subject (主题)
- **必须使用中文描述**
- 使用简洁的语言描述本次提交的更改
- 不超过 50 个字符
- 首字母小写
@ -61,7 +64,7 @@ inclusion: auto
- Breaking Changes 必须在页脚中以 `BREAKING CHANGE:` 开头
- 关闭 Issue 使用 `Closes #issue号`
## 示例
## 示例(必须使用中文)
### 简单的功能添加
```
@ -94,7 +97,14 @@ BREAKING CHANGE: 用户认证接口从 /api/auth 迁移到 /api/v2/auth
## 重要规则
1. **严格遵循格式**: `<type>(<scope>): <subject>`
2. **type 必须小写**: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
3. **subject 首字母小写**: 不要大写开头
4. **subject 不加句号**: 结尾不要加标点符号
5. **不超过 50 字符**: subject 部分要简洁
6. **破坏性变更**: 必须在 body 中以 `BREAKING CHANGE:` 开头说明
3. **subject 必须使用中文**: 不要使用英文描述
4. **subject 首字母小写**: 不要大写开头
5. **subject 不加句号**: 结尾不要加标点符号
6. **不超过 50 字符**: subject 部分要简洁
7. **破坏性变更**: 必须在 body 中以 `BREAKING CHANGE:` 开头说明
## 生成提交消息时的要求
- 始终使用中文
- 动词开头(如:添加、修复、更新、优化、重构)
- 描述要具体,避免模糊的表述
- 如果有多个更改,选择最主要的作为 subject

View File

@ -0,0 +1,16 @@
/**
* 生成UUID的兼容函数
* 优先使用原生 crypto.randomUUID如果不支持则使用兼容方案
*/
export function generateUUID(): string {
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
return crypto.randomUUID()
}
// 兼容性回退方案 - 生成符合 UUID v4 格式的字符串
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0
const v = c === 'x' ? r : (r & 0x3 | 0x8)
return v.toString(16)
})
}

View File

@ -7,6 +7,7 @@ import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
import { useRouterPush } from '@/hooks/common/router'
import { fetchAddTemplate, fetchTemplateDetail } from '@/service/api/template'
import { generateUUID } from '@/utils/uuid'
import { useUpload } from './hooks/useUpload'
import TemplateCanvas from './modules/TemplateCanvas.vue'
import TemplateSettings from './modules/TemplateSettings.vue'
@ -64,7 +65,7 @@ function handleUploadTrigger() {
* 处理区域生成
*/
function handleGenerate() {
const groupId = crypto.randomUUID()
const groupId = generateUUID()
const newRegions: Region[] = []
// 计算起始编号:查找现有的最大 Qx 编号
@ -85,7 +86,7 @@ function handleGenerate() {
for (let c = 0; c < genSettings.value.cols; c++) {
const index = maxNum + r * genSettings.value.cols + c + 1 // 计算当前区域的编号
newRegions.push({
id: crypto.randomUUID(),
id: generateUUID(),
groupId,
x: currentX + c * (genSettings.value.w + genSettings.value.gapX),
y: currentY + r * (genSettings.value.h + genSettings.value.gapY),

View File

@ -66,6 +66,11 @@ const { columns, columnChecks, data, getData, getDataByPage, loading, mobilePagi
title: '模板ID',
align: 'center',
},
{
key: 'PageNo',
title: '页码',
align: 'center',
},
{
key: 'competitionId',
title: '关联比赛',