mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-05-18 19:47:29 +08:00
🐞 fix: 修复登录状态问题
This commit is contained in:
@@ -61,22 +61,6 @@ const loadHotSearchKeyword = async () => {
|
|||||||
hotSearchValue.value = data.data.realkeyword
|
hotSearchValue.value = data.data.realkeyword
|
||||||
}
|
}
|
||||||
|
|
||||||
watchEffect(() => {
|
|
||||||
const user = localStorage.getItem('user')
|
|
||||||
store.state.user = user ? JSON.parse(user) : null
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => store.state.user,
|
|
||||||
(newVal) => {
|
|
||||||
if (newVal) {
|
|
||||||
userSetOptions.value = USER_SET_OPTIONS
|
|
||||||
}else{
|
|
||||||
userSetOptions.value = USER_SET_OPTIONS.filter(item => item.key !== 'logout')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const loadPage = async () => {
|
const loadPage = async () => {
|
||||||
const token = localStorage.getItem("token")
|
const token = localStorage.getItem("token")
|
||||||
if (!token) return
|
if (!token) return
|
||||||
@@ -85,6 +69,17 @@ const loadPage = async () => {
|
|||||||
localStorage.setItem('user', JSON.stringify(data.profile))
|
localStorage.setItem('user', JSON.stringify(data.profile))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
loadPage()
|
||||||
|
if (store.state.user) {
|
||||||
|
userSetOptions.value = USER_SET_OPTIONS
|
||||||
|
} else {
|
||||||
|
userSetOptions.value = USER_SET_OPTIONS.filter(item => item.key !== 'logout')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const toLogin = () => {
|
const toLogin = () => {
|
||||||
router.push('/login')
|
router.push('/login')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user