let firstBackTime = 0; const __sfc__ = defineApp({ onLaunch() { console.log('App Launch', " at App.uvue:7"); // 1. 从本地缓存读取 token(或用户信息) const token = uni.getStorageSync('token'); console.log(token, 'token', " at App.uvue:10"); // 2. 判断登录态 if (token === '' || token == null || token === 'undefined') { // 未登录:跳转到默认登录页 uni.reLaunch({ url: '/pages/login/login' }); } else { // 已登录:正常进入首页 uni.switchTab({ url: '/pages/homepage/console' }); } }, onShow() { console.log('App Show', " at App.uvue:22"); }, onHide() { console.log('App Hide', " at App.uvue:25"); }, onLastPageBackPress() { console.log('App LastPageBackPress', " at App.uvue:29"); 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(); } }, onExit() { console.log('App Exit', " at App.uvue:46"); }, }); export default __sfc__; const GenAppStyles = [_uM([["uni-row", _pS(_uM([["flexDirection", "row"]]))], ["uni-column", _pS(_uM([["flexDirection", "column"]]))]])]; //# sourceMappingURL=App.uvue.map