登录页/欢迎页美化

This commit is contained in:
灌糖包子 2026-03-19 23:11:03 +08:00
parent 96b032d262
commit cf34013c53
Signed by: sookie
GPG Key ID: 0599BECB75C1E68D
3 changed files with 281 additions and 47 deletions

1
components.d.ts vendored
View File

@ -22,6 +22,7 @@ declare module '@vue/runtime-core' {
ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElHeader: typeof import('element-plus/es')['ElHeader']
ElIcon: typeof import('element-plus/es')['ElIcon']
ElInput: typeof import('element-plus/es')['ElInput']
ElMain: typeof import('element-plus/es')['ElMain']
ElMenu: typeof import('element-plus/es')['ElMenu']

View File

@ -1,16 +1,42 @@
<template>
<div class="login-wrapper">
<h2 class="title">博客管理后台</h2>
<el-form ref="loginForm" :model="userInfo" :rules="ruleValidate" :label-width="80">
<el-form-item label="用户名" prop="username">
<el-input v-model="userInfo.username" @on-enter="login"/>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="userInfo.password" type="password" @on-enter="login" />
</el-form-item>
</el-form>
<div class="login-btn">
<el-button type="primary" @click="login">登录</el-button>
<div class="login-page">
<div class="login-card">
<div class="card-left">
<div class="brand">
<div class="brand-icon"></div>
<h1>Blog Admin</h1>
<p>简洁 · 高效 · 专注写作</p>
</div>
</div>
<div class="card-right">
<h2 class="form-title">欢迎回来</h2>
<p class="form-subtitle">请登录你的管理账号</p>
<el-form ref="loginForm" :model="userInfo" :rules="ruleValidate" label-position="top">
<el-form-item label="用户名" prop="username">
<el-input
v-model="userInfo.username"
placeholder="请输入用户名"
prefix-icon="User"
size="large"
@keyup.enter="login"
/>
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input
v-model="userInfo.password"
type="password"
placeholder="请输入密码"
prefix-icon="Lock"
size="large"
show-password
@keyup.enter="login"
/>
</el-form-item>
<el-button class="login-btn" type="primary" size="large" :loading="loading" @click="login">
</el-button>
</el-form>
</div>
</div>
</div>
</template>
@ -44,6 +70,8 @@ const ruleValidate = {
],
}
const loading = ref(false)
// created
store.commit('logout')
store.commit('clearTabs')
@ -52,7 +80,10 @@ localStorage.clear()
async function login() {
loginForm.value?.validate(async (valid: boolean) => {
if (!valid) return
const data = await http.post<UserInfo, any>('/api/v1/common/login', userInfo)
loading.value = true
const data = await http.post<UserInfo, any>('/api/v1/common/login', userInfo).finally(() => {
loading.value = false
})
if (data.token) {
store.commit('login', data)
router.push('/')
@ -63,19 +94,139 @@ async function login() {
}
</script>
<style lang="less" scoped>
.login-wrapper {
width: 400px;
vertical-align: middle;
position: absolute;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
.title {
text-align: center;
margin-bottom: 30px;
.login-page {
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
position: relative;
overflow: hidden;
&::before,
&::after {
content: '';
position: absolute;
border-radius: 50%;
filter: blur(80px);
opacity: 0.15;
}
.login-btn {
&::before {
width: 500px;
height: 500px;
background: #409eff;
top: -100px;
left: -100px;
}
&::after {
width: 400px;
height: 400px;
background: #67c23a;
bottom: -100px;
right: -100px;
}
}
.login-card {
display: flex;
width: 820px;
min-height: 480px;
border-radius: 20px;
overflow: hidden;
box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
position: relative;
z-index: 1;
}
.card-left {
flex: 1;
background: linear-gradient(145deg, #409eff, #0068d4);
display: flex;
align-items: center;
justify-content: center;
padding: 40px;
position: relative;
overflow: hidden;
&::before {
content: '';
position: absolute;
width: 300px;
height: 300px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.06);
top: -80px;
right: -80px;
}
&::after {
content: '';
position: absolute;
width: 200px;
height: 200px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.06);
bottom: -60px;
left: -60px;
}
.brand {
text-align: center;
color: #fff;
position: relative;
z-index: 1;
.brand-icon {
font-size: 48px;
margin-bottom: 16px;
opacity: 0.9;
}
h1 {
font-size: 28px;
font-weight: 700;
margin: 0 0 12px;
letter-spacing: 2px;
}
p {
font-size: 14px;
opacity: 0.75;
letter-spacing: 3px;
margin: 0;
}
}
}
.card-right {
flex: 1.1;
background: #fff;
padding: 52px 48px;
display: flex;
flex-direction: column;
justify-content: center;
.form-title {
font-size: 26px;
font-weight: 700;
color: #1d2129;
margin: 0 0 8px;
}
.form-subtitle {
font-size: 14px;
color: #86909c;
margin: 0 0 36px;
}
:deep(.el-form-item__label) {
font-weight: 600;
color: #4e5969;
}
.login-btn {
width: 100%;
margin-top: 8px;
height: 46px;
font-size: 16px;
letter-spacing: 4px;
border-radius: 8px;
}
}
</style>

View File

@ -1,14 +1,27 @@
<template>
<div>
<div class="nav-list">
<el-row v-for="menu in menus" :key="menu.name">
<el-col :span="3" class="nav-title">{{ menu.title }}</el-col>
<el-col :span="21">
<router-link :to="submenu.path" v-for="submenu in menu.child" :key="submenu.path" class="nav-item">
{{submenu.title}}
<div class="welcome-page">
<div class="welcome-header">
<h2>欢迎回来 👋</h2>
<p>选择下方快捷入口开始管理你的博客</p>
</div>
<div class="menu-sections">
<div class="menu-section" v-for="menu in menus" :key="menu.name">
<div class="section-title">
<el-icon><component :is="menu.icon" /></el-icon>
<span>{{ menu.title }}</span>
</div>
<div class="section-items">
<router-link
:to="submenu.path"
v-for="submenu in menu.child"
:key="submenu.path"
class="menu-item"
>
<span class="item-label">{{ submenu.title }}</span>
<el-icon class="item-arrow"><ArrowRight /></el-icon>
</router-link>
</el-col>
</el-row>
</div>
</div>
</div>
</div>
</template>
@ -16,22 +29,91 @@
import menus from '../config/menu'
</script>
<style lang="less" scoped>
.nav-list {
.nav-title {
font-size: 16px;
line-height: 66px;
text-align: right;
padding-right: 20px;
.welcome-page {
padding: 32px;
max-width: 900px;
}
.welcome-header {
margin-bottom: 32px;
h2 {
font-size: 26px;
font-weight: 700;
color: #1d2129;
margin: 0 0 8px;
}
.nav-item {
display: inline-block;
width: 200px;
font-size: 16px;
margin: 10px;
border: 1px solid #ccc;
padding: 10px;
text-decoration: none;
p {
font-size: 14px;
color: #86909c;
margin: 0;
}
}
.menu-sections {
display: flex;
flex-direction: column;
gap: 24px;
}
.menu-section {
background: #fff;
border-radius: 12px;
padding: 24px;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
border: 1px solid #f0f0f0;
}
.section-title {
display: flex;
align-items: center;
gap: 8px;
font-size: 15px;
font-weight: 600;
color: #4e5969;
margin-bottom: 16px;
padding-bottom: 12px;
border-bottom: 1px solid #f5f5f5;
.el-icon {
font-size: 17px;
color: var(--el-color-primary);
}
}
.section-items {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
gap: 12px;
}
.menu-item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 14px 16px;
border-radius: 8px;
background: #f7f8fa;
text-decoration: none;
color: #1d2129;
font-size: 14px;
transition: all 0.2s;
border: 1px solid transparent;
.item-arrow {
font-size: 13px;
color: #c9cdd4;
transition: transform 0.2s, color 0.2s;
}
&:hover {
background: var(--el-color-primary-light-9);
border-color: var(--el-color-primary-light-5);
color: var(--el-color-primary);
.item-arrow {
color: var(--el-color-primary);
transform: translateX(3px);
}
}
}
</style>