From f5b5b0d59f356cef6aea57c9f2bb4cce5ed0c195 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=B0=8F=E5=8F=B6?= <1936472877@qq.com>
Date: Thu, 14 Nov 2024 11:21:33 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=9E=E6=97=B6=E6=97=A5=E5=BF=97?=
=?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9A=82=E5=81=9C=E4=BB=A5=E5=8F=8A=E6=B8=85?=
=?UTF-8?q?=E7=A9=BA?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/system/realtimeLog/index.vue | 73 ++++++++++++++++++--------
1 file changed, 52 insertions(+), 21 deletions(-)
diff --git a/src/views/system/realtimeLog/index.vue b/src/views/system/realtimeLog/index.vue
index f6d874dc..57bad2eb 100644
--- a/src/views/system/realtimeLog/index.vue
+++ b/src/views/system/realtimeLog/index.vue
@@ -22,6 +22,13 @@
/>
+
+ 清空
+
+ 暂停
+
+ 继续
+
{
const level = ref(2);
-const lineSpace = ref(15);
+const lineSpace = ref(10);
const handleLineSpace = (value: number) => (lineSpace.value = value);
@@ -92,6 +99,23 @@ const authPass = ref(false);
const socket = ref(null);
const flash = ref();
+const clear = () => {
+ terminalRef.value.clearLog();
+};
+
+const isStop = ref(false);
+const stopLog = ref([]);
+const stop = () => {
+ isStop.value = true;
+};
+
+const start = () => {
+ isStop.value = false;
+ while (stopLog.value.length) {
+ terminalRef.value.pushMessage(stopLog.value.shift());
+ }
+};
+
const objectToString = (obj: any) => {
if (Array.isArray(obj)) {
return "[ " + obj.map(objectToString).join(" ") + " ]";
@@ -148,30 +172,37 @@ const onExecCmd = (
.replace(/(?<=^|>)([^<]*?)(?=<|$)/g, (i: string) => {
return i.replace(/ /g, " ");
})}`;
- terminalRef.value.pushMessage({
+ const message = {
type: "html",
content: html
- });
+ };
+ if (isStop.value) {
+ stopLog.value.push(message);
+ } else {
+ terminalRef.value.pushMessage(message);
+ }
}
- } else if (data.type === "console") {
- const html = data.logs
- .map((i: any) => {
- if (typeof i === "string") {
- return convert.toHtml(i);
- } else {
- return objectToString(i);
- }
- })
- .join(" ")
- .replace(/\n|\r/g, "
")
- .replace(/(?<=^|>)([^<]*?)(?=<|$)/g, (i: string) => {
- return i.replace(/ /g, " ");
- });
- terminalRef.value.pushMessage({
- type: "html",
- content: html
- });
}
+ // TODO: console.log
+ // else if (data.type === "console") {
+ // const html = data.logs
+ // .map((i: any) => {
+ // if (typeof i === "string") {
+ // return convert.toHtml(i);
+ // } else {
+ // return objectToString(i);
+ // }
+ // })
+ // .join(" ")
+ // .replace(/\n|\r/g, "
")
+ // .replace(/(?<=^|>)([^<]*?)(?=<|$)/g, (i: string) => {
+ // return i.replace(/ /g, " ");
+ // });
+ // terminalRef.value.pushMessage({
+ // type: "html",
+ // content: html
+ // });
+ // }
} catch (error) {
terminalRef.value.pushMessage({
type: "table",