2026-04-17 15:45:54 +08:00
|
|
|
<!-- src/views/Profile.vue -->
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { useUserStore } from '@/stores/user'
|
|
|
|
|
import { ElCard, ElInput, ElButton, ElMessage } from 'element-plus'
|
|
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
|
|
|
|
const username = ref(userStore.user?.username || '')
|
|
|
|
|
const email = ref(userStore.user?.email || '')
|
|
|
|
|
const avatar = ref(userStore.user?.avatar || '')
|
|
|
|
|
const loading = ref(false)
|
|
|
|
|
|
|
|
|
|
async function saveProfile() {
|
|
|
|
|
try {
|
|
|
|
|
loading.value = true
|
|
|
|
|
// await updateProfile({ username: username.value, avatar: avatar.value })
|
|
|
|
|
ElMessage.success('保存成功')
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
ElMessage.error(error.message || '保存失败')
|
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleAvatarUpload() {
|
|
|
|
|
// TODO: 实现头像上传
|
|
|
|
|
ElMessage.info('头像上传功能待实现')
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="profile-page">
|
|
|
|
|
<h1>个人中心</h1>
|
|
|
|
|
|
|
|
|
|
<el-card class="profile-card">
|
|
|
|
|
<div class="profile-form">
|
|
|
|
|
<div class="avatar-section">
|
|
|
|
|
<img :src="avatar || '/default-avatar.png'" class="avatar" />
|
|
|
|
|
<el-button @click="handleAvatarUpload">更换头像</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>用户名</label>
|
|
|
|
|
<el-input v-model="username" placeholder="请输入用户名" />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>邮箱</label>
|
|
|
|
|
<el-input v-model="email" disabled />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label>状态</label>
|
|
|
|
|
<div class="status-display">
|
|
|
|
|
<span>{{ userStore.userStatus }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="form-actions">
|
|
|
|
|
<el-button type="primary" :loading="loading" @click="saveProfile">
|
|
|
|
|
保存
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-card>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.profile-page {
|
|
|
|
|
max-width: 600px;
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.profile-page h1 {
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
margin: 0 0 24px;
|
2026-04-17 17:38:27 +08:00
|
|
|
background: var(--gg-gradient);
|
|
|
|
|
-webkit-background-clip: text;
|
|
|
|
|
-webkit-text-fill-color: transparent;
|
|
|
|
|
background-clip: text;
|
2026-04-17 15:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.profile-card {
|
2026-04-17 17:38:27 +08:00
|
|
|
border-radius: var(--gg-radius-md);
|
2026-04-17 15:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.profile-form {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatar-section {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.avatar {
|
|
|
|
|
width: 100px;
|
|
|
|
|
height: 100px;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
object-fit: cover;
|
2026-04-17 17:38:27 +08:00
|
|
|
border: 3px solid var(--gg-primary);
|
|
|
|
|
box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
|
2026-04-17 15:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-group {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-group label {
|
|
|
|
|
font-size: 14px;
|
2026-04-17 17:38:27 +08:00
|
|
|
font-weight: 600;
|
|
|
|
|
color: var(--gg-text);
|
2026-04-17 15:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.status-display {
|
|
|
|
|
padding: 8px 16px;
|
2026-04-17 17:38:27 +08:00
|
|
|
background: var(--gg-bg);
|
|
|
|
|
border: 1px solid var(--gg-border);
|
|
|
|
|
border-radius: var(--gg-radius-sm);
|
|
|
|
|
color: var(--gg-text);
|
2026-04-17 15:45:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-actions {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|