From ef3c7a422a0606fb477b97780ebbfe81696ed3df Mon Sep 17 00:00:00 2001 From: "DESKTOP-FUDKNA8\\znjsz" Date: Mon, 22 Jan 2024 15:32:04 +0800 Subject: [PATCH] update lunbo --- src/App.vue | 2 +- src/MainPage.vue | 45 ++++++++++++++++++++++++++++---------- src/components/NavMenu.vue | 40 +++++++++++++++++++-------------- src/components/Tools.vue | 26 +++++++++++++++------- src/pages/3D.vue | 5 ++--- src/store/settings.js | 2 +- 6 files changed, 79 insertions(+), 41 deletions(-) diff --git a/src/App.vue b/src/App.vue index 079b5b0..0698b4e 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,7 +34,7 @@ useWebsocket(store, urlPath.value); diff --git a/src/MainPage.vue b/src/MainPage.vue index 6b5d198..e7d44bf 100644 --- a/src/MainPage.vue +++ b/src/MainPage.vue @@ -9,8 +9,39 @@ import AlertListPage from "./pages/AlertListPage.vue"; import DataPage from "./pages/DataPage.vue"; import DatetimeTool from "./components/HeadTime.vue"; import TriplePage from "./pages/3D.vue"; +import { useSettings } from "./store/settings"; const props = defineProps(["path"]); + +const pages = ['3d', 'data', 'realtime', 'alert'] +const currentPage = ref("3d"); +const handlePageChange = (page) => { + currentPage.value = page; +}; + + +const { settings } = useSettings(); +const timer = ref(null); +watch(() => settings.carousel, val => { + if (val) { + timer.value = setInterval(() => { + handlePageChange(pages[(pages.indexOf(currentPage.value) + 1) % pages.length]) + }, settings.carouselTime); + return; + } + clearInterval(timer.value); + timer.value = null; +}) + +watch(() => settings.carouselTime, val => { + if (val > 0) { + if (timer.value) clearInterval(timer.value); + timer.value = setInterval(() => { + handlePageChange(pages[(pages.indexOf(currentPage.value) + 1) % pages.length]) + }, val); + } +}) + const pathMap = { '/1-1': 1, '/1-2': 2, @@ -25,11 +56,6 @@ const pathMap = { '/3-3': 11, '/3-4': 12 } - -const currentPage = ref("3d"); -const handlePageChange = (page) => { - currentPage.value = page; -};