mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 11:30:13 +08:00
refactor: rewrite user profile store using pinia
This commit is contained in:
1 parent
103ce4774c
commit
8a31a58c56
8 files changed
+68
-178
No files matched your search
@@ -5,11 +5,9 @@ import { useToast } from 'vue-toastification'
|
||||
import { logout } from '../../utils/auth'
|
||||
import { bugReportUrl, surveyUrl } from '../../config'
|
||||
import { reset } from '../../store/session'
|
||||
import userProfileStore, {
|
||||
loadUserProfile,
|
||||
resetUserProfile,
|
||||
} from '../../store/userProfile'
|
||||
import useUserProfile from '../../store/userProfile'
|
||||
|
||||
const store = useUserProfile()
|
||||
const router = useRouter()
|
||||
|
||||
const toast = useToast()
|
||||
@@ -17,7 +15,7 @@ const toast = useToast()
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
await logout()
|
||||
resetUserProfile()
|
||||
store.resetUserProfile()
|
||||
reset()
|
||||
router.push({ name: 'login' })
|
||||
} catch (err) {
|
||||
@@ -28,7 +26,7 @@ const handleLogout = async () => {
|
||||
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await loadUserProfile()
|
||||
await store.loadUserProfile()
|
||||
} catch (err) {
|
||||
toast.error('無法讀取使用者資料')
|
||||
console.error(err)
|
||||
@@ -59,7 +57,7 @@ onMounted(async () => {
|
||||
class="text-text inline-block whitespace-nowrap px-1.5"
|
||||
style="font-size: 2vh"
|
||||
>
|
||||
{{ userProfileStore.username }}
|
||||
{{ store.username }}
|
||||
</p>
|
||||
<a
|
||||
title="Survey"
|
||||
|
||||
Reference in new issue
Block a user