优化更新

This commit is contained in:
2026-01-24 10:12:31 +08:00
parent c0f27fd0ef
commit 177c35cc15
9 changed files with 1842 additions and 1265 deletions

View File

@@ -0,0 +1,570 @@
// 认证页面统一样式文件
// 使用明亮暖色调配色方案
// ===== 颜色变量 =====
$primary-color: #ff6b35; // 橙红色
$primary-light: #ff8a5b; // 浅橙红色
$primary-dark: #e55a2b; // 深橙红色
$secondary-color: #ffd93d; // 金黄色
$accent-color: #ffb84d; // 橙黄色
$bg-dark: #1a1a2e; // 深色背景
$bg-light: #16213e; // 浅色背景
$bg-gradient-start: #0f0f23; // 渐变开始
$bg-gradient-end: #1a1a2e; // 渐变结束
$text-primary: #ffffff;
$text-secondary: rgba(255, 255, 255, 0.7);
$text-muted: rgba(255, 255, 255, 0.5);
$border-color: rgba(255, 255, 255, 0.08);
$border-hover: rgba(255, 107, 53, 0.3);
$border-focus: rgba(255, 107, 53, 0.6);
// ===== 基础容器 =====
.auth-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
position: relative;
background: linear-gradient(135deg, $bg-gradient-start 0%, $bg-gradient-end 100%);
overflow: hidden;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
// ===== 科技感背景 =====
.tech-bg {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 0;
pointer-events: none;
// 网格线
.grid-line {
position: absolute;
width: 100%;
height: 1px;
background: linear-gradient(90deg, transparent, rgba(255, 107, 53, 0.08), transparent);
animation: gridMove 8s linear infinite;
&:nth-child(1) { top: 20%; animation-delay: 0s; }
&:nth-child(2) { top: 40%; animation-delay: 2s; }
&:nth-child(3) { top: 60%; animation-delay: 4s; }
&:nth-child(4) { top: 80%; animation-delay: 6s; }
}
// 光点效果
.light-spot {
position: absolute;
width: 4px;
height: 4px;
background: $primary-color;
border-radius: 50%;
box-shadow: 0 0 10px $primary-color, 0 0 20px $primary-color;
animation: float 6s ease-in-out infinite;
&:nth-child(5) { top: 15%; left: 20%; animation-delay: 0s; }
&:nth-child(6) { top: 25%; left: 70%; animation-delay: 2s; }
&:nth-child(7) { top: 55%; left: 15%; animation-delay: 4s; }
&:nth-child(8) { top: 75%; left: 80%; animation-delay: 1s; }
}
}
@keyframes gridMove {
0% { transform: translateX(-100%); }
100% { transform: translateX(100%); }
}
@keyframes float {
0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
50% { transform: translateY(-20px) scale(1.2); opacity: 1; }
}
// ===== 主卡片 =====
.auth-wrapper {
width: 100%;
max-width: 960px;
padding: 20px;
position: relative;
z-index: 1;
}
.auth-card {
background: rgba(255, 255, 255, 0.02);
backdrop-filter: blur(24px);
-webkit-backdrop-filter: blur(24px);
border-radius: 28px;
padding: 0;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
border: 1px solid $border-color;
overflow: hidden;
display: flex;
min-height: 580px;
animation: cardFadeIn 0.6s ease-out;
}
@keyframes cardFadeIn {
0% { opacity: 0; transform: translateY(20px); }
100% { opacity: 1; transform: translateY(0); }
}
// ===== 左侧装饰区 =====
.decoration-area {
flex: 1;
background: linear-gradient(135deg, rgba(255, 107, 53, 0.08) 0%, rgba(255, 217, 61, 0.03) 100%);
padding: 60px 40px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
position: relative;
border-right: 1px solid $border-color;
}
.tech-circle {
position: relative;
width: 220px;
height: 220px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 48px;
.circle-inner {
width: 110px;
height: 110px;
background: linear-gradient(135deg, $primary-color 0%, $primary-light 100%);
border-radius: 50%;
box-shadow: 0 0 50px rgba(255, 107, 53, 0.4);
animation: pulse 3s ease-in-out infinite;
display: flex;
align-items: center;
justify-content: center;
&::after {
content: '';
width: 60px;
height: 60px;
background: linear-gradient(135deg, $secondary-color 0%, $accent-color 100%);
border-radius: 50%;
box-shadow: 0 0 30px rgba(255, 217, 61, 0.5);
}
}
.circle-ring {
position: absolute;
width: 160px;
height: 160px;
border: 2px solid rgba(255, 107, 53, 0.2);
border-radius: 50%;
animation: rotate 12s linear infinite;
&::before {
content: '';
position: absolute;
top: -2px;
left: 50%;
transform: translateX(-50%);
width: 8px;
height: 8px;
background: $primary-color;
border-radius: 50%;
box-shadow: 0 0 15px $primary-color;
}
}
.circle-ring-2 {
width: 200px;
height: 200px;
border: 1px solid rgba(255, 217, 61, 0.15);
animation: rotate 18s linear infinite reverse;
}
}
@keyframes pulse {
0%, 100% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.08); opacity: 0.85; }
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.decoration-text {
text-align: center;
h2 {
margin: 0 0 16px;
font-size: 32px;
font-weight: 700;
background: linear-gradient(135deg, $primary-color 0%, $secondary-color 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
letter-spacing: 1px;
}
p {
margin: 0;
color: $text-secondary;
font-size: 16px;
font-weight: 400;
letter-spacing: 0.5px;
}
}
// ===== 右侧表单区 =====
.form-area {
flex: 1.3;
padding: 60px 56px;
}
.auth-header {
margin-bottom: 40px;
h1 {
margin: 0 0 12px;
font-size: 36px;
font-weight: 700;
background: linear-gradient(135deg, $primary-color 0%, $accent-color 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
letter-spacing: 1px;
}
.subtitle {
margin: 0;
color: $text-secondary;
font-size: 15px;
font-weight: 400;
}
}
// ===== 表单样式 =====
.auth-form {
margin-top: 0;
:deep(.ant-form-item) {
margin-bottom: 26px;
}
:deep(.ant-form-item-label > label) {
color: $text-secondary;
font-size: 14px;
font-weight: 500;
}
// 输入框样式
:deep(.ant-input-affix-wrapper),
:deep(.ant-input) {
background: rgba(255, 255, 255, 0.03);
border: 1px solid $border-color;
border-radius: 12px;
color: $text-primary;
padding: 12px 16px;
font-size: 15px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
&:hover {
background: rgba(255, 255, 255, 0.06);
border-color: $border-hover;
}
&:focus,
&.ant-input-affix-wrapper-focused {
background: rgba(255, 255, 255, 0.06);
border-color: $primary-color;
box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}
}
:deep(.ant-input::placeholder) {
color: $text-muted;
}
:deep(.ant-input-affix-wrapper > input.ant-input) {
background: transparent;
}
// 图标样式
:deep(.anticon) {
color: $text-secondary;
font-size: 16px;
transition: color 0.3s;
}
:deep(.ant-input-affix-wrapper-focused .anticon) {
color: $primary-color;
}
}
// ===== 按钮样式 =====
.auth-form :deep(.ant-btn-primary) {
background: linear-gradient(135deg, $primary-color 0%, $primary-light 100%);
border: none;
border-radius: 12px;
height: 48px;
font-weight: 600;
font-size: 16px;
letter-spacing: 0.5px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
&:hover:not(:disabled) {
background: linear-gradient(135deg, $primary-light 0%, $accent-color 100%);
box-shadow: 0 6px 25px rgba(255, 107, 53, 0.4);
transform: translateY(-2px);
}
&:active:not(:disabled) {
transform: translateY(0);
box-shadow: 0 2px 10px rgba(255, 107, 53, 0.3);
}
&:disabled {
background: rgba(255, 255, 255, 0.08);
color: $text-muted;
box-shadow: none;
transform: none;
cursor: not-allowed;
}
}
// ===== 表单选项 =====
.form-options {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 26px;
:deep(.ant-checkbox-wrapper) {
color: $text-primary;
font-size: 14px;
.ant-checkbox {
.ant-checkbox-inner {
border-color: $border-color;
background: rgba(255, 255, 255, 0.03);
}
&.ant-checkbox-checked .ant-checkbox-inner {
background: $primary-color;
border-color: $primary-color;
}
}
}
}
.forgot-password {
color: $primary-color;
text-decoration: none;
font-size: 14px;
font-weight: 500;
transition: all 0.3s;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
// ===== 验证码输入框 =====
.code-input-wrapper {
display: flex;
gap: 14px;
.code-input {
flex: 1;
}
.code-btn {
width: 150px;
white-space: nowrap;
background: linear-gradient(135deg, $primary-color 0%, $primary-light 100%);
border: none;
border-radius: 12px;
font-weight: 600;
font-size: 14px;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 4px 15px rgba(255, 107, 53, 0.3);
&:hover:not(:disabled) {
background: linear-gradient(135deg, $primary-light 0%, $accent-color 100%);
box-shadow: 0 6px 25px rgba(255, 107, 53, 0.4);
transform: translateY(-2px);
}
&:active:not(:disabled) {
transform: translateY(0);
}
&:disabled {
background: rgba(255, 255, 255, 0.08);
color: $text-muted;
box-shadow: none;
transform: none;
cursor: not-allowed;
}
}
}
// ===== 协议复选框 =====
.agreement-checkbox {
:deep(.ant-checkbox-wrapper) {
color: $text-secondary;
font-size: 13px;
align-items: flex-start;
line-height: 1.6;
.ant-checkbox {
margin-top: 2px;
.ant-checkbox-inner {
border-color: $border-color;
background: rgba(255, 255, 255, 0.03);
}
&.ant-checkbox-checked .ant-checkbox-inner {
background: $primary-color;
border-color: $primary-color;
}
}
}
}
.agreement-text {
font-size: 13px;
line-height: 1.6;
color: $text-secondary;
}
.link {
color: $primary-color;
text-decoration: none;
font-weight: 500;
transition: all 0.3s;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
// ===== 表单底部 =====
.form-footer {
text-align: center;
margin-top: 28px;
color: $text-secondary;
font-size: 14px;
.auth-link {
color: $primary-color;
text-decoration: none;
font-weight: 600;
margin-left: 6px;
transition: all 0.3s;
&:hover {
color: $primary-light;
text-decoration: underline;
}
}
}
// ===== 响应式设计 =====
@media (max-width: 768px) {
.auth-card {
flex-direction: column;
min-height: auto;
margin: 20px 0;
}
.decoration-area {
padding: 48px 24px;
border-right: none;
border-bottom: 1px solid $border-color;
}
.tech-circle {
width: 160px;
height: 160px;
.circle-inner {
width: 80px;
height: 80px;
&::after {
width: 45px;
height: 45px;
}
}
.circle-ring {
width: 120px;
height: 120px;
}
.circle-ring-2 {
width: 150px;
height: 150px;
}
}
.decoration-text {
h2 {
font-size: 26px;
}
p {
font-size: 14px;
}
}
.form-area {
padding: 48px 32px;
}
.auth-header {
h1 {
font-size: 28px;
}
.subtitle {
font-size: 14px;
}
}
.code-input-wrapper {
flex-direction: column;
gap: 12px;
.code-btn {
width: 100%;
}
}
}
@media (max-width: 480px) {
.auth-wrapper {
padding: 16px;
}
.auth-card {
border-radius: 20px;
}
.form-area {
padding: 36px 24px;
}
.auth-header {
margin-bottom: 32px;
}
}

View File

@@ -11,8 +11,8 @@
<div class="body">
<a-tree v-model:selectedKeys="selectedMenuKeys" v-model:checkedKeys="checkedMenuKeys"
:tree-data="filteredMenuTree" :field-names="{ title: 'title', key: 'id', children: 'children' }"
showLine checkable :check-strictly="true" :expand-on-click-node="false"
@select="onMenuSelect" @check="onMenuCheck">
showLine checkable :check-strictly="true" :expand-on-click-node="false" @select="onMenuSelect"
@check="onMenuCheck">
<template #icon="{ dataRef }">
<folder-outlined v-if="dataRef.children" />
<file-outlined v-else />
@@ -50,7 +50,7 @@
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue'
import { ref, onMounted } from 'vue'
import { message, Modal } from 'ant-design-vue'
import saveForm from './save.vue'
import authApi from '@/api/auth'
@@ -141,7 +141,7 @@ const findParentId = (tree, id) => {
}
// 菜单选择事件
const onMenuSelect = (selectedKeys, { selected, node }) => {
const onMenuSelect = (selectedKeys, { selected }) => {
if (selected) {
const menuId = selectedKeys[0]
const menuNode = findMenuNode(menuTree.value, menuId)
@@ -263,6 +263,7 @@ onMounted(() => {
padding: 12px 16px;
border-bottom: 1px solid #f0f0f0;
background: #fafafa;
height: 56px;
}
.body {
@@ -312,6 +313,7 @@ onMounted(() => {
padding: 16px 24px;
border-bottom: 1px solid #f0f0f0;
background: #fff;
height: 56px;
.title {
font-size: 18px;

View File

@@ -1,20 +1,15 @@
<template>
<div class="save-form">
<a-row :gutter="24">
<a-form :model="form" :rules="rules" ref="dialogForm" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
<!-- 第一行显示名称和类型 -->
<a-row :gutter="16">
<a-col :span="12">
<a-card title="基本信息" :bordered="false" size="small">
<a-form :model="form" :rules="rules" ref="dialogForm" :label-col="{ span: 6 }"
:wrapper-col="{ span: 16 }">
<a-form-item label="显示名称" name="title">
<a-input v-model:value="form.title" placeholder="菜单显示名字" allow-clear />
</a-form-item>
<a-form-item label="上级菜单" name="parent_id">
<a-tree-select v-model:value="form.parent_id" :tree-data="menuOptions"
:field-names="menuFieldNames" :tree-default-expand-all="false" show-icon
placeholder="顶级菜单" allow-clear tree-node-filter-prop="title"
:disabled="!!menuId" />
</a-form-item>
<a-form-item label="类型" name="type">
</a-col>
<a-col :span="12">
<a-form-item label="类型" name="type" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
<a-radio-group v-model:value="form.type" button-style="solid">
<a-radio-button value="menu">菜单</a-radio-button>
<a-radio-button value="iframe">Iframe</a-radio-button>
@@ -22,64 +17,123 @@
<a-radio-button value="button">按钮</a-radio-button>
</a-radio-group>
</a-form-item>
</a-col>
</a-row>
<!-- 第二行上级菜单和别名 -->
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="上级菜单" name="parent_id">
<a-tree-select v-model:value="form.parent_id" :tree-data="menuOptions"
:field-names="menuFieldNames" :tree-default-expand-all="false" show-icon placeholder="顶级菜单"
allow-clear tree-node-filter-prop="title" :disabled="!!menuId" />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="别名" name="name">
<a-input v-model:value="form.name" placeholder="菜单别名" allow-clear />
<div class="form-item-msg">系统唯一且与内置组件名一致否则导致缓存失效如类型为Iframe的菜单别名将代替源地址显示在地址栏</div>
<div class="form-item-msg">系统唯一且与内置组件名一致否则导致缓存失效</div>
</a-form-item>
</a-col>
</a-row>
<!-- 第三行菜单图标和排序 -->
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="菜单图标" name="icon">
<a-input v-model:value="form.icon" placeholder="请输入图标类名" allow-clear />
</a-form-item>
<a-form-item label="路由地址" name="path">
<a-input v-model:value="form.path" placeholder="" allow-clear />
</a-form-item>
<a-form-item label="重定向" name="redirect">
<a-input v-model:value="form.redirect" placeholder="" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="排序" name="sort">
<a-input-number v-model:value="form.sort" :min="0" :max="100" style="width: 100%" />
</a-form-item>
</a-col>
</a-row>
<!-- 第四行路由地址和重定向 -->
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="路由地址" name="path">
<a-input v-model:value="form.path" placeholder="" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="重定向" name="redirect">
<a-input v-model:value="form.redirect" placeholder="" allow-clear />
</a-form-item>
</a-col>
</a-row>
<!-- 第五行菜单高亮和视图 -->
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="菜单高亮" name="active">
<a-input v-model:value="form.active" placeholder="" allow-clear />
<div class="form-item-msg">子节点或详情页需要高亮的上级菜单路由地址</div>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="视图" name="component">
<a-input v-model:value="form.component" placeholder="" allow-clear>
<template #addonBefore>pages/</template>
</a-input>
<div class="form-item-msg">如父节点链接或Iframe等没有视图的菜单不需要填写</div>
</a-form-item>
</a-col>
</a-row>
<!-- 第六行颜色 -->
<a-row :gutter="16">
<a-col :span="12">
<a-form-item label="颜色" name="color">
<a-input v-model:value="form.color" placeholder="请输入颜色值" allow-clear />
</a-form-item>
<a-form-item label="是否隐藏" name="hidden">
</a-col>
</a-row>
<!-- 分隔线 -->
<a-divider />
<!-- 选项设置区域 -->
<div class="options-section">
<h4>选项设置</h4>
<a-row :gutter="16">
<a-col :span="8">
<a-form-item label="是否隐藏" name="hidden" :label-col="{ span: 4 }" :wrapper-col="{ span: 18 }">
<a-checkbox v-model:checked="form.hidden">隐藏菜单</a-checkbox>
<a-checkbox v-model:checked="form.hiddenBreadcrumb">隐藏面包屑</a-checkbox>
<div class="form-item-msg">菜单不显示在导航中但用户依然可以访问例如详情页</div>
</a-form-item>
<a-form-item label="是否固定" name="affix">
<a-switch v-model:checked="form.affix" />
<div class="form-item-msg">是否固定类似首页控制台在标签中是没有关闭按钮的</div>
</a-form-item>
<a-form-item label="是否全屏" name="fullpage">
<a-switch v-model:checked="form.fullpage" />
<div class="form-item-msg">是否全屏</div>
</a-form-item>
<a-form-item :wrapper-col="{ span: 16, offset: 6 }">
<a-button type="primary" @click="handleSave" :loading="loading">保存</a-button>
</a-form-item>
</a-form>
</a-card>
</a-col>
<a-col :span="12">
<a-card title="接口权限" :bordered="false" size="small">
<a-button type="dashed" block @click="addApiRow">
<a-col :span="8">
<a-form-item label="是否固定" name="affix" :label-col="{ span: 8 }" :wrapper-col="{ span: 14 }">
<a-switch v-model:checked="form.affix" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="是否全屏" name="fullpage" :label-col="{ span: 8 }" :wrapper-col="{ span: 14 }">
<a-switch v-model:checked="form.fullpage" />
</a-form-item>
</a-col>
</a-row>
</div>
<!-- 分隔线 -->
<a-divider />
<!-- 接口权限区域 -->
<div class="api-section">
<div class="section-header">
<h4>接口权限</h4>
<a-button type="primary" size="small" @click="addApiRow">
<template #icon><plus-outlined /></template>
添加接口权限
</a-button>
<a-list :data-source="form.apiList" item-layout="horizontal" style="margin-top: 16px">
<template #renderItem="{ item, index }">
<a-list-item>
<a-row :gutter="8" style="width: 100%">
</div>
<div class="api-list">
<div v-for="(item, index) in form.apiList" :key="index" class="api-item">
<a-row :gutter="8">
<a-col :span="8">
<a-input v-model:value="item.code" placeholder="标识" allow-clear />
</a-col>
@@ -92,28 +146,41 @@
</a-button>
</a-col>
</a-row>
</a-list-item>
</template>
</a-list>
<a-empty v-if="form.apiList.length === 0" description="暂无接口权限" style="margin-top: 16px" />
</a-card>
</a-col>
</a-row>
</div>
<a-empty v-if="form.apiList.length === 0" description="暂无接口权限"
:image="Empty.PRESENTED_IMAGE_SIMPLE" />
</div>
</div>
<!-- 操作按钮 -->
<a-form-item :wrapper-col="{ span: 18, offset: 4 }" style="margin-top: 32px">
<a-space>
<a-button type="primary" @click="handleSave" :loading="loading" size="large">保存</a-button>
<a-button @click="$emit('cancel')" size="large">取消</a-button>
</a-space>
</a-form-item>
</a-form>
</div>
</template>
<script setup>
import { ref, reactive, watch, onMounted } from 'vue'
import { message } from 'ant-design-vue'
import { message, Empty } from 'ant-design-vue'
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import authApi from '@/api/auth'
defineOptions({
name: 'PermissionSave'
})
const props = defineProps({
menu: { type: Object, default: () => [] },
menu: { type: [Object, Array], default: () => [] },
menuId: { type: [Number, String], default: null },
parentId: { type: [Number, String], default: null }
})
const emit = defineEmits(['success'])
const emit = defineEmits(['success', 'cancel'])
// 表单数据
const form = reactive({
@@ -170,6 +237,20 @@ const treeToMap = (tree) => {
return map
}
// 查找菜单节点
const findMenuNode = (tree, id) => {
for (const node of tree) {
if (node.id === id) {
return node
}
if (node.children && node.children.length > 0) {
const found = findMenuNode(node.children, id)
if (found) return found
}
}
return null
}
// 监听菜单树变化
watch(
() => props.menu,
@@ -181,6 +262,40 @@ watch(
{ deep: true, immediate: true }
)
// 监听 menuId 变化,从菜单树中查找并赋值
watch(
() => props.menuId,
(newVal) => {
if (newVal && props.menu && props.menu.length > 0) {
const menuNode = findMenuNode(props.menu, newVal)
if (menuNode) {
setData(menuNode, props.parentId)
}
} else if (!newVal) {
// 清空表单
setData({
id: '',
parent_id: 0,
name: '',
path: '',
component: '',
redirect: '',
sort: 0,
title: '',
icon: '',
active: '',
color: '',
type: 'menu',
affix: false,
hidden: false,
hiddenBreadcrumb: false,
fullpage: false,
apiList: []
})
}
}
)
// 添加接口权限行
const addApiRow = () => {
form.apiList.push({
@@ -271,35 +386,77 @@ defineExpose({
<style scoped lang="scss">
.save-form {
padding: 24px;
background: #fff;
.form-item-msg {
font-size: 12px;
color: #999;
color: #8c8c8c;
margin-top: 4px;
line-height: 1.5;
}
:deep(.ant-card) {
.ant-card-head {
background: #fafafa;
border-bottom: 1px solid #f0f0f0;
.options-section {
margin-top: 16px;
.ant-card-head-title {
font-weight: 500;
h4 {
font-size: 16px;
font-weight: 500;
color: #262626;
margin-bottom: 24px;
}
}
.ant-card-body {
padding: 24px;
.api-section {
margin-top: 16px;
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
h4 {
font-size: 16px;
font-weight: 500;
color: #262626;
margin: 0;
}
}
:deep(.ant-list-item) {
padding: 12px 0;
border-bottom: 1px solid #f0f0f0;
.api-list {
background: #fafafa;
border-radius: 4px;
padding: 16px;
.api-item {
margin-bottom: 12px;
padding: 12px;
background: #fff;
border-radius: 4px;
border: 1px solid #f0f0f0;
&:last-child {
border-bottom: none;
margin-bottom: 0;
}
&:hover {
border-color: #d9d9d9;
}
}
}
}
:deep(.ant-divider) {
margin: 32px 0;
}
:deep(.ant-form-item) {
margin-bottom: 24px;
}
:deep(.ant-empty) {
padding: 24px 0;
}
}
</style>

View File

@@ -1,22 +1,48 @@
<template>
<div class="login-container">
<div class="login-wrapper">
<div class="login-card">
<div class="login-header">
<div class="login-logo">
<h1>Vue Admin</h1>
</div>
<p class="login-subtitle">欢迎回来</p>
<div class="login-container auth-container">
<!-- 科技感背景 -->
<div class="tech-bg">
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
</div>
<a-form :model="formState" @finish="handleLogin" layout="vertical" class="login-form">
<!-- 主内容区 -->
<div class="login-wrapper auth-wrapper">
<div class="login-card auth-card">
<!-- 左侧装饰区 -->
<div class="decoration-area">
<div class="tech-circle">
<div class="circle-inner"></div>
<div class="circle-ring"></div>
<div class="circle-ring circle-ring-2"></div>
</div>
<div class="decoration-text">
<h2>欢迎回来</h2>
<p>进入智能管理系统</p>
</div>
</div>
<!-- 右侧表单区 -->
<div class="form-area">
<div class="auth-header">
<h1>Vue Admin</h1>
<p class="subtitle">登录您的账户</p>
</div>
<a-form :model="formState" @finish="handleLogin" layout="vertical" class="auth-form login-form">
<a-form-item name="username" :rules="[{ required: true, message: '请输入用户名' }]">
<a-input v-model:value="formState.username" placeholder="用户名" size="large"
<a-input v-model:value="formState.username" placeholder="请输入用户名" size="large"
:prefix="h(UserOutlined)" />
</a-form-item>
<a-form-item name="password" :rules="[{ required: true, message: '请输入密码' }]">
<a-input-password v-model:value="formState.password" placeholder="密码" size="large"
<a-input-password v-model:value="formState.password" placeholder="请输入密码" size="large"
:prefix="h(LockOutlined)" />
</a-form-item>
@@ -35,7 +61,7 @@
<div class="form-footer">
<span>还没有账号</span>
<router-link to="/register" class="register-link">
<router-link to="/register" class="auth-link">
立即注册
</router-link>
</div>
@@ -43,6 +69,7 @@
</div>
</div>
</div>
</div>
</template>
<script setup>
@@ -52,27 +79,29 @@ import { message } from 'ant-design-vue'
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
import { useUserStore } from '@/stores/modules/user'
import authApi from '@/api/auth'
import '@/assets/style/auth-pages.scss'
// 定义组件名称(多词命名)
defineOptions({
name: 'LoginPage'
});
})
const router = useRouter();
const loading = ref(false);
const router = useRouter()
const loading = ref(false)
const userStore = useUserStore()
const formState = reactive({
username: '',
password: '',
remember: false,
});
})
const handleLogin = async () => {
loading.value = true;
loading.value = true
try {
let res = await authApi.login.post({ username: formState.username, password: formState.password })
let res = await authApi.login.post({
username: formState.username,
password: formState.password,
})
if (res.code == 1) {
userStore.setToken(res.data.access_token)
let userInfo = await authApi.user.get()
@@ -80,112 +109,23 @@ const handleLogin = async () => {
userStore.setUserInfo(userInfo.data)
}
let authData = await authApi.menu.my.get()
if (authData.code == 1){
if (authData.code == 1) {
userStore.setMenu(authData.data.menu)
userStore.setPermissions(authData.data.permissions)
}
message.success('登录成功');
// 跳转到首页或重定向页面
message.success('登录成功')
const redirect = router.currentRoute.value.query.redirect || '/'
router.push(redirect)
}
} catch {
message.error('登录失败,请检查用户名和密码');
message.error('登录失败,请检查用户名和密码')
} finally {
loading.value = false;
loading.value = false
}
};
}
</script>
<style scoped>
.login-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
}
.login-wrapper {
width: 100%;
max-width: 400px;
}
.login-card {
background: white;
border-radius: 16px;
padding: 40px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}
.login-header {
text-align: center;
margin-bottom: 32px;
}
.login-logo h1 {
margin: 0;
font-size: 28px;
font-weight: 700;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.login-subtitle {
margin: 8px 0 0;
color: #666;
font-size: 14px;
}
.login-form {
margin-top: 24px;
}
.login-form :deep(.ant-form-item) {
margin-bottom: 20px;
}
.login-form :deep(.ant-input-affix-wrapper),
.login-form :deep(.ant-input) {
border-radius: 8px;
}
.form-options {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20px;
}
.forgot-password {
color: #667eea;
text-decoration: none;
font-size: 14px;
}
.forgot-password:hover {
text-decoration: underline;
}
.form-footer {
text-align: center;
margin-top: 16px;
color: #666;
font-size: 14px;
}
.register-link {
color: #667eea;
text-decoration: none;
font-weight: 500;
margin-left: 4px;
}
.register-link:hover {
text-decoration: underline;
}
/* 所有样式已移至统一样式文件 src/assets/style/auth-pages.scss */
</style>

View File

@@ -1,39 +1,65 @@
<template>
<div class="login-container">
<div class="login-wrapper">
<div class="login-card">
<div class="login-header">
<div class="login-logo">
<h1>Vue Admin</h1>
</div>
<p class="login-subtitle">重置密码</p>
<div class="reset-container auth-container">
<!-- 科技感背景 -->
<div class="tech-bg">
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
</div>
<a-form :model="formState" @finish="handleReset" layout="vertical" class="login-form">
<!-- 主内容区 -->
<div class="reset-wrapper auth-wrapper">
<div class="reset-card auth-card">
<!-- 左侧装饰区 -->
<div class="decoration-area">
<div class="tech-circle">
<div class="circle-inner"></div>
<div class="circle-ring"></div>
<div class="circle-ring circle-ring-2"></div>
</div>
<div class="decoration-text">
<h2>重置密码</h2>
<p>找回您的账户访问权限</p>
</div>
</div>
<!-- 右侧表单区 -->
<div class="form-area">
<div class="auth-header">
<h1>Vue Admin</h1>
<p class="subtitle">设置新密码</p>
</div>
<a-form :model="formState" @finish="handleReset" layout="vertical" class="auth-form reset-form">
<a-form-item name="email" :rules="[
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '请输入有效的邮箱地址' },
]">
<a-input v-model:value="formState.email" placeholder="邮箱地址" size="large"
<a-input v-model:value="formState.email" placeholder="请输入邮箱地址" size="large"
:prefix="h(MailOutlined)" />
</a-form-item>
<a-form-item name="verificationCode" :rules="[{ required: true, message: '请输入验证码' }]">
<a-input v-model:value="formState.verificationCode" placeholder="验证码" size="large"
:prefix="h(SafetyOutlined)">
<template #suffix>
<a-button type="link" :disabled="countdown > 0" @click="sendCode" class="code-btn">
<div class="code-input-wrapper">
<a-input v-model:value="formState.verificationCode" placeholder="请输入验证码" size="large"
:prefix="h(SafetyOutlined)" class="code-input" />
<a-button type="primary" :disabled="countdown > 0" @click="sendCode" class="code-btn"
size="large">
{{ countdown > 0 ? `${countdown}秒后重试` : '发送验证码' }}
</a-button>
</template>
</a-input>
</div>
</a-form-item>
<a-form-item name="newPassword" :rules="[
{ required: true, message: '请输入新密码' },
{ min: 6, message: '密码至少6个字符' },
]">
<a-input-password v-model:value="formState.newPassword" placeholder="新密码" size="large"
<a-input-password v-model:value="formState.newPassword" placeholder="请输入新密码" size="large"
:prefix="h(LockOutlined)" />
</a-form-item>
@@ -41,8 +67,8 @@
{ required: true, message: '请确认新密码' },
{ validator: validateConfirmPassword },
]">
<a-input-password v-model:value="formState.confirmPassword" placeholder="确认新密码" size="large"
:prefix="h(LockOutlined)" />
<a-input-password v-model:value="formState.confirmPassword" placeholder="请再次输入新密码"
size="large" :prefix="h(LockOutlined)" />
</a-form-item>
<a-form-item>
@@ -53,7 +79,7 @@
<div class="form-footer">
<span>记得密码了</span>
<router-link to="/login" class="register-link">
<router-link to="/login" class="auth-link">
立即登录
</router-link>
</div>
@@ -61,150 +87,70 @@
</div>
</div>
</div>
</div>
</template>
<script setup>
import { reactive, ref, h } from 'vue';
import { useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
import {
MailOutlined,
SafetyOutlined,
LockOutlined,
} from '@ant-design/icons-vue';
import { reactive, ref, h } from 'vue'
import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
import { MailOutlined, SafetyOutlined, LockOutlined } from '@ant-design/icons-vue'
import '@/assets/style/auth-pages.scss'
// 定义组件名称(多词命名)
defineOptions({
name: 'ResetPasswordPage'
});
})
const router = useRouter();
const loading = ref(false);
const countdown = ref(0);
const router = useRouter()
const loading = ref(false)
const countdown = ref(0)
const formState = reactive({
email: '',
verificationCode: '',
newPassword: '',
confirmPassword: '',
});
})
const validateConfirmPassword = async (rule, value) => {
if (value !== formState.newPassword) {
return Promise.reject('两次输入的密码不一致');
return Promise.reject('两次输入的密码不一致')
}
return Promise.resolve();
};
return Promise.resolve()
}
const sendCode = () => {
if (!formState.email) {
message.warning('请先输入邮箱地址');
return;
message.warning('请先输入邮箱地址')
return
}
// TODO: 实现发送验证码逻辑
message.success('验证码已发送');
countdown.value = 60;
message.success('验证码已发送')
countdown.value = 60
const timer = setInterval(() => {
countdown.value--;
countdown.value--
if (countdown.value <= 0) {
clearInterval(timer);
clearInterval(timer)
}
}, 1000);
};
}, 1000)
}
const handleReset = async () => {
loading.value = true;
loading.value = true
try {
// TODO: 实现重置密码逻辑
await new Promise((resolve) => setTimeout(resolve, 1000));
message.success('密码重置成功,请登录');
router.push('/login');
await new Promise((resolve) => setTimeout(resolve, 1000))
message.success('密码重置成功,请登录')
router.push('/login')
} catch {
message.error('密码重置失败,请稍后重试');
message.error('密码重置失败,请稍后重试')
} finally {
loading.value = false;
loading.value = false
}
};
}
</script>
<style scoped>
.login-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
}
.login-wrapper {
width: 100%;
max-width: 400px;
}
.login-card {
background: white;
border-radius: 16px;
padding: 40px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}
.login-header {
text-align: center;
margin-bottom: 32px;
}
.login-logo h1 {
margin: 0;
font-size: 28px;
font-weight: 700;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.login-subtitle {
margin: 8px 0 0;
color: #666;
font-size: 14px;
}
.login-form {
margin-top: 24px;
}
.login-form :deep(.ant-form-item) {
margin-bottom: 20px;
}
.login-form :deep(.ant-input-affix-wrapper),
.login-form :deep(.ant-input) {
border-radius: 8px;
}
.code-btn {
padding: 0;
height: auto;
font-size: 14px;
}
.form-footer {
text-align: center;
margin-top: 16px;
color: #666;
font-size: 14px;
}
.register-link {
color: #667eea;
text-decoration: none;
font-weight: 500;
margin-left: 4px;
}
.register-link:hover {
text-decoration: underline;
}
/* 所有样式已移至统一样式文件 src/assets/style/auth-pages.scss */
</style>

View File

@@ -1,20 +1,47 @@
<template>
<div class="login-container">
<div class="login-wrapper">
<div class="login-card">
<div class="login-header">
<div class="login-logo">
<h1>Vue Admin</h1>
</div>
<p class="login-subtitle">创建新账号</p>
<div class="register-container auth-container">
<!-- 科技感背景 -->
<div class="tech-bg">
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="grid-line"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
<div class="light-spot"></div>
</div>
<a-form :model="formState" @finish="handleRegister" layout="vertical" class="login-form">
<!-- 主内容区 -->
<div class="register-wrapper auth-wrapper">
<div class="register-card auth-card">
<!-- 左侧装饰区 -->
<div class="decoration-area">
<div class="tech-circle">
<div class="circle-inner"></div>
<div class="circle-ring"></div>
<div class="circle-ring circle-ring-2"></div>
</div>
<div class="decoration-text">
<h2>创建账号</h2>
<p>加入智能管理系统</p>
</div>
</div>
<!-- 右侧表单区 -->
<div class="form-area">
<div class="auth-header">
<h1>Vue Admin</h1>
<p class="subtitle">注册新账户</p>
</div>
<a-form :model="formState" @finish="handleRegister" layout="vertical"
class="auth-form register-form">
<a-form-item name="username" :rules="[
{ required: true, message: '请输入用户名' },
{ min: 3, message: '用户名至少3个字符' },
]">
<a-input v-model:value="formState.username" placeholder="用户名" size="large"
<a-input v-model:value="formState.username" placeholder="请输入用户名" size="large"
:prefix="h(UserOutlined)" />
</a-form-item>
@@ -22,7 +49,7 @@
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '请输入有效的邮箱地址' },
]">
<a-input v-model:value="formState.email" placeholder="邮箱地址" size="large"
<a-input v-model:value="formState.email" placeholder="请输入邮箱地址" size="large"
:prefix="h(MailOutlined)" />
</a-form-item>
@@ -30,7 +57,7 @@
{ required: true, message: '请输入密码' },
{ min: 6, message: '密码至少6个字符' },
]">
<a-input-password v-model:value="formState.password" placeholder="密码" size="large"
<a-input-password v-model:value="formState.password" placeholder="请输入密码" size="large"
:prefix="h(LockOutlined)" />
</a-form-item>
@@ -38,16 +65,18 @@
{ required: true, message: '请确认密码' },
{ validator: validateConfirmPassword },
]">
<a-input-password v-model:value="formState.confirmPassword" placeholder="确认密码" size="large"
:prefix="h(LockOutlined)" />
<a-input-password v-model:value="formState.confirmPassword" placeholder="请再次输入密码"
size="large" :prefix="h(LockOutlined)" />
</a-form-item>
<a-form-item>
<a-checkbox v-model:checked="formState.agree">
<a-checkbox v-model:checked="formState.agree" class="agreement-checkbox">
<span class="agreement-text">
我已阅读并同意
<a href="#" class="link">用户协议</a>
<a href="#" class="link">隐私政策</a>
</span>
</a-checkbox>
</a-form-item>
@@ -60,7 +89,7 @@
<div class="form-footer">
<span>已有账号</span>
<router-link to="/login" class="register-link">
<router-link to="/login" class="auth-link">
立即登录
</router-link>
</div>
@@ -68,25 +97,22 @@
</div>
</div>
</div>
</div>
</template>
<script setup>
import { reactive, ref, h } from 'vue';
import { useRouter } from 'vue-router';
import { message } from 'ant-design-vue';
import {
UserOutlined,
MailOutlined,
LockOutlined,
} from '@ant-design/icons-vue';
import { reactive, ref, h } from 'vue'
import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
import { UserOutlined, MailOutlined, LockOutlined } from '@ant-design/icons-vue'
import '@/assets/style/auth-pages.scss'
// 定义组件名称(多词命名)
defineOptions({
name: 'RegisterPage'
});
})
const router = useRouter();
const loading = ref(false);
const router = useRouter()
const loading = ref(false)
const formState = reactive({
username: '',
@@ -94,110 +120,30 @@ const formState = reactive({
password: '',
confirmPassword: '',
agree: false,
});
})
const validateConfirmPassword = async (rule, value) => {
if (value !== formState.password) {
return Promise.reject('两次输入的密码不一致');
return Promise.reject('两次输入的密码不一致')
}
return Promise.resolve();
};
return Promise.resolve()
}
const handleRegister = async () => {
loading.value = true;
loading.value = true
try {
// TODO: 实现注册逻辑
await new Promise((resolve) => setTimeout(resolve, 1000));
message.success('注册成功,请登录');
router.push('/login');
await new Promise((resolve) => setTimeout(resolve, 1000))
message.success('注册成功,请登录')
router.push('/login')
} catch {
message.error('注册失败,请稍后重试');
message.error('注册失败,请稍后重试')
} finally {
loading.value = false;
loading.value = false
}
};
}
</script>
<style scoped>
.login-container {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 20px;
}
.login-wrapper {
width: 100%;
max-width: 400px;
}
.login-card {
background: white;
border-radius: 16px;
padding: 40px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}
.login-header {
text-align: center;
margin-bottom: 32px;
}
.login-logo h1 {
margin: 0;
font-size: 28px;
font-weight: 700;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.login-subtitle {
margin: 8px 0 0;
color: #666;
font-size: 14px;
}
.login-form {
margin-top: 24px;
}
.login-form :deep(.ant-form-item) {
margin-bottom: 20px;
}
.login-form :deep(.ant-input-affix-wrapper),
.login-form :deep(.ant-input) {
border-radius: 8px;
}
.link {
color: #667eea;
text-decoration: none;
}
.link:hover {
text-decoration: underline;
}
.form-footer {
text-align: center;
margin-top: 16px;
color: #666;
font-size: 14px;
}
.register-link {
color: #667eea;
text-decoration: none;
font-weight: 500;
margin-left: 4px;
}
.register-link:hover {
text-decoration: underline;
}
/* 所有样式已移至统一样式文件 src/assets/style/auth-pages.scss */
</style>

View File

@@ -7,6 +7,8 @@
import { ref, computed } from 'vue'
import { message } from 'ant-design-vue'
import scForm from '@/components/scForm/index.vue'
import api from '@/api/auth'
import { useUserStore } from '@/stores/modules/user'
const props = defineProps({
userInfo: {
@@ -17,13 +19,14 @@ const props = defineProps({
const emit = defineEmits(['update'])
const userStore = useUserStore()
const loading = ref(false)
// 表单初始值
const initialValues = computed(() => ({
username: props.userInfo.username || '',
nickname: props.userInfo.nickname || '',
phone: props.userInfo.phone || '',
mobile: props.userInfo.mobile || '',
email: props.userInfo.email || '',
gender: props.userInfo.gender || 0,
birthday: props.userInfo.birthday || null,
@@ -32,68 +35,65 @@ const initialValues = computed(() => ({
// 表单项配置
const formItems = [
{ field: 'username', label: '用户名', type: 'input' },
{
field: 'username',
label: '用户名',
type: 'input',
disabled: true,
},
{
field: 'nickname',
label: '昵称',
type: 'input',
required: true,
field: 'nickname', label: '昵称', type: 'input', required: true,
rules: [
{ required: true, message: '请输入昵称', trigger: 'blur' },
{ min: 2, max: 20, message: '昵称长度在 2 到 20 个字符', trigger: 'blur' },
],
},
{
field: 'phone',
label: '手机号',
type: 'input',
field: 'phone', label: '手机号', type: 'input',
rules: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }],
},
{
field: 'email',
label: '邮箱',
type: 'input',
field: 'email', label: '邮箱', type: 'input',
rules: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }],
},
{
field: 'gender',
label: '性别',
type: 'radio',
field: 'gender', label: '性别', type: 'radio',
options: [
{ label: '男', value: 1 },
{ label: '女', value: 2 },
{ label: '保密', value: 0 },
],
},
{
field: 'birthday',
label: '生日',
type: 'date',
},
{
field: 'bio',
label: '个人简介',
type: 'textarea',
rows: 4,
maxLength: 200,
showCount: true,
},
{ field: 'remark', label: '个人简介', type: 'textarea', rows: 4, maxLength: 200, showCount: true, },
]
// 表单提交
const handleFinish = (values) => {
const handleFinish = async (values) => {
try {
loading.value = true
// 模拟接口请求
setTimeout(() => {
// 调用更新当前用户信息接口
let res = await api.users.edit.post({
username: values.username,
nickname: values.nickname,
mobile: values.mobile,
email: values.email,
gender: values.gender,
remark: values.remark,
})
if (!res || res.code !== 1) {
throw new Error(res.message || '保存失败,请重试')
}
// 重新获取用户信息
const response = await api.user.get()
if (response && response.data) {
userStore.setUserInfo(response.data)
}
// 通知父组件更新
emit('update', values)
message.success('保存成功')
} catch (error) {
message.error(error.message || '保存失败,请重试')
} finally {
loading.value = false
}, 1000)
}
}
// 重置表单

View File

@@ -58,19 +58,17 @@ import ProfileInfo from './components/ProfileInfo.vue'
import BasicInfo from './components/BasicInfo.vue'
import Password from './components/Password.vue'
import Security from './components/Security.vue'
import { useUserStore } from '@/stores/modules/user'
import api from '@/api/auth'
defineOptions({
name: 'UserCenter',
})
const userStore = useUserStore()
// 用户信息
const userInfo = ref({
username: '',
nickname: '',
phone: '',
email: '',
avatar: '',
status: 1,
gender: 0,
birthday: null,
bio: '',
})
const userInfo = ref({})
// 选中的菜单
const selectedKeys = ref(['basic'])
@@ -81,25 +79,34 @@ const avatarFileList = ref([])
const loading = ref(false)
// 初始化用户信息
const initUserInfo = () => {
// 模拟用户数据
const mockUserInfo = {
username: 'admin',
nickname: '管理员',
phone: '13800138000',
email: 'admin@example.com',
avatar: '',
status: 1,
gender: 1,
birthday: dayjs('1990-01-01'),
bio: '热爱编程,专注于前端开发技术。',
const initUserInfo = async () => {
try {
// 从 store 获取用户信息
const storeUserInfo = userStore.userInfo
if (storeUserInfo) {
userInfo.value = storeUserInfo
} else {
// 如果 store 中没有用户信息,则从接口获取
const response = await api.user.get()
if (response && response.data) {
userStore.setUserInfo(response.data)
userInfo.value = response.data
}
}
} catch (err) {
message.error(err.message || '获取用户信息失败')
}
userInfo.value = { ...mockUserInfo }
}
// 更新用户信息
const handleUpdateUserInfo = (data) => {
// 更新本地用户信息
Object.assign(userInfo.value, data)
// 如果 birthday 有值,转换为 dayjs 对象
if (data.birthday && typeof data.birthday === 'string') {
userInfo.value.birthday = dayjs(data.birthday)
}
}
// 密码修改成功

1265
yarn.lock

File diff suppressed because it is too large Load Diff