mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-17 10:27:30 +08:00
🐞 fix: 修复登录状态问题 修复播放退出登录的问题
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user