/
rykit
/
lifequest-app
Обзор
Документация
Войти
/
rykit
/
lifequest-app
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/services/deviceIdentity.ts
28 строк
777 B
Rykitik
fix: описал sync payload и conflict policy перед backend skeleton
25 апр 2026, 20:49
25 апр 2026, 20:49
1db8be4
Код
Авторство
О чём код?
const LIFEQUEST_DEVICE_ID_STORAGE_KEY = 'lifequest-device-id' function createDeviceId() { if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') { return crypto.randomUUID() } return `device-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}` } export function getOrCreateDeviceId() { const existingDeviceId = window.localStorage.getItem(LIFEQUEST_DEVICE_ID_STORAGE_KEY) if (existingDeviceId) { return existingDeviceId } const nextDeviceId = createDeviceId() window.localStorage.setItem(LIFEQUEST_DEVICE_ID_STORAGE_KEY, nextDeviceId) return nextDeviceId } export function resetDeviceId() { window.localStorage.removeItem(LIFEQUEST_DEVICE_ID_STORAGE_KEY) } export { LIFEQUEST_DEVICE_ID_STORAGE_KEY }