feat:蓝牙绑定和在线客服
This commit is contained in:
20
src/utils/device-id.ts
Normal file
20
src/utils/device-id.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
/** 从路由参数等解析 ID,避免 Number() 导致 int64 精度丢失 */
|
||||
export function parseId(raw: unknown): string {
|
||||
if (raw === undefined || raw === null || raw === '') return ''
|
||||
const id = String(raw).trim()
|
||||
return id === '0' ? '' : id
|
||||
}
|
||||
|
||||
/** 从路由参数等解析设备 ID */
|
||||
export function parseDeviceId(raw: unknown): string {
|
||||
return parseId(raw)
|
||||
}
|
||||
|
||||
export function isValidDeviceId(id: string): boolean {
|
||||
return /^\d+$/.test(id)
|
||||
}
|
||||
|
||||
export function sameId(a: unknown, b: unknown): boolean {
|
||||
if (a == null || b == null || a === '' || b === '') return false
|
||||
return String(a) === String(b)
|
||||
}
|
||||
Reference in New Issue
Block a user