Files
FT541-WMS/RuoYi-App-master/App.vue

67 lines
1.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script>
import config from './config'
import store from '@/store'
import { getToken } from '@/utils/auth'
export default {
onLaunch: function() {
this.initApp()
},
// onShow: function() {
// // 检查应用状态,确保从后台恢复时状态一致
// this.checkAppState()
// },
methods: {
// 初始化应用
initApp() {
// 初始化应用配置
this.initConfig()
// 检查用户登录状态
//#ifdef H5
this.checkLogin()
//#endif
},
initConfig() {
this.globalData.config = config
},
checkLogin() {
if (!getToken()) {
console.log('checkLogin 检查登录状态,token不存在')
this.$tab.reLaunch('/pages/login')
}
}
// checkAppState() {
// // 检查Token状态和页面导航栈状态
// console.log('应用从后台切换到前台,检查应用状态')
// // 检查Token状态
// if (!getToken()) {
// console.log('Token不存在,跳转到登录页')
// this.$tab.reLaunch('/pages/login')
// return
// }
// // 检查页面导航栈状态
// const pages = getCurrentPages()
// if (pages.length === 0) {
// console.log('页面导航栈为空,跳转到首页')
// this.$tab.reLaunch('/pages/index')
// return
// }
// // 检查当前页面是否为登录页
// const currentPage = pages[pages.length - 1].route
// if (currentPage === 'pages/login') {
// // 如果当前页面是登录页,不做任何操作
// console.log('当前页面是登录页,不需要跳转')
// }
// }
}
}
</script>
<style lang="scss">
@import '@/static/scss/index.scss'
</style>