fix: avatar 以及 auth 重构

This commit is contained in:
Tim
2025-10-17 15:10:43 +08:00
parent 61f8fa4bb7
commit f17b644a9b
14 changed files with 67 additions and 114 deletions

View File

@@ -40,7 +40,7 @@
<script setup>
import { toast } from '~/main'
import { setToken, loadCurrentUser } from '~/utils/auth'
import { setToken } from '~/utils/auth'
import BaseInput from '~/components/BaseInput.vue'
import ThirdPartyAuth from '~/components/ThirdPartyAuth.vue'
import { registerPush } from '~/utils/push'
@@ -61,7 +61,6 @@ const submitLogin = async () => {
const data = await res.json()
if (res.ok && data.token) {
setToken(data.token)
await loadCurrentUser()
toast.success('登录成功')
registerPush()
await navigateTo('/', { replace: true })

View File

@@ -84,7 +84,7 @@
>
<div class="conversation-avatar">
<BaseImage
:src="ch.avatar || '/default-avatar.jpg'"
:src="ch.avatar"
:alt="ch.name"
class="avatar-img"
@error="handleAvatarError"
@@ -194,7 +194,7 @@ function formatTime(timeString) {
// 头像加载失败处理
function handleAvatarError(event) {
event.target.src = '/default-avatar.jpg'
event.target.src = null
}
async function fetchChannels() {

View File

@@ -70,7 +70,7 @@
<script setup>
import BaseInput from '~/components/BaseInput.vue'
import { toast } from '~/main'
import { loadCurrentUser, setToken } from '~/utils/auth'
import { setToken } from '~/utils/auth'
import ThirdPartyAuth from '~/components/ThirdPartyAuth.vue'
const route = useRoute()
@@ -172,7 +172,6 @@ const verifyCode = async () => {
if (data.reason_code === 'VERIFIED_AND_APPROVED') {
toast.success('注册成功')
setToken(data.token)
loadCurrentUser()
navigateTo('/', { replace: true })
} else if (data.reason_code === 'VERIFIED') {
if (registerMode.value === 'WHITELIST') {