system-info.js 748 字节
Newer Older
Q
qiang 已提交
1 2
const UUID_KEY = '__DC_STAT_UUID'
let deviceId
3
function addUuid (result) {
Q
qiang 已提交
4 5 6
  deviceId = deviceId || __GLOBAL__.getStorageSync(UUID_KEY)
  if (!deviceId) {
    deviceId = Date.now() + '' + Math.floor(Math.random() * 1e7)
7 8
    __GLOBAL__.setStorage({
      key: UUID_KEY,
Q
qiang 已提交
9
      data: deviceId
10 11
    })
  }
Q
qiang 已提交
12
  result.deviceId = deviceId
13 14 15 16 17 18 19 20 21
}

function addSafeAreaInsets (result) {
  if (result.safeArea) {
    const safeArea = result.safeArea
    result.safeAreaInsets = {
      top: safeArea.top,
      left: safeArea.left,
      right: result.windowWidth - safeArea.right,
22
      bottom: Math.abs(result.screenHeight - safeArea.bottom)
23 24 25 26 27 28 29 30 31 32
    }
  }
}

export default {
  returnValue: function (result) {
    addUuid(result)
    addSafeAreaInsets(result)
  }
}