提交 a23f5f56 编写于 作者: Q qiang

fix: uuid -> deviceId

上级 ddf13ee4
...@@ -37,8 +37,7 @@ ...@@ -37,8 +37,7 @@
"base64-arraybuffer": "^0.2.0", "base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0", "intersection-observer": "^0.7.0",
"pako": "^1.0.11", "pako": "^1.0.11",
"safe-area-insets": "^1.4.1", "safe-area-insets": "^1.4.1"
"uuid": "3.4.0"
}, },
"private": true, "private": true,
"devDependencies": { "devDependencies": {
......
let uuid let deviceId
export default function () { export default function () {
uuid = uuid || plus.runtime.getDCloudId() deviceId = deviceId || plus.runtime.getDCloudId()
return uuid return deviceId
} }
...@@ -11,7 +11,7 @@ import tabBar from '../../framework/tab-bar' ...@@ -11,7 +11,7 @@ import tabBar from '../../framework/tab-bar'
import { getStatusbarHeight } from 'uni-platform/helpers/status-bar' import { getStatusbarHeight } from 'uni-platform/helpers/status-bar'
import uuid from 'uni-platform/helpers/uuid' import deviceId from 'uni-platform/helpers/uuid'
export function getSystemInfoSync () { export function getSystemInfoSync () {
return callApiSync(getSystemInfo, Object.create(null), 'getSystemInfo', 'getSystemInfoSync') return callApiSync(getSystemInfo, Object.create(null), 'getSystemInfo', 'getSystemInfoSync')
...@@ -100,6 +100,6 @@ export function getSystemInfo () { ...@@ -100,6 +100,6 @@ export function getSystemInfo () {
bottom: safeAreaInsets.bottom, bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left left: safeAreaInsets.left
}, },
uuid: uuid() deviceId: deviceId()
} }
} }
import { v4 as uuidv4 } from 'uuid' const UUID_KEY = '__DC_STAT_UUID'
const UUID_KEY = '__DC_UUID'
const storage = window.localStorage || window.sessionStorage || {} const storage = window.localStorage || window.sessionStorage || {}
let uuid let deviceId
export default function () { export default function () {
uuid = uuid || storage[UUID_KEY] deviceId = deviceId || storage[UUID_KEY]
if (!uuid) { if (!deviceId) {
uuid = uuidv4() deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
try { try {
storage[UUID_KEY] = uuid storage[UUID_KEY] = deviceId
} catch (error) { } catch (error) {
} }
} }
return uuid return deviceId
} }
import getWindowOffset from 'uni-platform/helpers/get-window-offset' import getWindowOffset from 'uni-platform/helpers/get-window-offset'
import uuid from 'uni-platform/helpers/uuid' import deviceId from 'uni-platform/helpers/uuid'
import safeAreaInsets from 'safe-area-insets' import safeAreaInsets from 'safe-area-insets'
const ua = navigator.userAgent const ua = navigator.userAgent
...@@ -113,7 +113,7 @@ export function getSystemInfoSync () { ...@@ -113,7 +113,7 @@ export function getSystemInfoSync () {
bottom: safeAreaInsets.bottom, bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left left: safeAreaInsets.left
}, },
uuid: uuid() deviceId: deviceId()
} }
} }
/** /**
......
import { v4 as uuidv4 } from 'uuid'
import { getStorageSync } from './storage' import { getStorageSync } from './storage'
const UUID_KEY = '__DC_UUID' const UUID_KEY = '__DC_STAT_UUID'
let uuid let deviceId
function addUuid (result) { function addUuid (result) {
uuid = uuid || getStorageSync(UUID_KEY) deviceId = deviceId || getStorageSync(UUID_KEY)
if (!uuid) { if (!deviceId) {
uuid = uuidv4() deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
__GLOBAL__.setStorage({ __GLOBAL__.setStorage({
key: UUID_KEY, key: UUID_KEY,
data: uuid data: deviceId
}) })
} }
result.uuid = uuid result.deviceId = deviceId
} }
function addSafeAreaInsets (result) { function addSafeAreaInsets (result) {
......
import { v4 as uuidv4 } from 'uuid' const UUID_KEY = '__DC_STAT_UUID'
let deviceId
const UUID_KEY = '__DC_UUID'
let uuid
function addUuid (result) { function addUuid (result) {
uuid = uuid || __GLOBAL__.getStorageSync(UUID_KEY) deviceId = deviceId || __GLOBAL__.getStorageSync(UUID_KEY)
if (!uuid) { if (!deviceId) {
uuid = uuidv4() deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
__GLOBAL__.setStorage({ __GLOBAL__.setStorage({
key: UUID_KEY, key: UUID_KEY,
data: uuid data: deviceId
}) })
} }
result.uuid = uuid result.deviceId = deviceId
} }
function addSafeAreaInsets (result) { function addSafeAreaInsets (result) {
......
...@@ -8965,7 +8965,7 @@ utils-merge@1.0.1: ...@@ -8965,7 +8965,7 @@ utils-merge@1.0.1:
version "1.0.1" version "1.0.1"
resolved "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" resolved "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
uuid@3.4.0, uuid@^3.0.1, uuid@^3.3.2: uuid@^3.0.1, uuid@^3.3.2:
version "3.4.0" version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册