From 942d93417b79c2b0415dc66631d0373176d65bf8 Mon Sep 17 00:00:00 2001 From: li-xiaochen <397721316@qq.com> Date: Tue, 28 Jan 2025 16:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=9C=80=E5=A4=9A=E4=BF=9D?= =?UTF-8?q?=E7=95=99200=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/App.vue | 23 +++++++++++++++-------- ui/src/components/FloatButton.vue | 2 +- ui/src/components/LogComponent.vue | 2 +- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ui/src/App.vue b/ui/src/App.vue index cffa4df..eb2e815 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -34,15 +34,19 @@ async function initialize_config() { await init_version() } -const log = ref('') +const log = ref([]) provide('log', log) const log_ele = ref(null) provide('log_ele', log_ele) -watch(log, () => { - nextTick(() => { - log_ele.value?.scrollTo({ position: 'bottom' }) - }) -}) +watch( + log, + () => { + nextTick(() => { + log_ele.value?.scrollTo({ position: 'bottom' }) + }) + }, + { deep: true } +) onMounted(() => { if (window.pywebview && pywebview.api) { @@ -53,12 +57,15 @@ onMounted(() => { }) } window.addEventListener('log', (e) => { - log.value += e.detail.log + log.value.push(e.detail.log) + if (log.value.length > 200) { + log.value.shift() + } }) }) function set_page(value) { - log.value = '' + log.value.splice(0) } const running = ref(false) diff --git a/ui/src/components/FloatButton.vue b/ui/src/components/FloatButton.vue index 06f16c1..de0ff86 100644 --- a/ui/src/components/FloatButton.vue +++ b/ui/src/components/FloatButton.vue @@ -11,7 +11,7 @@ const current_state = inject('current_state') const notification = useNotification() async function start() { - log.value = '' + log.value = [] running.value = true for (const [i, step] of steps.value.entries()) { current_step.value = i + 1 diff --git a/ui/src/components/LogComponent.vue b/ui/src/components/LogComponent.vue index 47d1339..b16c676 100644 --- a/ui/src/components/LogComponent.vue +++ b/ui/src/components/LogComponent.vue @@ -51,7 +51,7 @@ hljs.registerLanguage('naive-log', () => ({