From cccc6bb9ef3c7f0313b204fdd4d7da944804dfce Mon Sep 17 00:00:00 2001 From: skybird23333 <2603003199a@gmail.com> Date: Thu, 1 Dec 2022 21:40:01 +0800 Subject: [PATCH] Fix app/console: log auto scrolling when user isn't at the bottom --- app/components/Console/ConsoleComponent.vue | 18 +++++++----------- app/views/ProcessView.vue | 1 - 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/app/components/Console/ConsoleComponent.vue b/app/components/Console/ConsoleComponent.vue index c56fcb3..a8daa1b 100644 --- a/app/components/Console/ConsoleComponent.vue +++ b/app/components/Console/ConsoleComponent.vue @@ -24,27 +24,23 @@ export default { }, methods: { append(line, type) { + console.log(this.$refs.logview.scrollTop + 200, 'scrolltop') + console.log(this.$refs.logview.scrollHeight, 'scrollheight') + const isUserScrolledUp = !(this.$refs.logview.scrollTop + 200 == this.$refs.logview.scrollHeight) this.lines.push({ text: line, type: type }); this.$nextTick(() => { - this.$refs.logview.scrollTop = this.$refs.logview.scrollHeight; + if (!isUserScrolledUp) { + this.$refs.logview.scrollTop = this.$refs.logview.scrollHeight; + } }); }, async handleSend(evt) { if (evt.keyCode !== 13) return if (this.input === "") return; this.$client.sendToProcessStdin(this.name, this.input); - this.pushLog({ - type: "stdin", - text: this.input, - }); + this.append(this.input, "stdin"); this.input = ""; }, - pushLog(log) { - this.lines.push(log); - this.$nextTick(() => { - this.$refs.logview.scrollTop = this.$refs.logview.scrollHeight; - }); - } } } diff --git a/app/views/ProcessView.vue b/app/views/ProcessView.vue index 95f7ef1..2740ac9 100644 --- a/app/views/ProcessView.vue +++ b/app/views/ProcessView.vue @@ -58,7 +58,6 @@ export default { this.$refs.console.append(`
event${data.type}
`, data.type) break; } - console.log(data.type) } catch (e) { console.log(e) }