<script>
	export default {
		onLaunch: function() {
			console.log('App Launch');
			interceptorInit();
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		onMounted: function() {
			console.log('App mounted')
		},
		onUnmounted: function() {
			console.log('App unmounted')
		}
	}
	
	/**
	 * 拦截器初始化
	 */
	const interceptorInit = () => {
		uni.addInterceptor('navigateTo', {
		    invoke(data) {
		        const token = uni.getStorageSync('token');
		        if (!token) {
		            uni.reLaunch({
		                url: "/pages/login/login"
		            });
		            return false; // 阻止跳转
		        }
		    }
		});
	}
	
</script>

<style>
	/*每个页面公共css */
</style>
