功能:收口小程序前后台安全与防重复提交
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
const { STORAGE_KEYS, getStorage, setStorage } = require('./storage')
|
||||
|
||||
function createDeviceId() {
|
||||
const randomText = Math.random().toString(36).slice(2, 10)
|
||||
return `mini-device-${Date.now()}-${randomText}`
|
||||
}
|
||||
|
||||
function getDeviceId() {
|
||||
let value = getStorage(STORAGE_KEYS.DEVICE_ID, '')
|
||||
if (value) {
|
||||
return value
|
||||
}
|
||||
value = createDeviceId()
|
||||
setStorage(STORAGE_KEYS.DEVICE_ID, value)
|
||||
return value
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getDeviceId
|
||||
}
|
||||
Reference in New Issue
Block a user