index.uts 1.1 KB
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
  // 设备像素比
  devicePixelRatio : number
辛宝Otto's avatar
辛宝Otto 已提交
17 18
  // 事件判断回调
  eventCallbackNum: number
DCloud-WZF's avatar
DCloud-WZF 已提交
19 20
}

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

export const setLifeCycleNum = (num : number) => {
  state.lifeCycleNum = num
辛宝Otto's avatar
辛宝Otto 已提交
38 39 40 41
}

export const setEventCallbackNum = (num : number) => {
  state.eventCallbackNum = num
DCloud-WZF's avatar
DCloud-WZF 已提交
42 43
}

44 45
export const setStatusBarHeight = (height : number) => {
  state.statusBarHeight = height
46 47 48 49
}

export const setSafeArea = (value : SafeArea) => {
  state.safeArea = value
DCloud-WZF's avatar
DCloud-WZF 已提交
50 51 52 53
}

export const setDevicePixelRatio = (devicePixelRatio : number) => {
  state.devicePixelRatio = devicePixelRatio
DCloud-WZF's avatar
DCloud-WZF 已提交
54
}
辛宝Otto's avatar
辛宝Otto 已提交
55