index.uts 910 字节
Newer Older
1 2 3 4 5 6 7 8 9
export type SafeArea = {
  top : number,
  right : number,
  bottom : number,
  left : number,
  width : number,
  height : number,
}

DCloud-WZF's avatar
DCloud-WZF 已提交
10 11
type State = {
  lifeCycleNum : number,
12 13
  // 状态栏高度
  statusBarHeight : number,
14
  safeArea : SafeArea
DCloud-WZF's avatar
DCloud-WZF 已提交
15 16 17 18
  // 设备像素比
  devicePixelRatio : number
}

19 20 21 22 23 24 25 26 27 28 29 30 31
export const state = reactive({
  lifeCycleNum: 0,
  statusBarHeight: 0,
  devicePixelRatio: 1,
  safeArea: {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    width: 0,
    height: 0,
  }
} as State)
DCloud-WZF's avatar
DCloud-WZF 已提交
32 33 34 35 36

export const setLifeCycleNum = (num : number) => {
  state.lifeCycleNum = num
}

37 38
export const setStatusBarHeight = (height : number) => {
  state.statusBarHeight = height
39 40 41 42
}

export const setSafeArea = (value : SafeArea) => {
  state.safeArea = value
DCloud-WZF's avatar
DCloud-WZF 已提交
43 44 45 46
}

export const setDevicePixelRatio = (devicePixelRatio : number) => {
  state.devicePixelRatio = devicePixelRatio
DCloud-WZF's avatar
DCloud-WZF 已提交
47
}