<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
			this.checkLogin()
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			// 检查登录状态，未登录跳转登录页
			checkLogin() {
				const token = uni.getStorageSync('token')
				if (token) return
				// 已在登录页则跳过
				const pages = getCurrentPages()
				const currentRoute = pages.length > 0 ? pages[pages.length - 1].route : ''
				if (currentRoute === 'pages/login/login') return
				uni.reLaunch({
					url: '/pages/login/login'
				})
			}
		}
	}
</script>

<style>
	@import '@/uni_modules/tuniaoui-vue3/index.css';
	@import '@tuniao/tn-icon/dist/index.css'
</style>
