Files
Web_BLS_ProjectConsole/src/frontend/App.vue

208 lines
3.5 KiB
Vue
Raw Normal View History

<template>
<div class="app-container">
<header class="app-header">
<button class="menu-toggle" @click="toggleSidebar" v-if="isMobile">
<span class="menu-icon"></span>
</button>
<h1>BLS Project Console</h1>
</header>
<div class="app-content">
<!-- 左侧选择区域 -->
<aside class="sidebar" :class="{ 'sidebar-closed': !sidebarOpen && isMobile }">
<router-view name="sidebar" />
</aside>
<!-- 右侧调试区域 -->
<main class="main-content">
<router-view name="main" />
</main>
</div>
</div>
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue';
const sidebarOpen = ref(true);
const isMobile = ref(false);
// 检测窗口大小变化
const checkMobile = () => {
isMobile.value = window.innerWidth < 768;
if (isMobile.value) {
sidebarOpen.value = false;
} else {
sidebarOpen.value = true;
}
};
// 切换侧边栏
const toggleSidebar = () => {
sidebarOpen.value = !sidebarOpen.value;
};
// 监听窗口大小变化
onMounted(() => {
checkMobile();
window.addEventListener('resize', checkMobile);
});
onUnmounted(() => {
window.removeEventListener('resize', checkMobile);
});
</script>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background-color: #121212;
color: #e0e0e0;
overflow: hidden;
}
.app-container {
min-height: 100vh;
display: flex;
flex-direction: column;
background-color: #1e1e1e;
}
.app-header {
background-color: #008C8C;
color: white;
padding: 0.6rem 1rem;
display: flex;
align-items: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
z-index: 100;
}
.menu-toggle {
background: none;
border: none;
color: white;
font-size: 1.2rem;
cursor: pointer;
margin-right: 1rem;
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
border-radius: 4px;
transition: background-color 0.2s;
}
.menu-toggle:hover {
background-color: rgba(255, 255, 255, 0.1);
}
.menu-icon {
display: block;
width: 20px;
height: 2px;
background-color: white;
position: relative;
transition: background-color 0.2s;
}
.menu-icon::before,
.menu-icon::after {
content: '';
position: absolute;
width: 20px;
height: 2px;
background-color: white;
transition: transform 0.2s, top 0.2s;
}
.menu-icon::before {
top: -6px;
}
.menu-icon::after {
top: 6px;
}
.app-header h1 {
font-size: 1.5rem;
font-weight: 600;
margin: 0;
}
.app-content {
flex: 1;
display: flex;
overflow: hidden;
}
/* 左侧选择区域 */
.sidebar {
width: 280px;
background-color: #252526;
border-right: 1px solid #3e3e42;
display: flex;
flex-direction: column;
transition: all 0.3s ease;
overflow-y: auto;
z-index: 50;
color: #e0e0e0;
}
/* 移动端侧边栏关闭状态 */
.sidebar-closed {
width: 0;
border-right: none;
overflow: hidden;
}
/* 右侧调试区域 */
.main-content {
flex: 1;
padding: 0;
overflow: hidden;
background-color: #1e1e1e;
}
/* 响应式设计 */
@media (max-width: 768px) {
.menu-toggle {
display: flex;
}
.sidebar {
position: fixed;
left: 0;
top: 60px;
height: calc(100vh - 60px);
width: 280px;
box-shadow: 2px 0 8px rgba(0, 0, 0, 0.15);
}
.sidebar-closed {
left: -280px;
width: 280px;
}
.main-content {
padding: 0.5rem;
overflow: auto;
}
}
@media (min-width: 769px) {
.menu-toggle {
display: none;
}
.sidebar {
width: 280px;
}
}
</style>