提交 556c5094 编写于 作者: Q qiang

Merge branch 'dev' into alpha

......@@ -224,7 +224,7 @@ uni-app的Storage在不同端的实现不同:
- 微信小程序单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。
- 支付宝小程序单条数据转换成字符串后,字符串长度最大200*1024。同一个支付宝用户,同一个小程序缓存总上限为10MB。
- 百度、字节跳动小程序文档未说明大小限制
- 非App平台清空Storage会导致uni.getSystemInfo获取到的uuid改变
- 非App平台清空Storage会导致uni.getSystemInfo获取到的deviceId改变
除此之外,其他数据存储方案:
- H5端还支持websql、indexedDB、sessionStorage
......
......@@ -52,7 +52,7 @@
|wifiEnabled | Wi-Fi 的系统开关 |微信小程序|
|safeArea|在竖屏正方向下的安全区域|App、H5、微信小程序|
|safeAreaInsets|在竖屏正方向下的安全区域插入位置(2.5.3+)|App、H5、微信小程序|
|uuid|通用唯一识别码|非 App 端清空 Storage 会导致改变|
|deviceId|设备 id|非 App 端由 uni-app 框架生成并存储,清空 Storage 会导致改变|
**Tips**
- 屏幕高度 = 原生NavigationBar高度(含状态栏高度)+ 可使用窗口高度 + 原生TabBar高度
......@@ -144,7 +144,7 @@ uni.getSystemInfo({
|wifiEnabled | Wi-Fi 的系统开关 |微信小程序|
|safeArea|在竖屏正方向下的安全区域|App、H5、微信小程序|
|safeAreaInsets|在竖屏正方向下的安全区域插入位置(2.5.3+)|App、H5、微信小程序|
|uuid|通用唯一识别码|非 App 端清空 Storage 会导致改变|
|deviceId|设备 id|非 App 端由 uni-app 框架生成并存储,清空 Storage 会导致改变|
**Tips**
- 使用注意同上getSystemInfo
......
......@@ -37,8 +37,7 @@
"base64-arraybuffer": "^0.2.0",
"intersection-observer": "^0.7.0",
"pako": "^1.0.11",
"safe-area-insets": "^1.4.1",
"uuid": "3.4.0"
"safe-area-insets": "^1.4.1"
},
"private": true,
"devDependencies": {
......
let uuid
let deviceId
export default function () {
uuid = uuid || plus.runtime.getDCloudId()
return uuid
deviceId = deviceId || plus.runtime.getDCloudId()
return deviceId
}
......@@ -11,7 +11,7 @@ import tabBar from '../../framework/tab-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 () {
return callApiSync(getSystemInfo, Object.create(null), 'getSystemInfo', 'getSystemInfoSync')
......@@ -100,6 +100,6 @@ export function getSystemInfo () {
bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left
},
uuid: uuid()
deviceId: deviceId()
}
}
import { v4 as uuidv4 } from 'uuid'
const UUID_KEY = '__DC_UUID'
const UUID_KEY = '__DC_STAT_UUID'
const storage = window.localStorage || window.sessionStorage || {}
let uuid
let deviceId
export default function () {
uuid = uuid || storage[UUID_KEY]
if (!uuid) {
uuid = uuidv4()
deviceId = deviceId || storage[UUID_KEY]
if (!deviceId) {
deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
try {
storage[UUID_KEY] = uuid
storage[UUID_KEY] = deviceId
} catch (error) {
}
}
return uuid
return deviceId
}
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'
const ua = navigator.userAgent
......@@ -113,7 +113,7 @@ export function getSystemInfoSync () {
bottom: safeAreaInsets.bottom,
left: safeAreaInsets.left
},
uuid: uuid()
deviceId: deviceId()
}
}
/**
......
import { v4 as uuidv4 } from 'uuid'
import { getStorageSync } from './storage'
const UUID_KEY = '__DC_UUID'
let uuid
const UUID_KEY = '__DC_STAT_UUID'
let deviceId
function addUuid (result) {
uuid = uuid || getStorageSync(UUID_KEY)
if (!uuid) {
uuid = uuidv4()
deviceId = deviceId || getStorageSync(UUID_KEY)
if (!deviceId) {
deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
__GLOBAL__.setStorage({
key: UUID_KEY,
data: uuid
data: deviceId
})
}
result.uuid = uuid
result.deviceId = deviceId
}
function addSafeAreaInsets (result) {
......
import { v4 as uuidv4 } from 'uuid'
const UUID_KEY = '__DC_UUID'
let uuid
const UUID_KEY = '__DC_STAT_UUID'
let deviceId
function addUuid (result) {
uuid = uuid || __GLOBAL__.getStorageSync(UUID_KEY)
if (!uuid) {
uuid = uuidv4()
deviceId = deviceId || __GLOBAL__.getStorageSync(UUID_KEY)
if (!deviceId) {
deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
__GLOBAL__.setStorage({
key: UUID_KEY,
data: uuid
data: deviceId
})
}
result.uuid = uuid
result.deviceId = deviceId
}
function addSafeAreaInsets (result) {
......
......@@ -8965,7 +8965,7 @@ utils-merge@1.0.1:
version "1.0.1"
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"
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.
先完成此消息的编辑!
想要评论请 注册