Files
JayuCloud/YumiNail-Admin-Program/utils/device.js
T

21 lines
458 B
JavaScript

const { STORAGE_KEYS, getStorage, setStorage } = require('./storage')
function createDeviceId() {
const randomText = Math.random().toString(36).slice(2, 10)
return `admin-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
}