From b69140307bccaa486e8d6449528b99e55ad5aef8 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Thu, 31 Aug 2023 16:24:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AF=B9=E8=AF=9D=E6=A1=86?= =?UTF-8?q?=E5=AF=B9=E9=BD=90=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- themes/common.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/themes/common.js b/themes/common.js index a56672d..7733c7b 100644 --- a/themes/common.js +++ b/themes/common.js @@ -1,6 +1,6 @@ function ChatBotHeight() { function update_height(){ - var { panel_height_target, chatbot_height, chatbot } = get_elements(); + var { panel_height_target, chatbot_height, chatbot } = get_elements(true); if (panel_height_target!=chatbot_height) { var pixelString = panel_height_target.toString() + 'px'; @@ -28,21 +28,24 @@ function ChatBotHeight() { }, 50); // 每100毫秒执行一次 } -function get_elements() { +function get_elements(consider_state_panel=false) { var chatbot = document.querySelector('#gpt-chatbot > div.wrap.svelte-18telvq'); if (!chatbot) { chatbot = document.querySelector('#gpt-chatbot'); } - const panel1 = document.querySelector('#input-panel'); - const panel2 = document.querySelector('#basic-panel'); - const panel3 = document.querySelector('#plugin-panel'); - const panel4 = document.querySelector('#interact-panel'); - const panel5 = document.querySelector('#input-panel2'); - const panel_active = document.querySelector('#state-panel'); - // 25.3 是chatbot的label高度, 16 是右侧的gap - var panel_height_target = panel1.offsetHeight + panel2.offsetHeight + panel3.offsetHeight + panel4.offsetHeight + panel5.offsetHeight - 25.5 + 16*3; + const panel1 = document.querySelector('#input-panel').getBoundingClientRect(); + const panel2 = document.querySelector('#basic-panel').getBoundingClientRect() + const panel3 = document.querySelector('#plugin-panel').getBoundingClientRect(); + const panel4 = document.querySelector('#interact-panel').getBoundingClientRect(); + const panel5 = document.querySelector('#input-panel2').getBoundingClientRect(); + const panel_active = document.querySelector('#state-panel').getBoundingClientRect(); + if (consider_state_panel || panel_active.height < 25){ + document.state_panel_height = panel_active.height; + } + // 25 是chatbot的label高度, 16 是右侧的gap + var panel_height_target = panel1.height + panel2.height + panel3.height + panel4.height + panel5.height - 25 + 16*3; // 禁止动态的state-panel高度影响 - panel_height_target = panel_height_target + (21-panel_active.offsetHeight) + panel_height_target = panel_height_target + (document.state_panel_height-panel_active.height) var panel_height_target = parseInt(panel_height_target); var chatbot_height = chatbot.style.height; var chatbot_height = parseInt(chatbot_height);