refactor(layout): 重构项目布局和样式
- 移除 App.vue 中的复杂布局结构,改为使用 RouterView - 新增 DefaultLayout.vue 和 LoginLayout.vue 组件用于不同页面布局 - 更新 CustomLogin.vue 样式,增加登录容器和背景图 -调整 main.css 中的样式,使页面宽度自适应
This commit is contained in:
parent
371a83587e
commit
22d9be62c7
64
src/App.vue
64
src/App.vue
@ -1,67 +1,9 @@
|
|||||||
<style scoped></style>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a-layout style="min-height: 100vh">
|
<RouterView />
|
||||||
<a-layout-header :style="{ background: '#fff', width: '100%' }">
|
|
||||||
<a-menu
|
|
||||||
v-model:selectedKeys="current"
|
|
||||||
mode="horizontal"
|
|
||||||
:items="items"
|
|
||||||
theme="light"
|
|
||||||
:style="{ justifyContent: 'center' }"
|
|
||||||
/>
|
|
||||||
</a-layout-header>
|
|
||||||
<a-layout>
|
|
||||||
<a-layout-content
|
|
||||||
theme="light"
|
|
||||||
:style="{ flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'center' }"
|
|
||||||
>
|
|
||||||
<RouterView />
|
|
||||||
</a-layout-content>
|
|
||||||
<a-layout-sider
|
|
||||||
theme="light"
|
|
||||||
:collapsible="true"
|
|
||||||
:collapsed-width="0"
|
|
||||||
:defaultCollapsed="true"
|
|
||||||
>
|
|
||||||
<CustomCard :name="'rsgl'" :style="{ margin: 'auto', padding: '10px' }" />
|
|
||||||
</a-layout-sider>
|
|
||||||
</a-layout>
|
|
||||||
<a-layout-footer> jjjj</a-layout-footer>
|
|
||||||
</a-layout>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="js">
|
<script setup lang="js">
|
||||||
import { RouterView } from 'vue-router'
|
import { RouterView } from 'vue-router'
|
||||||
import { h, ref } from 'vue'
|
</script>
|
||||||
import { AppstoreOutlined, MailOutlined } from '@ant-design/icons-vue'
|
|
||||||
import CustomCard from '@/components/CustomCard.vue'
|
|
||||||
|
|
||||||
const current = ref(['mail'])
|
<style scoped></style>
|
||||||
const items = ref([
|
|
||||||
{
|
|
||||||
key: 'home',
|
|
||||||
icon: () => h(MailOutlined),
|
|
||||||
label: h('a', { href: '/' }, '首页'),
|
|
||||||
title: '首页'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'about',
|
|
||||||
icon: () => h(AppstoreOutlined),
|
|
||||||
label: h('a', { href: '/about' }, '关于'),
|
|
||||||
title: '关于'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'tool',
|
|
||||||
icon: () => h(AppstoreOutlined),
|
|
||||||
label: h('a', { href: '/tool' }, '工具'),
|
|
||||||
title: '工具'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: 'login',
|
|
||||||
icon: () => h(AppstoreOutlined),
|
|
||||||
label: h('a', { href: '/login' }, '登录'),
|
|
||||||
title: '登录'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
</script>
|
|
||||||
|
|||||||
BIN
src/assets/background.jpg
Normal file
BIN
src/assets/background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 217 KiB |
@ -1,7 +1,6 @@
|
|||||||
@import './base.css';
|
@import './base.css';
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
max-width: 1280px;
|
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 2rem;
|
padding: 2rem;
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@ -14,8 +13,8 @@ header {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main {
|
main {
|
||||||
/*width: 80%;*/
|
width: 100%;
|
||||||
width: 1080px;
|
/*width: 1080px;*/
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
flex: 2 800px;
|
flex: 2 800px;
|
||||||
@ -25,19 +24,19 @@ main {
|
|||||||
a,
|
a,
|
||||||
.green {
|
.green {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: hsla(160, 100%, 37%, 1);
|
color: hsl(0, 0%, 0%);
|
||||||
transition: 0.4s;
|
transition: 0.4s;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
a:hover {
|
a:hover {
|
||||||
background-color: hsla(160, 100%, 37%, 0.2);
|
background-color: hsla(150, 1%, 56%, 0.2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
#app {
|
#app {
|
||||||
padding: 0 2rem;
|
padding: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ const disabled = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<a-card>
|
<a-card class="login-container" :hoverable="true">
|
||||||
<a-form
|
<a-form
|
||||||
:model="formState"
|
:model="formState"
|
||||||
name="login"
|
name="login"
|
||||||
@ -42,26 +42,16 @@ const disabled = computed(() => {
|
|||||||
@finish="onfinish"
|
@finish="onfinish"
|
||||||
@finishFailed="onFinishFailed"
|
@finishFailed="onFinishFailed"
|
||||||
>
|
>
|
||||||
<a-form-item
|
<a-form-item name="account" :rules="[{ required: true, message: '请输入账号' }]">
|
||||||
label="account"
|
<a-input v-model:value="formState.account" placeholder="请输入账号">
|
||||||
name="account"
|
|
||||||
:rules="[{ required: true, message: 'Please Input Your Account' }]"
|
|
||||||
style="display: flex; align-items: center; width: 100%"
|
|
||||||
>
|
|
||||||
<a-input v-model:value="formState.account" style="width: 100%">
|
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<UserOutlined class="site-form-item-icon" style="margin-right: 8px"></UserOutlined>
|
<UserOutlined class="site-form-item-icon" style="margin-right: 8px"></UserOutlined>
|
||||||
</template>
|
</template>
|
||||||
</a-input>
|
</a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item
|
<a-form-item name="password" :rules="[{ required: true, message: '请输入密码' }]">
|
||||||
label="password"
|
<a-input-password v-model:value="formState.password" placeholder="请输入密码">
|
||||||
name="password"
|
|
||||||
:rules="[{ required: true, message: 'Please Input Your Password' }]"
|
|
||||||
style="display: flex; align-items: center; width: 100%"
|
|
||||||
>
|
|
||||||
<a-input-password v-model:value="formState.password" style="width: 100%">
|
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<LockOutlined class="site-form-item-icon" style="margin-right: 8px"></LockOutlined>
|
<LockOutlined class="site-form-item-icon" style="margin-right: 8px"></LockOutlined>
|
||||||
</template>
|
</template>
|
||||||
@ -69,23 +59,26 @@ const disabled = computed(() => {
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item name="remember" style="width: 100%">
|
<a-form-item name="remember" style="width: 100%">
|
||||||
<a-checkbox v-model:checked="formState.remember">Remember me</a-checkbox>
|
<a-checkbox v-model:checked="formState.remember">记住我</a-checkbox>
|
||||||
<a class="login-form-forgot" href="">Forgot Password</a>
|
<a class="login-form-forgot" href="">忘记密码?</a>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item style="width: 100%">
|
<a-form-item style="width: 100%">
|
||||||
<a-button :disabled="disabled" type="primary" html-type="submit" class="login-form-button"
|
<a-button :disabled="disabled" type="primary" html-type="submit" class="login-form-button"
|
||||||
>Login
|
>登录
|
||||||
</a-button>
|
</a-button>
|
||||||
<a href="">Register Now!</a>
|
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
</a-card>
|
</a-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.login-container {
|
||||||
|
background-color: rgba(253, 253, 253, 0.9);
|
||||||
|
}
|
||||||
|
|
||||||
.login-form {
|
.login-form {
|
||||||
max-width: 300px;
|
min-width: 350px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.login-form-forgot {
|
.login-form-forgot {
|
||||||
|
|||||||
61
src/layouts/DefaultLayout.vue
Normal file
61
src/layouts/DefaultLayout.vue
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<script setup>
|
||||||
|
import CustomCard from '@/components/CustomCard.vue'
|
||||||
|
import { RouterView } from 'vue-router'
|
||||||
|
import { h, ref } from 'vue'
|
||||||
|
import { AppstoreOutlined, MailOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
|
const current = ref(['mail'])
|
||||||
|
const items = ref([
|
||||||
|
{
|
||||||
|
key: 'home',
|
||||||
|
icon: () => h(MailOutlined),
|
||||||
|
label: h('a', { href: '/' }, '首页'),
|
||||||
|
title: '首页'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'about',
|
||||||
|
icon: () => h(AppstoreOutlined),
|
||||||
|
label: h('a', { href: '/about' }, '关于'),
|
||||||
|
title: '关于'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'tool',
|
||||||
|
icon: () => h(AppstoreOutlined),
|
||||||
|
label: h('a', { href: '/tool' }, '工具'),
|
||||||
|
title: '工具'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<a-layout style="min-height: 100vh">
|
||||||
|
<a-layout-header :style="{ background: '#fff', width: '100%' }">
|
||||||
|
<a-menu
|
||||||
|
v-model:selectedKeys="current"
|
||||||
|
mode="horizontal"
|
||||||
|
:items="items"
|
||||||
|
theme="light"
|
||||||
|
:style="{ justifyContent: 'center' }"
|
||||||
|
/>
|
||||||
|
</a-layout-header>
|
||||||
|
<a-layout>
|
||||||
|
<a-layout-content
|
||||||
|
theme="light"
|
||||||
|
:style="{ flexDirection: 'column', justifyContent: 'flex-start', alignItems: 'center' }"
|
||||||
|
>
|
||||||
|
<RouterView />
|
||||||
|
</a-layout-content>
|
||||||
|
<a-layout-sider
|
||||||
|
theme="light"
|
||||||
|
:collapsible="true"
|
||||||
|
:collapsed-width="0"
|
||||||
|
:defaultCollapsed="true"
|
||||||
|
>
|
||||||
|
<CustomCard :name="'rsgl'" :style="{ margin: 'auto', padding: '10px' }" />
|
||||||
|
</a-layout-sider>
|
||||||
|
</a-layout>
|
||||||
|
<a-layout-footer>footer</a-layout-footer>
|
||||||
|
</a-layout>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
24
src/layouts/LoginLayout.vue
Normal file
24
src/layouts/LoginLayout.vue
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
<div class="login-layout">
|
||||||
|
<RouterView />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { RouterView } from 'vue-router'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.login-layout {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100%;
|
||||||
|
|
||||||
|
background:
|
||||||
|
linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)),
|
||||||
|
url('@/assets/background.jpg') no-repeat center;
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,37 +1,51 @@
|
|||||||
import { createRouter, createWebHistory } from 'vue-router'
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
import HomeView from '@/views/HomeView.vue'
|
|
||||||
import AboutView from '@/views/AboutView.vue'
|
import AboutView from '@/views/AboutView.vue'
|
||||||
import ToolView from '@/views/ToolView.vue'
|
import ToolView from '@/views/ToolView.vue'
|
||||||
import LoginView from '@/views/LoginView.vue'
|
|
||||||
import NewsView from '@/views/NewsView.vue'
|
import NewsView from '@/views/NewsView.vue'
|
||||||
|
import DefaultLayout from '../layouts/DefaultLayout.vue'
|
||||||
|
import LoginLayout from '@/layouts/LoginLayout.vue'
|
||||||
|
import LoginView from '@/views/LoginView.vue'
|
||||||
|
import HomeView from '@/views/HomeView.vue'
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
history: createWebHistory(import.meta.env.BASE_URL),
|
history: createWebHistory(import.meta.env.BASE_URL),
|
||||||
routes: [
|
routes: [
|
||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'home',
|
component: DefaultLayout,
|
||||||
component: HomeView
|
children: [
|
||||||
},
|
{
|
||||||
{
|
path: '',
|
||||||
path: '/about',
|
name: 'Home',
|
||||||
name: 'about',
|
component: HomeView
|
||||||
component: AboutView
|
},
|
||||||
},
|
{
|
||||||
{
|
path: '/about',
|
||||||
path: '/tool',
|
name: 'about',
|
||||||
name: 'tool',
|
component: AboutView
|
||||||
component: ToolView
|
},
|
||||||
|
{
|
||||||
|
path: '/tool',
|
||||||
|
name: 'tool',
|
||||||
|
component: ToolView
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/news',
|
||||||
|
name: 'news',
|
||||||
|
component: NewsView
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
name: 'login',
|
component: LoginLayout,
|
||||||
component: LoginView
|
children: [
|
||||||
},
|
{
|
||||||
{
|
path: '',
|
||||||
path: '/news',
|
name: 'Login',
|
||||||
name: 'news',
|
component: LoginView
|
||||||
component: NewsView
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user