feat: main layout

This commit is contained in:
tim
2025-07-02 21:44:30 +08:00
parent 7519ec760c
commit bfc0f95c8f
6 changed files with 37 additions and 27 deletions

View File

@@ -1,9 +1,12 @@
<template> <template>
<div id="app"> <div id="app">
<HeaderComponent @toggle-menu="menuVisible = !menuVisible" /> <HeaderComponent @toggle-menu="menuVisible = !menuVisible" />
<MenuComponent :visible="menuVisible" />
<div class="content" :class="{ 'with-menu': menuVisible }"> <div class="main-container">
<router-view /> <MenuComponent :visible="menuVisible" />
<div class="content" :class="{ 'with-menu': menuVisible }">
<router-view />
</div>
</div> </div>
</div> </div>
</template> </template>
@@ -22,22 +25,18 @@ export default {
</script> </script>
<style> <style>
<<<<<<< HEAD
=======
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
color: #2c3e50;
}
.content { .content {
margin-left: 0;
transition: margin-left 0.3s ease; transition: margin-left 0.3s ease;
padding-top: 60px;
} }
.content.with-menu {
margin-left: 200px; .main-container {
display: flex;
justify-content: center;
flex-direction: row;
max-width: var(--page-max-width);
margin-left: auto;
margin-right: auto;
background-color: var(--normal-background-color);
} }
>>>>>>> 09bbafa1912b3a87115018c72230fd57e8d08aff
</style> </style>

View File

@@ -0,0 +1,13 @@
:root {
--header-height: 60px;
--header-background-color: gray;
--menu-background-color: darkgray;
--normal-background-color: lightgray;
--menu-width: 200px;
--page-max-width: 1200px;
}
body {
margin: 0;
padding: 0;
}

View File

@@ -16,9 +16,9 @@ export default {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
padding: 10px 20px; height: var(--header-height);
background-color: #42b983; background-color: var(--header-background-color);
color: white; color: var(--header-text-color);
} }
.menu-btn { .menu-btn {
font-size: 24px; font-size: 24px;

View File

@@ -23,13 +23,9 @@ export default {
<style scoped> <style scoped>
.menu { .menu {
width: 200px; width: 200px;
background-color: #f5f5f5; background-color: var(--menu-background-color);
padding: 10px;
position: fixed;
left: 0;
top: 0;
bottom: 0;
overflow-y: auto; overflow-y: auto;
height: calc(100vh - var(--header-height));
} }
.slide-enter-active, .slide-leave-active { .slide-enter-active, .slide-leave-active {
transition: transform 0.3s ease; transition: transform 0.3s ease;

View File

@@ -1,5 +1,6 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
import './assets/global.css'
createApp(App).use(router).mount('#app') createApp(App).use(router).mount('#app')

View File

@@ -13,6 +13,7 @@ export default {
<style scoped> <style scoped>
.home-page { .home-page {
padding: 20px; background-color: white;
color: black;
} }
</style> </style>