mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-23 15:47:23 +08:00
🐞 fix: 修复登录状态问题
This commit is contained in:
@@ -61,22 +61,6 @@ const loadHotSearchKeyword = async () => {
|
||||
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 token = localStorage.getItem("token")
|
||||
if (!token) return
|
||||
@@ -85,6 +69,17 @@ const loadPage = async () => {
|
||||
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 = () => {
|
||||
router.push('/login')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user