|
|
@@ -1,5 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
import { onLaunch, onShow, onHide } from "@dcloudio/uni-app";
|
|
|
+import { isLoggedIn } from "@/utils/auth";
|
|
|
|
|
|
onLaunch((options: any) => {
|
|
|
console.log("App Launch", options);
|
|
|
@@ -9,6 +10,7 @@ onLaunch((options: any) => {
|
|
|
|
|
|
onShow(() => {
|
|
|
console.log("App Show");
|
|
|
+ checkLoginStatus();
|
|
|
});
|
|
|
|
|
|
onHide(() => {
|
|
|
@@ -16,12 +18,11 @@ onHide(() => {
|
|
|
});
|
|
|
|
|
|
const checkLoginStatus = () => {
|
|
|
- const token = uni.getStorageSync('admin_token');
|
|
|
const pages = getCurrentPages();
|
|
|
const currentPage = pages[pages.length - 1];
|
|
|
const currentPath = currentPage ? currentPage.route : '';
|
|
|
|
|
|
- if (!token && currentPath !== 'pages/login/login') {
|
|
|
+ if (!isLoggedIn() && currentPath !== 'pages/login/login') {
|
|
|
console.log('未登录,跳转到登录页');
|
|
|
uni.reLaunch({
|
|
|
url: '/pages/login/login'
|