提交 0b92bef6 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

fix(App lifecycle): onLastPageBackPress

上级 7ddb94bb
<script lang="uts"> <script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts' import { state, setLifeCycleNum } from '@/store/index.uts'
let firstBackTime = 0
export default { export default {
onLaunch: function () { onLaunch: function () {
// 自动化测试 // 自动化测试
...@@ -34,6 +35,19 @@ export default { ...@@ -34,6 +35,19 @@ export default {
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum - 1000) setLifeCycleNum(state.lifeCycleNum - 1000)
console.log('App LastPageBackPress') console.log('App LastPageBackPress')
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)
}
}, },
methods: { methods: {
increasetLifeCycleNum() { increasetLifeCycleNum() {
...@@ -75,10 +89,10 @@ uni-page-body { ...@@ -75,10 +89,10 @@ uni-page-body {
display: none !important; display: none !important;
} }
.uni-row{ .uni-row {
flex-direction: row; flex-direction: row;
} }
.uni-column{ .uni-column {
flex-direction: column; flex-direction: column;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册