Skip to content

Commit

Permalink
feat: 优化已登录自动跳转仪表盘
Browse files Browse the repository at this point in the history
  • Loading branch information
devhaozi committed Feb 9, 2025
1 parent 2293646 commit c527af9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion web/src/utils/http/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const http = createAlova({
console.log(json)
const message = resolveResError(
code,
json?.message && json.message.trim() !== '' ? json.message : statusText
(typeof json?.message === 'string' && json.message.trim()) || statusText
)
const noAlert = meta?.noAlert
if (!noAlert) {
Expand Down
32 changes: 14 additions & 18 deletions web/src/views/login/IndexView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async function handleLogin() {
await addDynamicRoutes()
useRequest(user.info()).onSuccess(({ data }) => {
userStore.set(data)
userStore.set(data as any)
})
if (query.redirect) {
const path = query.redirect as string
Expand All @@ -78,25 +78,21 @@ async function handleLogin() {
loging.value = false
}
watch(
() => isLogin,
async () => {
if (isLogin) {
console.log(isLogin)
await addDynamicRoutes()
useRequest(user.info()).onSuccess(({ data }) => {
userStore.set(data)
})
if (query.redirect) {
const path = query.redirect as string
Reflect.deleteProperty(query, 'redirect')
await router.push({ path, query })
} else {
await router.push('/')
}
watch(isLogin, async () => {
if (isLogin) {
await addDynamicRoutes()
useRequest(user.info()).onSuccess(({ data }) => {
userStore.set(data as any)
})
if (query.redirect) {
const path = query.redirect as string
Reflect.deleteProperty(query, 'redirect')
await router.push({ path, query })
} else {
await router.push('/')
}
}
)
})
</script>

<template>
Expand Down

0 comments on commit c527af9

Please sign in to comment.