App.uvue 2.2 KB
Newer Older
DCloud-WZF's avatar
DCloud-WZF 已提交
1 2 3
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'

4
let firstBackTime = 0
5 6
export default {
  onLaunch: function () {
7
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
8
    setLifeCycleNum(state.lifeCycleNum + 1000)
9
    console.log('App Launch')
10

H
hdx 已提交
11
    const performance = uni.getPerformance()
12 13
    const observer1: PerformanceObserver = performance.createObserver(
      (entryList: PerformanceObserverEntryList) => {
14
        console.log('observer1:entryList.getEntries()' +JSON.stringify(entryList.getEntries()))
15 16 17 18 19
      }
    )
    observer1.observe({
      entryTypes: ['render', 'navigation'],
    } as PerformanceObserverOptions)
20 21
  },
  onShow: function () {
22
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
23
    setLifeCycleNum(state.lifeCycleNum + 100)
24
    console.log('App Show')
25 26
  },
  onHide: function () {
27
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
28
    setLifeCycleNum(state.lifeCycleNum - 100)
29
    console.log('App Hide')
30
  },
M
mehaotian 已提交
31
  onLastPageBackPress: function () {
32
    // 自动化测试
DCloud-WZF's avatar
DCloud-WZF 已提交
33
    setLifeCycleNum(state.lifeCycleNum - 1000)
DCloud-WZF's avatar
DCloud-WZF 已提交
34
    console.log('App LastPageBackPress')
35 36 37 38 39 40 41 42 43 44 45
    if (firstBackTime == 0) {
      uni.showToast({
        title: '再按一次退出应用',
        position: 'bottom',
      })
      firstBackTime = Date.now()
      setTimeout(() => {
        firstBackTime = 0
      }, 2000)
    } else if (Date.now() - firstBackTime < 2000) {
      firstBackTime = Date.now()
46
      uni.exit()
47
    }
48
  },
DCloud-WZF's avatar
DCloud-WZF 已提交
49 50 51
  onExit(){
		console.log('App Exit')
	},
DCloud-WZF's avatar
DCloud-WZF 已提交
52 53 54 55 56 57
  methods: {
    increasetLifeCycleNum() {
      setLifeCycleNum(state.lifeCycleNum + 100)
      console.log('App increasetLifeCycleNum')
    }
  }
58
}
Y
init  
yurj26 已提交
59 60 61
</script>

<style>
62
/*每个页面公共css */
DCloud-WZF's avatar
DCloud-WZF 已提交
63
@import "./common/uni.css";
64 65 66 67 68 69 70 71 72 73

/* #ifdef H5 */
@media screen and (min-width: 768px) {
  body {
    overflow-y: scroll;
  }
}

/* 顶栏通栏样式 */
/* .uni-top-window {
Y
yurj26 已提交
74 75 76 77
  	    left: 0;
  	    right: 0;
  	} */

78 79 80 81 82
uni-page-body {
  background-color: #f5f5f5 !important;
  min-height: 100% !important;
  height: auto !important;
}
Y
yurj26 已提交
83

84 85 86
.uni-top-window uni-tabbar .uni-tabbar {
  background-color: #fff !important;
}
Y
yurj26 已提交
87

88 89 90
.uni-app--showleftwindow .hideOnPc {
  display: none !important;
}
Y
yurj26 已提交
91

92 93
.uni-row {
  flex-direction: row;
94
}
95 96
.uni-column {
  flex-direction: column;
97 98
}

99 100
/* #endif */
</style>