🐞 fix: 修复登录状态问题 修复播放退出登录的问题

This commit is contained in:
alger
2025-01-25 21:49:22 +08:00
parent 599b0251af
commit 4fa1295b84
6 changed files with 23 additions and 27 deletions
+7 -2
View File
@@ -132,6 +132,7 @@ onBeforeUnmount(() => {
const checkLoginStatus = () => {
const token = localStorage.getItem('token');
const userData = localStorage.getItem('user');
console.log('触发了', token, userData);
if (!token || !userData) {
router.push('/login');
@@ -152,6 +153,10 @@ const loadPage = async () => {
// 检查登录状态
if (!checkLoginStatus()) return;
await loadData();
};
const loadData = async () => {
try {
infoLoading.value = true;
@@ -188,10 +193,10 @@ const loadPage = async () => {
watch(
() => router.currentRoute.value.path,
(newPath) => {
console.log('newPath', newPath);
if (newPath === '/user') {
checkLoginStatus();
} else {
loadPage();
loadData();
}
}
);