feat(admin): 新增题库、排行榜、实时结果和模板管理功能

- 添加题库管理页面及相关组件
- 实现排行榜管理功能,包括列表和详情页
- 新增实时结果展示页面
- 添加模板制作和管理功能
- 完善路由配置和国际化支持
- 新增阿里云OSS文件上传服务
- 添加多种工具函数和类型定义
- 优化表格和表单组件
- 调整布局和样式细节
This commit is contained in:
2026-01-22 17:55:35 +08:00
parent d950bb4018
commit 697d606611
47 changed files with 3810 additions and 685 deletions

View File

@ -0,0 +1,48 @@
import path from 'path-browserify';
export function getCurrentYear(): Date {
return new Date();
}
/**
* 得到随机数
* @param min 最小值
* @param max 最大值
* @returns
*/
export function getTrueRandomInt(min: number, max: number) {
const range = max - min + 1;
const maxSafe = 0xffffffff; // 32位最大无符号整数 (2^32 - 1)
let randomValue = 0;
do {
const buffer = new Uint32Array(1);
window.crypto.getRandomValues(buffer);
randomValue = (buffer[0]! / (maxSafe + 1)) * range; // [0, range)
} while (randomValue >= range); // 拒绝采样避免偏差
return Math.floor(randomValue) + min;
}
/**
* 路径拼接
*/
export function browserPathJoin(base: string, ...paths: string[]) {
const [protocol, ...rest] = base.split('://');
if (rest.length > 0) {
const pathPart = rest.join('://').replace(/\/+/g, '/');
return `${protocol}://${path.join(pathPart, ...paths)}`;
}
return path.join(base, ...paths);
}
/**
* 下一个tick后执行
*/
export function nextTickSleep() {
return new Promise((resolve) => {
nextTick(() => {
resolve(true);
});
});
}