功能:新增业务接口与扫码组件
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
export function normalizeScanValue(value) {
|
||||
const normalizedValue = String(value ?? '').trim()
|
||||
if (!normalizedValue) {
|
||||
throw new Error('二维码不能为空')
|
||||
}
|
||||
|
||||
return normalizedValue
|
||||
}
|
||||
|
||||
export function isDuplicateScan(value, lastValue, scannedAt, lastScannedAt, duplicateWindowMs) {
|
||||
const elapsed = scannedAt - lastScannedAt
|
||||
return value === lastValue && elapsed >= 0 && elapsed <= duplicateWindowMs
|
||||
}
|
||||
|
||||
export function createIdempotencyKey() {
|
||||
return globalThis.crypto.randomUUID()
|
||||
}
|
||||
Reference in New Issue
Block a user