feat: add username to navbar, pass title by props

This commit is contained in:
Lin, Hung-Shin committed 2023-11-22 14:46:41 +08:00
1 parent d15a197db9
commit 89f86fad30
4 files changed
+62 -8

No files matched your search

+30
View File
@@ -0,0 +1,30 @@
import { reactive } from 'vue'
import api from '../utils/api'
const store = reactive({
username: '',
email: '',
progress: {},
})
export async function loadUserProfile() {
try {
const res = await api.get('/users/me')
const { username, email, progress } = res.data
store.username = username
store.email = email
store.progress = progress
return store
} catch (err) {
console.error(err)
throw new Error('Failed to load user profile', err)
}
}
export function resetUserProfile() {
store.username = ''
store.email = ''
store.progress = {}
}
export default store