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

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

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

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

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

87 88 89
.uni-top-window uni-tabbar .uni-tabbar {
  background-color: #fff !important;
}
Y
yurj26 已提交
90

91 92 93
.uni-app--showleftwindow .hideOnPc {
  display: none !important;
}
Y
yurj26 已提交
94

95 96
.uni-row {
  flex-direction: row;
97
}
98 99
.uni-column {
  flex-direction: column;
100 101
}

102 103
/* #endif */
</style>