调整部分前端布局和后端增删改逻辑

This commit is contained in:
焦龙言
2026-09-20 10:38:10 +08:00
parent acddc8a237
commit 3edba99d2d
227 changed files with 122871 additions and 839 deletions
@@ -12,6 +12,17 @@ export function isDuplicateScan(value, lastValue, scannedAt, lastScannedAt, dupl
return value === lastValue && elapsed >= 0 && elapsed <= duplicateWindowMs
}
export function createIdempotencyKey() {
return globalThis.crypto.randomUUID()
export function createIdempotencyKey(cryptoProvider = globalThis.crypto) {
if (typeof cryptoProvider?.randomUUID === 'function') {
return cryptoProvider.randomUUID()
}
if (typeof cryptoProvider?.getRandomValues !== 'function') {
throw new Error('当前浏览器不支持安全随机数,请使用 HTTPS 或 localhost 访问系统')
}
const bytes = cryptoProvider.getRandomValues(new Uint8Array(16))
bytes[6] = (bytes[6] & 0x0f) | 0x40
bytes[8] = (bytes[8] & 0x3f) | 0x80
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`
}