登录页/欢迎页美化
This commit is contained in:
parent
96b032d262
commit
cf34013c53
1
components.d.ts
vendored
1
components.d.ts
vendored
@ -22,6 +22,7 @@ declare module '@vue/runtime-core' {
|
|||||||
ElForm: typeof import('element-plus/es')['ElForm']
|
ElForm: typeof import('element-plus/es')['ElForm']
|
||||||
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
ElFormItem: typeof import('element-plus/es')['ElFormItem']
|
||||||
ElHeader: typeof import('element-plus/es')['ElHeader']
|
ElHeader: typeof import('element-plus/es')['ElHeader']
|
||||||
|
ElIcon: typeof import('element-plus/es')['ElIcon']
|
||||||
ElInput: typeof import('element-plus/es')['ElInput']
|
ElInput: typeof import('element-plus/es')['ElInput']
|
||||||
ElMain: typeof import('element-plus/es')['ElMain']
|
ElMain: typeof import('element-plus/es')['ElMain']
|
||||||
ElMenu: typeof import('element-plus/es')['ElMenu']
|
ElMenu: typeof import('element-plus/es')['ElMenu']
|
||||||
|
|||||||
@ -1,16 +1,42 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="login-wrapper">
|
<div class="login-page">
|
||||||
<h2 class="title">博客管理后台</h2>
|
<div class="login-card">
|
||||||
<el-form ref="loginForm" :model="userInfo" :rules="ruleValidate" :label-width="80">
|
<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-form-item label="用户名" prop="username">
|
||||||
<el-input v-model="userInfo.username" @on-enter="login"/>
|
<el-input
|
||||||
|
v-model="userInfo.username"
|
||||||
|
placeholder="请输入用户名"
|
||||||
|
prefix-icon="User"
|
||||||
|
size="large"
|
||||||
|
@keyup.enter="login"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="密码" prop="password">
|
<el-form-item label="密码" prop="password">
|
||||||
<el-input v-model="userInfo.password" type="password" @on-enter="login" />
|
<el-input
|
||||||
|
v-model="userInfo.password"
|
||||||
|
type="password"
|
||||||
|
placeholder="请输入密码"
|
||||||
|
prefix-icon="Lock"
|
||||||
|
size="large"
|
||||||
|
show-password
|
||||||
|
@keyup.enter="login"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-button class="login-btn" type="primary" size="large" :loading="loading" @click="login">
|
||||||
|
登 录
|
||||||
|
</el-button>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div class="login-btn">
|
</div>
|
||||||
<el-button type="primary" @click="login">登录</el-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -44,6 +70,8 @@ const ruleValidate = {
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
|
||||||
// created
|
// created
|
||||||
store.commit('logout')
|
store.commit('logout')
|
||||||
store.commit('clearTabs')
|
store.commit('clearTabs')
|
||||||
@ -52,7 +80,10 @@ localStorage.clear()
|
|||||||
async function login() {
|
async function login() {
|
||||||
loginForm.value?.validate(async (valid: boolean) => {
|
loginForm.value?.validate(async (valid: boolean) => {
|
||||||
if (!valid) return
|
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) {
|
if (data.token) {
|
||||||
store.commit('login', data)
|
store.commit('login', data)
|
||||||
router.push('/')
|
router.push('/')
|
||||||
@ -63,19 +94,139 @@ async function login() {
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.login-wrapper {
|
.login-page {
|
||||||
width: 400px;
|
min-height: 100vh;
|
||||||
vertical-align: middle;
|
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;
|
position: absolute;
|
||||||
top: 40%;
|
border-radius: 50%;
|
||||||
left: 50%;
|
filter: blur(80px);
|
||||||
transform: translate(-50%, -50%);
|
opacity: 0.15;
|
||||||
.title {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
}
|
}
|
||||||
.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;
|
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>
|
</style>
|
||||||
@ -1,14 +1,27 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="welcome-page">
|
||||||
<div class="nav-list">
|
<div class="welcome-header">
|
||||||
<el-row v-for="menu in menus" :key="menu.name">
|
<h2>欢迎回来 👋</h2>
|
||||||
<el-col :span="3" class="nav-title">{{ menu.title }}</el-col>
|
<p>选择下方快捷入口,开始管理你的博客</p>
|
||||||
<el-col :span="21">
|
</div>
|
||||||
<router-link :to="submenu.path" v-for="submenu in menu.child" :key="submenu.path" class="nav-item">
|
<div class="menu-sections">
|
||||||
{{submenu.title}}
|
<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>
|
</router-link>
|
||||||
</el-col>
|
</div>
|
||||||
</el-row>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -16,22 +29,91 @@
|
|||||||
import menus from '../config/menu'
|
import menus from '../config/menu'
|
||||||
</script>
|
</script>
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.nav-list {
|
.welcome-page {
|
||||||
.nav-title {
|
padding: 32px;
|
||||||
font-size: 16px;
|
max-width: 900px;
|
||||||
line-height: 66px;
|
|
||||||
text-align: right;
|
|
||||||
padding-right: 20px;
|
|
||||||
}
|
}
|
||||||
.nav-item {
|
|
||||||
display: inline-block;
|
.welcome-header {
|
||||||
width: 200px;
|
margin-bottom: 32px;
|
||||||
font-size: 16px;
|
h2 {
|
||||||
margin: 10px;
|
font-size: 26px;
|
||||||
border: 1px solid #ccc;
|
font-weight: 700;
|
||||||
padding: 10px;
|
color: #1d2129;
|
||||||
text-decoration: none;
|
margin: 0 0 8px;
|
||||||
|
}
|
||||||
|
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);
|
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>
|
</style>
|
||||||
Loading…
x
Reference in New Issue
Block a user