迁移 orm 依赖到 drizzle

This commit is contained in:
2025-09-27 10:37:27 +08:00
parent 7fa2fe67ca
commit 72ea29f435
19 changed files with 538 additions and 523 deletions

View File

@@ -6,12 +6,11 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
// 数据验证函数
export const validateNumber = (value: unknown): number => {
if (typeof value === 'number') return value
if (typeof value === 'string') {
const num = parseInt(value)
return isNaN(num) ? 0 : num
}
return 0
// 取数组第一个元素,支持映射
export function first<T>(array: T[]): T | undefined
export function first<T, I>(array: T[], select: (item: T) => I): I | undefined
export function first<T, I>(array: T[], select?: (item: T) => I) {
const item = array.length > 0 ? array[0] : undefined
return select && item ? select(item) : item
}