Keldos commited on
Commit
fa02110
·
1 Parent(s): 85471e1

feat: 输入框高度调整适配更多设备

Browse files

现在适配了最小横向分辨率为320px的设备(12 mini, iPad分屏)
还适配了iPad等的标签栏等

Files changed (2) hide show
  1. ChuanhuChatbot.py +1 -1
  2. assets/custom.js +20 -5
ChuanhuChatbot.py CHANGED
@@ -49,7 +49,7 @@ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
49
  with gr.Row():
50
  chatbot = gr.Chatbot(elem_id="chuanhu_chatbot").style(height="100%")
51
  with gr.Row():
52
- with gr.Column(min_width=280, scale=12):
53
  user_input = gr.Textbox(
54
  elem_id="user_input_tb",
55
  show_label=False, placeholder="在这里输入"
 
49
  with gr.Row():
50
  chatbot = gr.Chatbot(elem_id="chuanhu_chatbot").style(height="100%")
51
  with gr.Row():
52
+ with gr.Column(min_width=225, scale=12):
53
  user_input = gr.Textbox(
54
  elem_id="user_input_tb",
55
  show_label=False, placeholder="在这里输入"
assets/custom.js CHANGED
@@ -138,11 +138,18 @@ function setChatbotHeight() {
138
  const screenWidth = window.innerWidth;
139
  const statusDisplay = document.querySelector('#status_display');
140
  const statusDisplayHeight = statusDisplay ? statusDisplay.offsetHeight : 0;
141
- if (screenWidth <= 499) {
142
- const vh = window.innerHeight * 0.01;
143
- document.documentElement.style.setProperty('--vh', `${vh}px`);
144
-
145
- const chatbot = document.querySelector('#chuanhu_chatbot');
 
 
 
 
 
 
 
146
  if (chatbot) {
147
  chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 100}px)`;
148
  const wrap = chatbot.querySelector('.wrap');
@@ -150,6 +157,14 @@ function setChatbotHeight() {
150
  wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 100}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
151
  }
152
  }
 
 
 
 
 
 
 
 
153
  }
154
  }
155
 
 
138
  const screenWidth = window.innerWidth;
139
  const statusDisplay = document.querySelector('#status_display');
140
  const statusDisplayHeight = statusDisplay ? statusDisplay.offsetHeight : 0;
141
+ const chatbot = document.querySelector('#chuanhu_chatbot');
142
+ const vh = window.innerHeight * 0.01;
143
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
144
+ if (screenWidth <= 320) {
145
+ if (chatbot) {
146
+ chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 150}px)`;
147
+ const wrap = chatbot.querySelector('.wrap');
148
+ if (wrap) {
149
+ wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 150}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
150
+ }
151
+ }
152
+ } else if (screenWidth <= 499) {
153
  if (chatbot) {
154
  chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 100}px)`;
155
  const wrap = chatbot.querySelector('.wrap');
 
157
  wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 100}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
158
  }
159
  }
160
+ } else {
161
+ if (chatbot) {
162
+ chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 160}px)`;
163
+ const wrap = chatbot.querySelector('.wrap');
164
+ if (wrap) {
165
+ wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 160}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
166
+ }
167
+ }
168
  }
169
  }
170