Skip to content

Commit

Permalink
Bug fix for navbar (#787)
Browse files Browse the repository at this point in the history
* Update the component name to be consistent

* Bug fix on using useFetchApi

* Set default value when initialize the user store
  • Loading branch information
hiveer authored Nov 15, 2024
1 parent 6d836d9 commit aa60945
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
location.href = `/${locale}/settings/locale`
},
async fetchUser() {
const {data, _} = await useFetchApi(`${this.csghubServer}/api/v1/user/${this.uuid}?type=uuid`).json()
const {data, _} = await useFetchApi(`/user/${this.uuid}?type=uuid`).json()
if (data.value) {
this.userAvatar = data.value.data.avatar
this.userStore.initialize(data.value.data)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from './locales/en.js'
import zh from './locales/zh.js'

import Navbar from "./components/navbar/TheNavbar.vue"
import Navbar from "./components/navbar/Navbar.vue"
import CommentList from "./components/comment/CommentList.vue"
import EndpointDetail from "./components/endpoints/EndpointDetail.vue"
import RepoDetail from "./components/shared/RepoDetail.vue"
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/stores/UserStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ const useUserStore = defineStore('User', () => {
const isLoggedIn = computed(() => username.value !== '')

async function initialize(initialData) {
username.value = initialData.username
nickname.value = initialData.nickname
email.value = initialData.email
phone.value = initialData.phone
avatar.value = initialData.avatar
uuid.value = initialData.uuid
homepage.value = initialData.homepage
bio.value = initialData.bio
roles.value = initialData.roles
username.value = initialData.username || ''
nickname.value = initialData.nickname || ''
email.value = initialData.email || ''
phone.value = initialData.phone || ''
avatar.value = initialData.avatar || ''
uuid.value = initialData.uuid || ''
homepage.value = initialData.homepage || ''
bio.value = initialData.bio || ''
roles.value = initialData.roles || []
if (initialData.orgs) {
orgs.value = initialData.orgs
}
lastLoginTime.value = initialData.lastLoginTime
lastLoginTime.value = initialData.lastLoginTime || ''
}

return {
Expand Down

0 comments on commit aa60945

Please sign in to comment.