index.uts 1.6 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 19 20 21 22 23
  eventCallbackNum: number
  // 是否匹配左侧窗口
  noMatchLeftWindow:boolean
  // 当前激活的tab页
  active: string
  leftWinActive:string
DCloud-WZF's avatar
DCloud-WZF 已提交
24 25
}

26 27 28
export const state = reactive({
  lifeCycleNum: 0,
  statusBarHeight: 0,
辛宝Otto's avatar
辛宝Otto 已提交
29
  devicePixelRatio: 1,
30 31 32 33
  eventCallbackNum: 0,
  noMatchLeftWindow: true,
  active: 'componentPage',
  leftWinActive: '/pages/component/public-properties/public-properties',
34 35 36 37 38 39 40 41 42
  safeArea: {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    width: 0,
    height: 0,
  }
} as State)
DCloud-WZF's avatar
DCloud-WZF 已提交
43 44 45

export const setLifeCycleNum = (num : number) => {
  state.lifeCycleNum = num
辛宝Otto's avatar
辛宝Otto 已提交
46 47 48 49
}

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

52 53
export const setStatusBarHeight = (height : number) => {
  state.statusBarHeight = height
54 55 56 57
}

export const setSafeArea = (value : SafeArea) => {
  state.safeArea = value
DCloud-WZF's avatar
DCloud-WZF 已提交
58 59 60 61
}

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

64 65 66 67 68 69 70 71 72 73 74 75
export const setMatchLeftWindow = (matchLeftWindow:boolean) => {
  state.noMatchLeftWindow = !matchLeftWindow
}

export const setActive = (tabPage:string) => {
  state.active = tabPage
}

export const setLeftWinActive = (leftWinActive:string) => {
  state.leftWinActive = leftWinActive
}