From a405c6460a071047a4a6e3749683c0165d613e7f Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Mon, 14 Aug 2023 17:59:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E6=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/LoginForm.vue | 6 ++++- src/components/Operator.vue | 20 ++++++++++++--- src/main.js | 12 ++++++++- src/mock/command.js | 33 ++++++++++++++++++++++++ src/pages/Home.vue | 52 ++++++++++++++++++++++++++++++++++++++ src/pages/Login.vue | 60 +++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 175 insertions(+), 8 deletions(-) diff --git a/src/components/LoginForm.vue b/src/components/LoginForm.vue index 684aa1a..c9f2daf 100644 --- a/src/components/LoginForm.vue +++ b/src/components/LoginForm.vue @@ -21,10 +21,13 @@ diff --git a/src/pages/Login.vue b/src/pages/Login.vue index cb98fed..2008828 100644 --- a/src/pages/Login.vue +++ b/src/pages/Login.vue @@ -3,15 +3,23 @@
-
+

关机

-
+

重新启动

+ +
+
+ +

{{ shutSecond }} 秒后关机...

+
+
+
@@ -19,11 +27,33 @@ import Restart from '@/assets/img/login/restart.png' import Shutdown from '@/assets/img/login/shutdown.png' import LoginForm from 'cpns/LoginForm.vue' - +import { shutdownJSON } from '@/mock/command' import { useWebSocketStore } from '@/store' +import { ref, onUnmounted } from 'vue' const webSocketStore = useWebSocketStore() webSocketStore.initCommandSocket() webSocketStore.initEventSocket() +const showShutdown = ref(false) +const shutSecond = ref(5) +const timer = ref(null) + +const shutdown = () => { + showShutdown.value = true + timer.value = setInterval(() => { + if (shutSecond.value > 0) { + shutSecond.value = shutSecond.value - 1 + } else { + timer.value = null + } + }, 1000) + webSocketStore?.sendCommandMsg(shutdownJSON) +} + +onUnmounted(() => { + timer.value = null +}) + +const reboot = () => {}