2025-03-31 18:24:37 +08:00
|
|
|
<template>
|
|
|
|
<div class="app-wrapper">
|
|
|
|
<v-sidebar />
|
|
|
|
<v-header />
|
|
|
|
<div class="main-container">
|
|
|
|
<div class="app-main" :class="{ 'content-collapse': sidebar.collapse }">
|
2025-04-01 13:52:57 +08:00
|
|
|
<router-view v-slot="{ Component }">
|
|
|
|
<transition name="move" mode="out-in">
|
2025-04-10 19:00:17 +08:00
|
|
|
<keep-alive :include="[]">
|
2025-04-01 13:52:57 +08:00
|
|
|
<component :is="Component"></component>
|
|
|
|
</keep-alive>
|
|
|
|
</transition>
|
|
|
|
</router-view>
|
2025-03-31 18:24:37 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2025-04-11 18:46:52 +08:00
|
|
|
|
|
|
|
<!-- <Alarm ref="alarmRef" v-if="visible" @close="close" /> -->
|
2025-03-31 18:24:37 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
|
|
import { useSidebarStore } from "@/store/sidebar";
|
|
|
|
import vHeader from "@/components/header.vue";
|
|
|
|
import vSidebar from "@/components/sidebar.vue";
|
2025-04-11 18:46:52 +08:00
|
|
|
import Alarm from "@/components/alarm.vue";
|
|
|
|
import { ref } from "vue";
|
|
|
|
|
|
|
|
// import useWebSocket from "@/utils/webSocket";
|
|
|
|
// const { onMessage } = useWebSocket();
|
|
|
|
// onMessage((res) => {
|
|
|
|
// console.log(res, "WebSocket 接收服务器消息");
|
|
|
|
// if (res.cmd == "warning") {
|
|
|
|
// console.log("预警弹窗");
|
|
|
|
// }
|
|
|
|
// });
|
2025-03-31 18:24:37 +08:00
|
|
|
|
|
|
|
const sidebar = useSidebarStore();
|
2025-04-11 18:46:52 +08:00
|
|
|
const alarmRef = ref(null);
|
|
|
|
const audioPlayer = ref(null);
|
|
|
|
const visible = ref(true);
|
2025-04-10 19:00:17 +08:00
|
|
|
|
|
|
|
const getInclude = (routeList: any) => {
|
|
|
|
if (!routeList) return [];
|
|
|
|
let list = [];
|
|
|
|
routeList.forEach((item) => {
|
|
|
|
if (item.meta && item.meta.keepAlive) {
|
|
|
|
list.push(item.name);
|
|
|
|
}
|
|
|
|
if (item.children && item.children.length) {
|
|
|
|
list = [...list, ...getInclude(item.children)];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return list;
|
|
|
|
};
|
2025-04-11 18:46:52 +08:00
|
|
|
const close = async () => {
|
|
|
|
try {
|
|
|
|
audioPlayer.value.play();
|
|
|
|
console.log(1111);
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error, 2222);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
audioPlayer.value.play().catch((error) => {
|
|
|
|
console.error("自动播放被阻止:", error);
|
|
|
|
});
|
|
|
|
}, 5000);
|
|
|
|
const playAudio = () => {
|
|
|
|
if (audioPlayer.value) {
|
|
|
|
audioPlayer.value.play().catch((error) => {
|
|
|
|
console.error("自动播放被阻止:", error);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2025-04-10 19:00:17 +08:00
|
|
|
// const include = getInclude(routes[0].children);
|
2025-03-31 18:24:37 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="less">
|
2025-04-01 18:07:18 +08:00
|
|
|
// @media screen and (max-width: 800px) {
|
|
|
|
// .main-container {
|
|
|
|
// margin-left: 0 !important;
|
|
|
|
// }
|
|
|
|
// .sidebar-container {
|
|
|
|
// width: 0 !important;
|
|
|
|
// }
|
|
|
|
// .app-wrapper-header {
|
|
|
|
// width: 100% !important;
|
|
|
|
// }
|
|
|
|
// }
|
2025-03-31 18:24:37 +08:00
|
|
|
.app-wrapper {
|
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
|
|
|
height: 100vh;
|
|
|
|
background: #f0f2f5;
|
|
|
|
overflow: hidden;
|
|
|
|
.main-container {
|
|
|
|
height: 100vh;
|
|
|
|
margin-left: 210px;
|
|
|
|
min-height: 100%;
|
|
|
|
position: relative;
|
|
|
|
transition: 0.3s;
|
|
|
|
background-color: #f2f4fa;
|
|
|
|
}
|
|
|
|
.app-main {
|
2025-04-01 13:52:57 +08:00
|
|
|
// height: 100vh;
|
|
|
|
height: calc(100vh - 90px);
|
2025-03-31 18:24:37 +08:00
|
|
|
position: relative;
|
|
|
|
width: 100%;
|
2025-04-01 13:52:57 +08:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
// padding-top: 70px;
|
|
|
|
margin-top: 70px;
|
2025-03-31 18:24:37 +08:00
|
|
|
box-sizing: border-box;
|
|
|
|
overflow: hidden;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|