| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <template>
- <a-config-provider>
- <a-layout class="app-layout">
- <!-- 头部 -->
- <a-layout-header class="app-header">
- <div class="header-content">
- <a-row align="middle" justify="space-between">
- <a-col>
- <a-space align="center">
- <!-- <a-icon type="gateway" size="large" /> -->
- <div class="logo"></div>
- </a-space>
- </a-col>
- <a-col>
- <StatusIndicator />
- </a-col>
- </a-row>
- </div>
- </a-layout-header>
- <a-layout>
- <!-- 左侧菜单 -->
- <a-layout-sider
- class="app-sider"
- width="256"
- :collapsible="true"
- v-model:collapsed="collapsed"
- :trigger="null"
- breakpoint="lg"
- collapsed-width="80"
- >
- <div class="app-title">配线架配置系统</div>
- <a-menu
- mode="inline"
- :selected-keys="[selectedKey]"
- :collapsed="collapsed"
- @click="handleMenuClick"
- theme="dark"
- class="side-menu"
- >
- <a-menu-item key="/real-time-status" icon="<area-chart />">
- <router-link to="/real-time-status">实时状态</router-link>
- </a-menu-item>
- <a-menu-item key="/system-config" icon="<setting />">
- <router-link to="/system-config">系统配置</router-link>
- </a-menu-item>
- <a-menu-item key="/led-debug" icon="<bulb />">
- <router-link to="/led-debug">LED调试</router-link>
- </a-menu-item>
- <a-menu-item key="/network-config" icon="<wifi />">
- <router-link to="/network-config">网络配置</router-link>
- </a-menu-item>
- <a-menu-item key="/about" icon="<info-circle />">
- <router-link to="/about">关于</router-link>
- </a-menu-item>
- </a-menu>
- </a-layout-sider>
- <!-- 主要内容区域 -->
- <a-layout-content class="app-content">
- <div class="content-container">
- <router-view />
- </div>
- </a-layout-content>
- </a-layout>
- <!-- 页脚 -->
- <a-layout-footer class="app-footer">
- <p class="footer-text">© {{ new Date().getFullYear() }} 配线架配置系统 v1.0.0 | 实时数据通信平台</p>
- </a-layout-footer>
- </a-layout>
- </a-config-provider>
- </template>
- <script setup>
- import { ref, computed, onMounted, watch } from 'vue'
- import { useRoute } from 'vue-router'
- import StatusIndicator from './components/StatusIndicator.vue'
- import { useDataStore } from './stores/dataStore'
- import { initWebSocket } from './utils/websocket'
- // 初始化数据存储
- const dataStore = useDataStore()
- const route = useRoute()
- const collapsed = ref(false)
- // 计算当前选中的菜单项
- const selectedKey = computed(() => {
- return route.path
- })
- // 处理菜单点击
- const handleMenuClick = (e) => {
- console.log('菜单点击:', e.key)
- }
- // 监听路由变化
- watch(() => route.path, (newPath) => {
- console.log('路由变化:', newPath)
- })
- // 组件挂载时初始化WebSocket连接
- onMounted(() => {
- initWebSocket(dataStore)
- })
- </script>
- <style scoped>
- /* 应用布局 */
- .app-layout {
- min-height: 100vh;
- }
- /* 头部样式 */
- .app-header {
- background-color: #001529;
- padding: 0;
- height: 64px;
- line-height: 64px;
- position: fixed;
- width: 100%;
- z-index: 10;
- }
- .header-content {
- max-width: 100%;
- margin: 0 auto;
- padding: 0 24px;
- height: 100%;
- }
- .app-title {
- margin: 0;
- font-size: 20px;
- font-weight: 600;
- color: #fff;
- margin: 10px;
- font-size: 15px;
- margin-bottom: 0;;
- }
- /* 侧边栏样式 */
- .app-sider {
- background-color: #001529;
- position: fixed;
- left: 0;
- top: 64px;
- height: calc(100vh - 64px);
- z-index: 9;
- transition: all 0.3s;
- }
- .logo {
- height: 60px;
- width: 94px;
- position: absolute;
- top: 0px;
- background: url('/vite.svg') center no-repeat;
- background-size: contain;
- }
- .side-menu {
- height: calc(100% - 64px);
- padding: 20px 0;
- padding-top: 0px;
- }
- .side-menu .ant-menu-item {
- margin: 0;
- padding: 0 20px;
- height: 50px;
- line-height: 50px;
- }
- .side-menu .ant-menu-item:hover {
- background-color: rgba(255, 255, 255, 0.1);
- }
- .side-menu .ant-menu-item-selected {
- background-color: #1890ff;
- }
- /* 主要内容区域 */
- .app-content {
- padding: 24px;
- background-color: #f0f2f5;
- min-height: calc(100vh - 64px);
- margin-left: 256px;
- margin-top: 64px;
- transition: all 0.3s;
- }
- .app-sider.collapsed + .app-content {
- margin-left: 80px;
- }
- .content-container {
- max-width: 100%;
- margin: 0 auto;
- }
- /* 页脚样式 */
- .app-footer {
- text-align: center;
- background-color: #001529;
- color: rgba(255, 255, 255, 0.65);
- font-size: 14px;
- padding: 16px 0;
- margin-left: 256px;
- transition: all 0.3s;
- }
- .app-sider.collapsed + .app-content + .app-footer {
- margin-left: 80px;
- }
- .footer-text {
- margin: 0;
- }
- /* 响应式调整 */
- @media (max-width: 1024px) {
- .app-sider {
- transform: translateX(-100%);
- }
-
- .app-sider.collapsed {
- transform: translateX(0);
- }
-
- .app-content {
- margin-left: 0;
- }
-
- .app-footer {
- margin-left: 0;
- }
- }
- @media (max-width: 768px) {
- .app-content {
- padding: 16px;
- }
-
- .header-content {
- padding: 0 16px;
- }
-
- .app-title {
- font-size: 18px;
- }
- }
- /* 路由链接样式 */
- :deep(.ant-menu-item a) {
- color: rgba(255, 255, 255, 0.65);
- width: 100%;
- display: flex;
- align-items: center;
- }
- :deep(.ant-menu-item a:hover) {
- color: #fff;
- }
- :deep(.ant-menu-item-selected a) {
- color: #fff;
- }
- /* 修复侧边栏滚动问题 */
- :deep(.ant-layout-sider-children) {
- overflow-y: auto;
- height: 100%;
- }
- </style>
|