toos-halloween/toos-dashboard/src/App.vue

45 lines
1.3 KiB
Vue
Raw Normal View History

2023-10-04 13:53:57 +02:00
<template>
2023-10-13 09:43:42 +02:00
<div class="w-full flex h-screen bg-neutral-950">
<Sidebar @updateCurrentPage="setCurrentPage" />
<div class="w-full">
2023-10-16 19:01:34 +02:00
<Status />
2023-10-13 09:43:42 +02:00
<Main v-if="currentPage === 0" />
<Conf v-if="currentPage === 1" />
<Test v-if="currentPage === 2" />
2023-10-04 13:53:57 +02:00
</div>
2023-10-16 19:01:34 +02:00
<audio id="audioContainer">
<source src="./assets/audio.mp3" type="audio/mp3">
</audio>
2023-10-04 13:53:57 +02:00
</div>
</template>
2023-10-13 09:43:42 +02:00
<script setup>
import Sidebar from "./components/Sidebar.vue";
import Test from "./components/Test.vue";
import Main from "./components/Main.vue";
import Conf from "./components/Conf.vue";
2023-10-16 19:01:34 +02:00
import Status from "./components/Status.vue";
2023-10-04 13:53:57 +02:00
2023-10-16 19:01:34 +02:00
import { ref, onMounted } from "vue";
import { listen } from '@tauri-apps/api/event';
import { invoke } from "@tauri-apps/api/tauri"
import { useLocalStorage } from '@vueuse/core'
const serialConfig = useLocalStorage('serialConfig', { port: '', baud: 9600, open: false })
2023-10-13 09:43:42 +02:00
const currentPage = ref(2);
const setCurrentPage = (x) => {
currentPage.value = x;
2023-10-04 13:53:57 +02:00
}
2023-10-16 19:01:34 +02:00
onMounted(async () => {
await invoke('close_port', { portName: serialConfig.value.port, baud: serialConfig.value.baud });
serialConfig.value.open = false;
await listen('port-state', (event) => {
serialConfig.value.open = event.payload.open
});
})
2023-10-13 09:43:42 +02:00
</script>