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 = () => {}