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",