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

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

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

<style>
DCloud-WZF's avatar
DCloud-WZF 已提交
55
/* @font-face {
H
init.  
hdx 已提交
56 57 58 59 60 61
    font-family: uniicons;
    font-weight: normal;
    font-style: normal;
    src: url('./static/fonts/uni.ttf') format('truetype');
  } */

DCloud-WZF's avatar
DCloud-WZF 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
.page {
  padding: 15px;
}

.uni-panel {
  margin-bottom: 12px;
}

.uni-panel-h {
  background-color: #ffffff;
  flex-direction: row;
  align-items: center;
  padding: 12px;
}

.uni-panel-h-on {
  background-color: #f0f0f0;
}

.uni-panel-text {
  color: #000000;
  font-size: 14px;
  font-weight: normal;
}

.uni-panel-icon-on {
  transform: rotate(180deg);
}

.uni-navigate-item {
  flex-direction: row;
  align-items: center;
  background-color: #ffffff;
  border-top-style: solid;
  border-top-color: #f0f0f0;
  border-top-width: 1px;
  padding: 12px;
  justify-content: space-between;
}

.uni-navigate-item:active {
  background-color: #f8f8f8;
}

.uni-navigate-text {
  color: #000000;
  font-size: 12px;
  opacity: 0.8;
}

.uni-navigate-icon {
  margin-left: 15px;
  color: #999999;
  font-size: 14px;
  font-weight: normal;
}

.text-disabled {
  color: #a0a0a0;
}

.list-item-text {
  line-height: 36px;
}

.split-title {
  margin: 20px 0 5px;
  padding: 5px 0;
  border-bottom: 1px solid #dfdfdf;
}

.btn-view {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #dfdfdf;
  border-radius: 3px;
}
</style>