优化更新

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

View File

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

View File

@@ -1,45 +1,72 @@
<template> <template>
<div class="login-container"> <div class="login-container auth-container">
<div class="login-wrapper"> <!-- 科技感背景 -->
<div class="login-card"> <div class="tech-bg">
<div class="login-header"> <div class="grid-line"></div>
<div class="login-logo"> <div class="grid-line"></div>
<h1>Vue Admin</h1> <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>
<!-- 主内容区 -->
<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>
<p class="login-subtitle">欢迎回来</p>
</div> </div>
<a-form :model="formState" @finish="handleLogin" layout="vertical" class="login-form"> <!-- 右侧表单区 -->
<a-form-item name="username" :rules="[{ required: true, message: '请输入用户名' }]"> <div class="form-area">
<a-input v-model:value="formState.username" placeholder="用户名" size="large" <div class="auth-header">
:prefix="h(UserOutlined)" /> <h1>Vue Admin</h1>
</a-form-item> <p class="subtitle">登录您的账户</p>
<a-form-item name="password" :rules="[{ required: true, message: '请输入密码' }]">
<a-input-password v-model:value="formState.password" placeholder="密码" size="large"
:prefix="h(LockOutlined)" />
</a-form-item>
<div class="form-options">
<a-checkbox v-model:checked="formState.remember">记住密码</a-checkbox>
<router-link to="/reset-password" class="forgot-password">
忘记密码
</router-link>
</div> </div>
<a-form-item> <a-form :model="formState" @finish="handleLogin" layout="vertical" class="auth-form login-form">
<a-button type="primary" html-type="submit" size="large" block :loading="loading"> <a-form-item name="username" :rules="[{ required: true, message: '请输入用户名' }]">
登录 <a-input v-model:value="formState.username" placeholder="请输入用户名" size="large"
</a-button> :prefix="h(UserOutlined)" />
</a-form-item> </a-form-item>
<div class="form-footer"> <a-form-item name="password" :rules="[{ required: true, message: '请输入密码' }]">
<span>还没有账号</span> <a-input-password v-model:value="formState.password" placeholder="请输入密码" size="large"
<router-link to="/register" class="register-link"> :prefix="h(LockOutlined)" />
立即注册 </a-form-item>
</router-link>
</div> <div class="form-options">
</a-form> <a-checkbox v-model:checked="formState.remember">记住密码</a-checkbox>
<router-link to="/reset-password" class="forgot-password">
忘记密码
</router-link>
</div>
<a-form-item>
<a-button type="primary" html-type="submit" size="large" block :loading="loading">
登录
</a-button>
</a-form-item>
<div class="form-footer">
<span>还没有账号</span>
<router-link to="/register" class="auth-link">
立即注册
</router-link>
</div>
</a-form>
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -52,27 +79,29 @@ import { message } from 'ant-design-vue'
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue' import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
import { useUserStore } from '@/stores/modules/user' import { useUserStore } from '@/stores/modules/user'
import authApi from '@/api/auth' import authApi from '@/api/auth'
import '@/assets/style/auth-pages.scss'
// 定义组件名称(多词命名)
defineOptions({ defineOptions({
name: 'LoginPage' name: 'LoginPage'
}); })
const router = useRouter(); const router = useRouter()
const loading = ref(false); const loading = ref(false)
const userStore = useUserStore() const userStore = useUserStore()
const formState = reactive({ const formState = reactive({
username: '', username: '',
password: '', password: '',
remember: false, remember: false,
}); })
const handleLogin = async () => { const handleLogin = async () => {
loading.value = true; loading.value = true
try { try {
let res = await authApi.login.post({
let res = await authApi.login.post({ username: formState.username, password: formState.password }) username: formState.username,
password: formState.password,
})
if (res.code == 1) { if (res.code == 1) {
userStore.setToken(res.data.access_token) userStore.setToken(res.data.access_token)
let userInfo = await authApi.user.get() let userInfo = await authApi.user.get()
@@ -80,112 +109,23 @@ const handleLogin = async () => {
userStore.setUserInfo(userInfo.data) userStore.setUserInfo(userInfo.data)
} }
let authData = await authApi.menu.my.get() let authData = await authApi.menu.my.get()
if (authData.code == 1){ if (authData.code == 1) {
userStore.setMenu(authData.data.menu) userStore.setMenu(authData.data.menu)
userStore.setPermissions(authData.data.permissions) userStore.setPermissions(authData.data.permissions)
} }
message.success('登录成功'); message.success('登录成功')
// 跳转到首页或重定向页面
const redirect = router.currentRoute.value.query.redirect || '/' const redirect = router.currentRoute.value.query.redirect || '/'
router.push(redirect) router.push(redirect)
} }
} catch { } catch {
message.error('登录失败,请检查用户名和密码'); message.error('登录失败,请检查用户名和密码')
} finally { } finally {
loading.value = false; loading.value = false
} }
}; }
</script> </script>
<style scoped> <style scoped>
.login-container { /* 所有样式已移至统一样式文件 src/assets/style/auth-pages.scss */
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;
}
</style> </style>

View File

@@ -1,210 +1,156 @@
<template> <template>
<div class="login-container"> <div class="reset-container auth-container">
<div class="login-wrapper"> <!-- 科技感背景 -->
<div class="login-card"> <div class="tech-bg">
<div class="login-header"> <div class="grid-line"></div>
<div class="login-logo"> <div class="grid-line"></div>
<h1>Vue Admin</h1> <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>
<!-- 主内容区 -->
<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>
<p class="login-subtitle">重置密码</p>
</div> </div>
<a-form :model="formState" @finish="handleReset" layout="vertical" class="login-form"> <!-- 右侧表单区 -->
<a-form-item name="email" :rules="[ <div class="form-area">
{ required: true, message: '请输入邮箱' }, <div class="auth-header">
{ type: 'email', message: '请输入有效的邮箱地址' }, <h1>Vue Admin</h1>
]"> <p class="subtitle">设置新密码</p>
<a-input v-model:value="formState.email" placeholder="邮箱地址" size="large" </div>
:prefix="h(MailOutlined)" />
</a-form-item>
<a-form-item name="verificationCode" :rules="[{ required: true, message: '请输入验证码' }]"> <a-form :model="formState" @finish="handleReset" layout="vertical" class="auth-form reset-form">
<a-input v-model:value="formState.verificationCode" placeholder="验证码" size="large" <a-form-item name="email" :rules="[
:prefix="h(SafetyOutlined)"> { required: true, message: '请输入邮箱' },
<template #suffix> { type: 'email', message: '请输入有效的邮箱地址' },
<a-button type="link" :disabled="countdown > 0" @click="sendCode" class="code-btn"> ]">
<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: '请输入验证码' }]">
<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}秒后重试` : '发送验证码' }} {{ countdown > 0 ? `${countdown}秒后重试` : '发送验证码' }}
</a-button> </a-button>
</template> </div>
</a-input> </a-form-item>
</a-form-item>
<a-form-item name="newPassword" :rules="[ <a-form-item name="newPassword" :rules="[
{ required: true, message: '请输入新密码' }, { required: true, message: '请输入新密码' },
{ min: 6, message: '密码至少6个字符' }, { 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)" /> :prefix="h(LockOutlined)" />
</a-form-item> </a-form-item>
<a-form-item name="confirmPassword" :rules="[ <a-form-item name="confirmPassword" :rules="[
{ required: true, message: '请确认新密码' }, { required: true, message: '请确认新密码' },
{ validator: validateConfirmPassword }, { validator: validateConfirmPassword },
]"> ]">
<a-input-password v-model:value="formState.confirmPassword" placeholder="确认新密码" size="large" <a-input-password v-model:value="formState.confirmPassword" placeholder="请再次输入新密码"
:prefix="h(LockOutlined)" /> size="large" :prefix="h(LockOutlined)" />
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-button type="primary" html-type="submit" size="large" block :loading="loading"> <a-button type="primary" html-type="submit" size="large" block :loading="loading">
重置密码 重置密码
</a-button> </a-button>
</a-form-item> </a-form-item>
<div class="form-footer"> <div class="form-footer">
<span>记得密码了</span> <span>记得密码了</span>
<router-link to="/login" class="register-link"> <router-link to="/login" class="auth-link">
立即登录 立即登录
</router-link> </router-link>
</div> </div>
</a-form> </a-form>
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { reactive, ref, h } from 'vue'; import { reactive, ref, h } from 'vue'
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue'
import { import { MailOutlined, SafetyOutlined, LockOutlined } from '@ant-design/icons-vue'
MailOutlined, import '@/assets/style/auth-pages.scss'
SafetyOutlined,
LockOutlined,
} from '@ant-design/icons-vue';
// 定义组件名称(多词命名)
defineOptions({ defineOptions({
name: 'ResetPasswordPage' name: 'ResetPasswordPage'
}); })
const router = useRouter(); const router = useRouter()
const loading = ref(false); const loading = ref(false)
const countdown = ref(0); const countdown = ref(0)
const formState = reactive({ const formState = reactive({
email: '', email: '',
verificationCode: '', verificationCode: '',
newPassword: '', newPassword: '',
confirmPassword: '', confirmPassword: '',
}); })
const validateConfirmPassword = async (rule, value) => { const validateConfirmPassword = async (rule, value) => {
if (value !== formState.newPassword) { if (value !== formState.newPassword) {
return Promise.reject('两次输入的密码不一致'); return Promise.reject('两次输入的密码不一致')
} }
return Promise.resolve(); return Promise.resolve()
}; }
const sendCode = () => { const sendCode = () => {
if (!formState.email) { if (!formState.email) {
message.warning('请先输入邮箱地址'); message.warning('请先输入邮箱地址')
return; return
} }
// TODO: 实现发送验证码逻辑 // TODO: 实现发送验证码逻辑
message.success('验证码已发送'); message.success('验证码已发送')
countdown.value = 60; countdown.value = 60
const timer = setInterval(() => { const timer = setInterval(() => {
countdown.value--; countdown.value--
if (countdown.value <= 0) { if (countdown.value <= 0) {
clearInterval(timer); clearInterval(timer)
} }
}, 1000); }, 1000)
}; }
const handleReset = async () => { const handleReset = async () => {
loading.value = true; loading.value = true
try { try {
// TODO: 实现重置密码逻辑 // TODO: 实现重置密码逻辑
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000))
message.success('密码重置成功,请登录'); message.success('密码重置成功,请登录')
router.push('/login'); router.push('/login')
} catch { } catch {
message.error('密码重置失败,请稍后重试'); message.error('密码重置失败,请稍后重试')
} finally { } finally {
loading.value = false; loading.value = false
} }
}; }
</script> </script>
<style scoped> <style scoped>
.login-container { /* 所有样式已移至统一样式文件 src/assets/style/auth-pages.scss */
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;
}
</style> </style>

View File

@@ -1,92 +1,118 @@
<template> <template>
<div class="login-container"> <div class="register-container auth-container">
<div class="login-wrapper"> <!-- 科技感背景 -->
<div class="login-card"> <div class="tech-bg">
<div class="login-header"> <div class="grid-line"></div>
<div class="login-logo"> <div class="grid-line"></div>
<h1>Vue Admin</h1> <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>
<!-- 主内容区 -->
<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>
<p class="login-subtitle">创建新账号</p>
</div> </div>
<a-form :model="formState" @finish="handleRegister" layout="vertical" class="login-form"> <!-- 右侧表单区 -->
<a-form-item name="username" :rules="[ <div class="form-area">
{ required: true, message: '请输入用户名' }, <div class="auth-header">
{ min: 3, message: '用户名至少3个字符' }, <h1>Vue Admin</h1>
]"> <p class="subtitle">注册新账户</p>
<a-input v-model:value="formState.username" placeholder="用户名" size="large"
:prefix="h(UserOutlined)" />
</a-form-item>
<a-form-item name="email" :rules="[
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '请输入有效的邮箱地址' },
]">
<a-input v-model:value="formState.email" placeholder="邮箱地址" size="large"
:prefix="h(MailOutlined)" />
</a-form-item>
<a-form-item name="password" :rules="[
{ required: true, message: '请输入密码' },
{ min: 6, message: '密码至少6个字符' },
]">
<a-input-password v-model:value="formState.password" placeholder="密码" size="large"
:prefix="h(LockOutlined)" />
</a-form-item>
<a-form-item name="confirmPassword" :rules="[
{ required: true, message: '请确认密码' },
{ validator: validateConfirmPassword },
]">
<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 href="#" class="link">用户协议</a>
<a href="#" class="link">隐私政策</a>
</a-checkbox>
</a-form-item>
<a-form-item>
<a-button type="primary" html-type="submit" size="large" block :loading="loading"
:disabled="!formState.agree">
注册
</a-button>
</a-form-item>
<div class="form-footer">
<span>已有账号</span>
<router-link to="/login" class="register-link">
立即登录
</router-link>
</div> </div>
</a-form>
<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"
:prefix="h(UserOutlined)" />
</a-form-item>
<a-form-item name="email" :rules="[
{ required: true, message: '请输入邮箱' },
{ type: 'email', message: '请输入有效的邮箱地址' },
]">
<a-input v-model:value="formState.email" placeholder="请输入邮箱地址" size="large"
:prefix="h(MailOutlined)" />
</a-form-item>
<a-form-item name="password" :rules="[
{ required: true, message: '请输入密码' },
{ min: 6, message: '密码至少6个字符' },
]">
<a-input-password v-model:value="formState.password" placeholder="请输入密码" size="large"
:prefix="h(LockOutlined)" />
</a-form-item>
<a-form-item name="confirmPassword" :rules="[
{ required: true, message: '请确认密码' },
{ validator: validateConfirmPassword },
]">
<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" class="agreement-checkbox">
<span class="agreement-text">
我已阅读并同意
<a href="#" class="link">用户协议</a>
<a href="#" class="link">隐私政策</a>
</span>
</a-checkbox>
</a-form-item>
<a-form-item>
<a-button type="primary" html-type="submit" size="large" block :loading="loading"
:disabled="!formState.agree">
注册
</a-button>
</a-form-item>
<div class="form-footer">
<span>已有账号</span>
<router-link to="/login" class="auth-link">
立即登录
</router-link>
</div>
</a-form>
</div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
<script setup> <script setup>
import { reactive, ref, h } from 'vue'; import { reactive, ref, h } from 'vue'
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'; import { message } from 'ant-design-vue'
import { import { UserOutlined, MailOutlined, LockOutlined } from '@ant-design/icons-vue'
UserOutlined, import '@/assets/style/auth-pages.scss'
MailOutlined,
LockOutlined,
} from '@ant-design/icons-vue';
// 定义组件名称(多词命名)
defineOptions({ defineOptions({
name: 'RegisterPage' name: 'RegisterPage'
}); })
const router = useRouter(); const router = useRouter()
const loading = ref(false); const loading = ref(false)
const formState = reactive({ const formState = reactive({
username: '', username: '',
@@ -94,110 +120,30 @@ const formState = reactive({
password: '', password: '',
confirmPassword: '', confirmPassword: '',
agree: false, agree: false,
}); })
const validateConfirmPassword = async (rule, value) => { const validateConfirmPassword = async (rule, value) => {
if (value !== formState.password) { if (value !== formState.password) {
return Promise.reject('两次输入的密码不一致'); return Promise.reject('两次输入的密码不一致')
} }
return Promise.resolve(); return Promise.resolve()
}; }
const handleRegister = async () => { const handleRegister = async () => {
loading.value = true; loading.value = true
try { try {
// TODO: 实现注册逻辑 // TODO: 实现注册逻辑
await new Promise((resolve) => setTimeout(resolve, 1000)); await new Promise((resolve) => setTimeout(resolve, 1000))
message.success('注册成功,请登录'); message.success('注册成功,请登录')
router.push('/login'); router.push('/login')
} catch { } catch {
message.error('注册失败,请稍后重试'); message.error('注册失败,请稍后重试')
} finally { } finally {
loading.value = false; loading.value = false
} }
}; }
</script> </script>
<style scoped> <style scoped>
.login-container { /* 所有样式已移至统一样式文件 src/assets/style/auth-pages.scss */
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;
}
</style> </style>

View File

@@ -7,6 +7,8 @@
import { ref, computed } from 'vue' import { ref, computed } from 'vue'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import scForm from '@/components/scForm/index.vue' import scForm from '@/components/scForm/index.vue'
import api from '@/api/auth'
import { useUserStore } from '@/stores/modules/user'
const props = defineProps({ const props = defineProps({
userInfo: { userInfo: {
@@ -17,13 +19,14 @@ const props = defineProps({
const emit = defineEmits(['update']) const emit = defineEmits(['update'])
const userStore = useUserStore()
const loading = ref(false) const loading = ref(false)
// 表单初始值 // 表单初始值
const initialValues = computed(() => ({ const initialValues = computed(() => ({
username: props.userInfo.username || '', username: props.userInfo.username || '',
nickname: props.userInfo.nickname || '', nickname: props.userInfo.nickname || '',
phone: props.userInfo.phone || '', mobile: props.userInfo.mobile || '',
email: props.userInfo.email || '', email: props.userInfo.email || '',
gender: props.userInfo.gender || 0, gender: props.userInfo.gender || 0,
birthday: props.userInfo.birthday || null, birthday: props.userInfo.birthday || null,
@@ -32,68 +35,65 @@ const initialValues = computed(() => ({
// 表单项配置 // 表单项配置
const formItems = [ const formItems = [
{ field: 'username', label: '用户名', type: 'input' },
{ {
field: 'username', field: 'nickname', label: '昵称', type: 'input', required: true,
label: '用户名',
type: 'input',
disabled: true,
},
{
field: 'nickname',
label: '昵称',
type: 'input',
required: true,
rules: [ rules: [
{ required: true, message: '请输入昵称', trigger: 'blur' }, { required: true, message: '请输入昵称', trigger: 'blur' },
{ min: 2, max: 20, message: '昵称长度在 2 到 20 个字符', trigger: 'blur' }, { min: 2, max: 20, message: '昵称长度在 2 到 20 个字符', trigger: 'blur' },
], ],
}, },
{ {
field: 'phone', field: 'phone', label: '手机号', type: 'input',
label: '手机号',
type: 'input',
rules: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }], rules: [{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }],
}, },
{ {
field: 'email', field: 'email', label: '邮箱', type: 'input',
label: '邮箱',
type: 'input',
rules: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }], rules: [{ type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }],
}, },
{ {
field: 'gender', field: 'gender', label: '性别', type: 'radio',
label: '性别',
type: 'radio',
options: [ options: [
{ label: '男', value: 1 }, { label: '男', value: 1 },
{ label: '女', value: 2 }, { label: '女', value: 2 },
{ label: '保密', value: 0 }, { label: '保密', value: 0 },
], ],
}, },
{ { field: 'remark', label: '个人简介', type: 'textarea', rows: 4, maxLength: 200, showCount: true, },
field: 'birthday',
label: '生日',
type: 'date',
},
{
field: 'bio',
label: '个人简介',
type: 'textarea',
rows: 4,
maxLength: 200,
showCount: true,
},
] ]
// 表单提交 // 表单提交
const handleFinish = (values) => { const handleFinish = async (values) => {
loading.value = true 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) emit('update', values)
message.success('保存成功') message.success('保存成功')
} catch (error) {
message.error(error.message || '保存失败,请重试')
} finally {
loading.value = false loading.value = false
}, 1000) }
} }
// 重置表单 // 重置表单

View File

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