refactor: ♻️ 个人中心界面重构

This commit is contained in:
Ray.Hao
2025-04-03 13:58:38 +08:00
parent 794df442e2
commit 8dcdecfde4

View File

@@ -1,16 +1,15 @@
<template> <template>
<div class="app-container"> <div class="profile-container">
<el-tabs tab-position="left"> <el-row :gutter="20">
<!-- 基本设置 Tab Pane --> <!-- 左侧个人信息卡片 -->
<el-tab-pane label="账号信息"> <el-col :span="8">
<div class="w-full"> <el-card class="user-card">
<el-card> <div class="user-info">
<!-- 头像和昵称部分 --> <div class="avatar-wrapper">
<div class="relative w-100px h-100px flex-center">
<el-avatar :src="userProfile.avatar" :size="100" /> <el-avatar :src="userProfile.avatar" :size="100" />
<el-button <el-button
type="info" type="info"
class="absolute bottom-0 right-0 cursor-pointer" class="avatar-edit-btn"
circle circle
:icon="Camera" :icon="Camera"
size="small" size="small"
@@ -18,152 +17,115 @@
/> />
<input ref="fileInput" type="file" style="display: none" @change="handleFileChange" /> <input ref="fileInput" type="file" style="display: none" @change="handleFileChange" />
</div> </div>
<div class="mt-5"> <div class="user-name">
{{ userProfile.nickname }} <span class="nickname">{{ userProfile.nickname }}</span>
<el-icon <el-icon class="edit-icon" @click="handleOpenDialog(DialogType.ACCOUNT)">
class="align-middle cursor-pointer"
@click="handleOpenDialog(DialogType.ACCOUNT)"
>
<Edit /> <Edit />
</el-icon> </el-icon>
</div> </div>
<!-- 用户信息描述 --> <div class="user-role">{{ userProfile.roleNames }}</div>
<el-descriptions :column="1" class="mt-10"> </div>
<!-- 用户名 --> <el-divider />
<el-descriptions-item> <div class="user-stats">
<template #label> <div class="stat-item">
<el-icon class="align-middle"><User /></el-icon> <div class="stat-value">0</div>
用户名 <div class="stat-label">待办</div>
</div>
<div class="stat-item">
<div class="stat-value">0</div>
<div class="stat-label">消息</div>
</div>
<div class="stat-item">
<div class="stat-value">0</div>
<div class="stat-label">通知</div>
</div>
</div>
</el-card>
</el-col>
<!-- 右侧信息卡片 -->
<el-col :span="16">
<el-card class="info-card">
<template #header>
<div class="card-header">
<span>账号信息</span>
</div>
</template> </template>
<el-descriptions :column="1" border>
<el-descriptions-item label="用户名">
{{ userProfile.username }} {{ userProfile.username }}
<el-icon v-if="userProfile.gender === 1" class="align-middle color-blue"> <el-icon v-if="userProfile.gender === 1" class="gender-icon male">
<Male /> <Male />
</el-icon> </el-icon>
<el-icon v-else class="align-middle color-pink"> <el-icon v-else class="gender-icon female">
<Female /> <Female />
</el-icon> </el-icon>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item label="手机号码">
<template #label> {{ userProfile.mobile || "未绑定" }}
<el-icon class="align-middle"><Phone /></el-icon> <el-button
手机号码 v-if="userProfile.mobile"
</template> type="primary"
{{ userProfile.mobile }} link
@click="() => handleOpenDialog(DialogType.MOBILE)"
>
更换
</el-button>
<el-button
v-else
type="primary"
link
@click="() => handleOpenDialog(DialogType.MOBILE)"
>
绑定
</el-button>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item label="邮箱">
<template #label> {{ userProfile.email || "未绑定" }}
<el-icon class="align-middle"><Message /></el-icon> <el-button
邮箱 v-if="userProfile.email"
</template> type="primary"
{{ userProfile.email }} link
@click="() => handleOpenDialog(DialogType.EMAIL)"
>
更换
</el-button>
<el-button
v-else
type="primary"
link
@click="() => handleOpenDialog(DialogType.EMAIL)"
>
绑定
</el-button>
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item label="部门">
<template #label>
<div class="i-svg:tree" />
部门
</template>
{{ userProfile.deptName }} {{ userProfile.deptName }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item label="创建时间">
<template #label>
<div class="i-svg:role" />
角色
</template>
{{ userProfile.roleNames }}
</el-descriptions-item>
<el-descriptions-item>
<template #label>
<el-icon class="align-middle"><Timer /></el-icon>
创建日期
</template>
{{ userProfile.createTime }} {{ userProfile.createTime }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
</el-card> </el-card>
</div>
</el-tab-pane>
<!-- 安全设置 --> <el-card class="security-card">
<el-tab-pane label="安全设置"> <template #header>
<el-card> <div class="card-header">
<!-- 账户密码 --> <span>安全设置</span>
<el-row> </div>
<el-col :span="16"> </template>
<div class="font-bold">账户密码</div> <div class="security-item">
<div class="text-14px mt-2"> <div class="security-info">
定期修改密码有助于保护账户安全 <div class="security-title">账户密码</div>
<el-button <div class="security-desc">定期修改密码有助于保护账户安全</div>
type="primary" </div>
plain <el-button type="primary" link @click="() => handleOpenDialog(DialogType.PASSWORD)">
size="small"
class="ml-5"
@click="() => handleOpenDialog(DialogType.PASSWORD)"
>
修改 修改
</el-button> </el-button>
</div> </div>
</el-card>
</el-col> </el-col>
</el-row> </el-row>
<!-- 绑定手机 -->
<div class="mt-5">
<div class="font-bold">绑定手机</div>
<div class="text-14px mt-2">
<span v-if="userProfile.mobile">已绑定手机号{{ userProfile.mobile }}</span>
<span v-else>未绑定手机</span>
<el-button
v-if="userProfile.mobile"
type="primary"
plain
size="small"
class="ml-5"
@click="() => handleOpenDialog(DialogType.MOBILE)"
>
更换
</el-button>
<el-button
v-else
type="primary"
plain
size="small"
class="ml-5"
@click="() => handleOpenDialog(DialogType.MOBILE)"
>
绑定
</el-button>
</div>
</div>
<!-- 绑定邮箱 -->
<div class="mt-5">
<div class="font-bold">绑定邮箱</div>
<div class="text-14px mt-2">
<span v-if="userProfile.email">已绑定邮箱{{ userProfile.email }}</span>
<span v-else>未绑定邮箱</span>
<el-button
v-if="userProfile.email"
type="primary"
plain
size="small"
class="ml-5"
@click="() => handleOpenDialog(DialogType.EMAIL)"
>
更换
</el-button>
<el-button
v-else
type="primary"
plain
size="small"
class="ml-5"
@click="() => handleOpenDialog(DialogType.EMAIL)"
>
绑定
</el-button>
</div>
</div>
</el-card>
</el-tab-pane>
</el-tabs>
<!-- 弹窗 --> <!-- 弹窗 -->
<el-dialog v-model="dialog.visible" :title="dialog.title" :width="500"> <el-dialog v-model="dialog.visible" :title="dialog.title" :width="500">
@@ -200,6 +162,7 @@
<el-input v-model="passwordChangeForm.confirmPassword" type="password" show-password /> <el-input v-model="passwordChangeForm.confirmPassword" type="password" show-password />
</el-form-item> </el-form-item>
</el-form> </el-form>
<!-- 绑定手机 --> <!-- 绑定手机 -->
<el-form <el-form
v-else-if="dialog.type === DialogType.MOBILE" v-else-if="dialog.type === DialogType.MOBILE"
@@ -214,7 +177,7 @@
<el-form-item label="验证码" prop="code"> <el-form-item label="验证码" prop="code">
<el-input v-model="mobileUpdateForm.code" style="width: 250px"> <el-input v-model="mobileUpdateForm.code" style="width: 250px">
<template #append> <template #append>
<el-button class="ml-5" :disabled="mobileCountdown > 0" @click="handleSendMobileCode"> <el-button :disabled="mobileCountdown > 0" @click="handleSendMobileCode">
{{ mobileCountdown > 0 ? `${mobileCountdown}s后重新发送` : "发送验证码" }} {{ mobileCountdown > 0 ? `${mobileCountdown}s后重新发送` : "发送验证码" }}
</el-button> </el-button>
</template> </template>
@@ -236,13 +199,14 @@
<el-form-item label="验证码" prop="code"> <el-form-item label="验证码" prop="code">
<el-input v-model="emailUpdateForm.code" style="width: 250px"> <el-input v-model="emailUpdateForm.code" style="width: 250px">
<template #append> <template #append>
<el-button class="ml-5" :disabled="emailCountdown > 0" @click="handleSendEmailCode"> <el-button :disabled="emailCountdown > 0" @click="handleSendEmailCode">
{{ emailCountdown > 0 ? `${emailCountdown}s后重新发送` : "发送验证码" }} {{ emailCountdown > 0 ? `${emailCountdown}s后重新发送` : "发送验证码" }}
</el-button> </el-button>
</template> </template>
</el-input> </el-input>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> <template #footer>
<span class="dialog-footer"> <span class="dialog-footer">
<el-button @click="dialog.visible = false">取消</el-button> <el-button @click="dialog.visible = false">取消</el-button>
@@ -490,18 +454,167 @@ onMounted(async () => {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
/** 关闭tag标签 */ .profile-container {
.app-container { min-height: calc(100vh - 84px);
/* 50px = navbar = 50px */ padding: 20px;
height: calc(100vh - 50px);
background: var(--el-fill-color-blank); background: var(--el-fill-color-blank);
} }
/** 开启tag标签 */ .user-card {
.hasTagsView { .user-info {
.app-container { padding: 20px 0;
/* 84px = navbar + tags-view = 50px + 34px */ text-align: center;
height: calc(100vh - 84px);
.avatar-wrapper {
position: relative;
display: inline-block;
margin-bottom: 16px;
.avatar-edit-btn {
position: absolute;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
border: none;
transition: all 0.3s ease;
&:hover {
background: rgba(0, 0, 0, 0.7);
}
}
}
.user-name {
margin-bottom: 8px;
.nickname {
font-size: 18px;
font-weight: 600;
color: var(--el-text-color-primary);
}
.edit-icon {
margin-left: 8px;
color: var(--el-text-color-secondary);
cursor: pointer;
transition: all 0.3s ease;
&:hover {
color: var(--el-color-primary);
}
}
}
.user-role {
font-size: 14px;
color: var(--el-text-color-secondary);
}
}
.user-stats {
display: flex;
justify-content: space-around;
padding: 16px 0;
.stat-item {
text-align: center;
.stat-value {
font-size: 20px;
font-weight: 600;
color: var(--el-text-color-primary);
}
.stat-label {
margin-top: 4px;
font-size: 12px;
color: var(--el-text-color-secondary);
}
}
}
}
.info-card,
.security-card {
margin-bottom: 20px;
.card-header {
font-size: 16px;
font-weight: 600;
color: var(--el-text-color-primary);
}
}
.security-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 0;
.security-info {
.security-title {
margin-bottom: 4px;
font-size: 16px;
font-weight: 500;
color: var(--el-text-color-primary);
}
.security-desc {
font-size: 14px;
color: var(--el-text-color-secondary);
}
}
}
.el-descriptions {
.el-descriptions__label {
font-weight: 500;
color: var(--el-text-color-regular);
}
.el-descriptions__content {
color: var(--el-text-color-primary);
}
.gender-icon {
margin-left: 8px;
font-size: 16px;
&.male {
color: #409eff;
}
&.female {
color: #f56c6c;
}
}
}
.el-dialog {
.el-dialog__header {
padding: 20px;
margin: 0;
border-bottom: 1px solid var(--el-border-color-light);
}
.el-dialog__body {
padding: 30px 20px;
}
.el-dialog__footer {
padding: 20px;
border-top: 1px solid var(--el-border-color-light);
}
}
// 响应式适配
@media (max-width: 768px) {
.profile-container {
padding: 10px;
}
.el-col {
width: 100%;
} }
} }
</style> </style>