Keldos commited on
Commit
3f11a48
·
1 Parent(s): 8a9c9c1

refactor: 自动高度改用dvh

Browse files
web_assets/javascript/ChuanhuChat.js CHANGED
@@ -327,10 +327,10 @@ function setPopupBoxPosition() {
327
  // chuanhuPopup.style.top = `${(screenHeight - popupBoxHeight) / 2}px`;
328
  }
329
 
330
- function updateVH() {
331
- const vh = window.innerHeight * 0.01;
332
- document.documentElement.style.setProperty('--vh', `${vh}px`);
333
- }
334
 
335
  function setChatbotHeight() {
336
  return;
@@ -442,7 +442,7 @@ var gradioObserver = new MutationObserver(function (mutations) {
442
  // 监视页面变化
443
  window.addEventListener("DOMContentLoaded", function () {
444
  // const ga = document.getElementsByTagName("gradio-app");
445
- updateVH();
446
  windowWidth = window.innerWidth;
447
  gradioApp().addEventListener("render", initialize);
448
  isInIframe = (window.self !== window.top);
@@ -450,13 +450,13 @@ window.addEventListener("DOMContentLoaded", function () {
450
  });
451
  window.addEventListener('resize', ()=>{
452
  // setChatbotHeight();
453
- updateVH();
454
  windowWidth = window.innerWidth;
455
  setPopupBoxPosition();
456
  adjustSide();
457
  });
458
  window.addEventListener('orientationchange', (event) => {
459
- updateVH();
460
  windowWidth = window.innerWidth;
461
  setPopupBoxPosition();
462
  adjustSide();
 
327
  // chuanhuPopup.style.top = `${(screenHeight - popupBoxHeight) / 2}px`;
328
  }
329
 
330
+ // function updateVH() {
331
+ // const vh = window.innerHeight * 0.01;
332
+ // document.documentElement.style.setProperty('--vh', `${vh}px`);
333
+ // }
334
 
335
  function setChatbotHeight() {
336
  return;
 
442
  // 监视页面变化
443
  window.addEventListener("DOMContentLoaded", function () {
444
  // const ga = document.getElementsByTagName("gradio-app");
445
+ // updateVH();
446
  windowWidth = window.innerWidth;
447
  gradioApp().addEventListener("render", initialize);
448
  isInIframe = (window.self !== window.top);
 
450
  });
451
  window.addEventListener('resize', ()=>{
452
  // setChatbotHeight();
453
+ // updateVH();
454
  windowWidth = window.innerWidth;
455
  setPopupBoxPosition();
456
  adjustSide();
457
  });
458
  window.addEventListener('orientationchange', (event) => {
459
+ // updateVH();
460
  windowWidth = window.innerWidth;
461
  setPopupBoxPosition();
462
  adjustSide();
web_assets/stylesheet/ChuanhuChat.css CHANGED
@@ -232,6 +232,8 @@ body.popup-open {
232
 
233
 
234
  #popup-wrapper {
 
 
235
  display: none;
236
  position: fixed;
237
  overflow: auto;
@@ -300,10 +302,10 @@ body.popup-open {
300
  display: inline-flex;
301
  justify-content: space-between;
302
  /* margin-top: 54px; */
303
- /* height: calc(100*var(--vh) - 72px); */
304
  position: absolute;
305
  top: 65px;
306
- height: calc(100*var(--vh) - 65px);
307
  }
308
 
309
  #chuanhu-area {
@@ -644,7 +646,7 @@ input:checked + .chatbot-input-more-span {
644
  #menu-area.showSide {
645
  width: var(--menu-width);
646
  max-width: var(--menu-width);
647
- height: calc(100*var(--vh) - 65px);
648
  visibility: visible;
649
  /* margin-right: 16px; */
650
  border-right: 0.5px solid var(--border-color-primary);
@@ -656,7 +658,7 @@ input:checked + .chatbot-input-more-span {
656
  }
657
  #toolbox-area.showSide {
658
  width: var(--toolbox-width);
659
- height: calc(100*var(--vh) - 65px);
660
  visibility: visible;
661
  /* margin-left: 16px; */
662
  }
@@ -685,17 +687,17 @@ input:checked + .chatbot-input-more-span {
685
  /* right: calc(0px - var(--toolbox-width)); */
686
  z-index: 10008;
687
  overflow: unset;
688
- top: calc(100*var(--vh));
689
  margin: 0;
690
  }
691
  #toolbox-area > div {
692
  width: 100vw;
693
- height: calc( 90*var(--vh) - 48px );
694
  }
695
  #toolbox-area.showSide {
696
  width: 100vw;
697
  right: 0;
698
- top: calc( 10*var(--vh) + 48px );
699
  margin: 0;
700
  border-radius: 6px;
701
  box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2);
@@ -789,7 +791,7 @@ input:checked + .chatbot-input-more-span {
789
  }
790
  #chuanhu-popup {
791
  width: 100vw;
792
- height: calc( 90*var(--vh) - 48px );
793
  border-bottom-left-radius: 0;
794
  border-bottom-right-radius: 0;
795
  }
@@ -806,7 +808,7 @@ input:checked + .chatbot-input-more-span {
806
  }
807
  #toolbox-area > .gradio-group > div.styler > .gradio-tabs > div.tabitem,
808
  #chuanhu-popup .gradio-group > div.styler > .gradio-tabs > div.tabitem {
809
- height: calc( 90*var(--vh) - 48px - 46px - 45px );
810
  overflow-x: auto;
811
  border: none;
812
  }
@@ -990,8 +992,8 @@ input:checked + .chatbot-input-more-span {
990
  } */
991
 
992
  #chuanhu-history {
993
- max-height: calc(100*var(--vh) - 65px - 61px);
994
- max-height: calc(100*var(--vh) - 65px - calc(36px + 12px + max(12px, env(safe-area-inset-bottom)) + 1px ));
995
  /* overflow-y: auto; */
996
  }
997
  #chuanhu-history > div {
@@ -1250,14 +1252,14 @@ button:active .icon-need-hover, button:active.icon-need-hover {
1250
  overflow: hidden;
1251
  display: inline-flex;
1252
  /* margin-top: 54px; */
1253
- /* height: calc(100*var(--vh) - 72px); */
1254
  /* position: absolute;
1255
  top: 48px;
1256
  } */
1257
  /*
1258
  .hide-body {
1259
  display: none;
1260
- top: calc(-100*var(--vh));
1261
 
1262
  }
1263
  #train-body {
@@ -1266,7 +1268,7 @@ button:active .icon-need-hover, button:active.icon-need-hover {
1266
 
1267
  #chuanhu-body.hide-body {
1268
  display: none;
1269
- top: calc(100*var(--vh) + 48px);
1270
  }
1271
  #chuanhu-body {
1272
  transition: top 0.3s ease-in-out, display 0.3s ease;
 
232
 
233
 
234
  #popup-wrapper {
235
+ width: 100dvw;
236
+ height: 100dvh;
237
  display: none;
238
  position: fixed;
239
  overflow: auto;
 
302
  display: inline-flex;
303
  justify-content: space-between;
304
  /* margin-top: 54px; */
305
+ /* height: calc(100dvh - 72px); */
306
  position: absolute;
307
  top: 65px;
308
+ height: calc(100dvh - 65px);
309
  }
310
 
311
  #chuanhu-area {
 
646
  #menu-area.showSide {
647
  width: var(--menu-width);
648
  max-width: var(--menu-width);
649
+ height: calc(100dvh - 65px);
650
  visibility: visible;
651
  /* margin-right: 16px; */
652
  border-right: 0.5px solid var(--border-color-primary);
 
658
  }
659
  #toolbox-area.showSide {
660
  width: var(--toolbox-width);
661
+ height: calc(100dvh - 65px);
662
  visibility: visible;
663
  /* margin-left: 16px; */
664
  }
 
687
  /* right: calc(0px - var(--toolbox-width)); */
688
  z-index: 10008;
689
  overflow: unset;
690
+ top: 100dvh;
691
  margin: 0;
692
  }
693
  #toolbox-area > div {
694
  width: 100vw;
695
+ height: calc( 90dvh - 48px );
696
  }
697
  #toolbox-area.showSide {
698
  width: 100vw;
699
  right: 0;
700
+ top: calc( 10dvh + 48px );
701
  margin: 0;
702
  border-radius: 6px;
703
  box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2);
 
791
  }
792
  #chuanhu-popup {
793
  width: 100vw;
794
+ height: calc( 90dvh - 48px );
795
  border-bottom-left-radius: 0;
796
  border-bottom-right-radius: 0;
797
  }
 
808
  }
809
  #toolbox-area > .gradio-group > div.styler > .gradio-tabs > div.tabitem,
810
  #chuanhu-popup .gradio-group > div.styler > .gradio-tabs > div.tabitem {
811
+ height: calc( 90dvh - 48px - 46px - 45px );
812
  overflow-x: auto;
813
  border: none;
814
  }
 
992
  } */
993
 
994
  #chuanhu-history {
995
+ max-height: calc(100dvh - 65px - 61px);
996
+ max-height: calc(100dvh - 65px - calc(36px + 12px + max(12px, env(safe-area-inset-bottom)) + 1px ));
997
  /* overflow-y: auto; */
998
  }
999
  #chuanhu-history > div {
 
1252
  overflow: hidden;
1253
  display: inline-flex;
1254
  /* margin-top: 54px; */
1255
+ /* height: calc(100dvh - 72px); */
1256
  /* position: absolute;
1257
  top: 48px;
1258
  } */
1259
  /*
1260
  .hide-body {
1261
  display: none;
1262
+ top: calc(-100dvh);
1263
 
1264
  }
1265
  #train-body {
 
1268
 
1269
  #chuanhu-body.hide-body {
1270
  display: none;
1271
+ top: calc(100dvh + 48px);
1272
  }
1273
  #chuanhu-body {
1274
  transition: top 0.3s ease-in-out, display 0.3s ease;
web_assets/stylesheet/chatbot.css CHANGED
@@ -151,19 +151,19 @@ hr.append-display {
151
  /* update on 2023.4.8: 高度的细致调整已写入JavaScript */
152
  @media screen and (min-width: 500px) {
153
  /* #chuanhu-chatbot {
154
- height: calc(100*var(--vh) - 200px);
155
  }
156
  #chuanhu-chatbot>.wrapper>.wrap {
157
- max-height: calc(100*var(--vh) - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
158
  } */
159
  }
160
  /* 屏幕宽度小于500px的设备 */
161
  @media screen and (max-width: 499px) {
162
  /* #chuanhu-chatbot {
163
- height: calc(100*var(--vh) - 140px);
164
  }
165
  #chuanhu-chatbot>.wrapper>.wrap {
166
- max-height: calc(100*var(--vh) - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
167
  } */
168
  .message.bot {
169
  max-width: calc(100% - 84px) !important;
@@ -183,7 +183,7 @@ hr.append-display {
183
  }
184
 
185
  #chuanhu-chatbot {
186
- height: calc(100*var(--vh) - 65px) !important;
187
  border-radius: 0;
188
  }
189
  #chuanhu-chatbot > .wrapper > .bubble-wrap {
 
151
  /* update on 2023.4.8: 高度的细致调整已写入JavaScript */
152
  @media screen and (min-width: 500px) {
153
  /* #chuanhu-chatbot {
154
+ height: calc(100dvh - 200px);
155
  }
156
  #chuanhu-chatbot>.wrapper>.wrap {
157
+ max-height: calc(100dvh - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
158
  } */
159
  }
160
  /* 屏幕宽度小于500px的设备 */
161
  @media screen and (max-width: 499px) {
162
  /* #chuanhu-chatbot {
163
+ height: calc(100dvh - 140px);
164
  }
165
  #chuanhu-chatbot>.wrapper>.wrap {
166
+ max-height: calc(100dvh - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
167
  } */
168
  .message.bot {
169
  max-width: calc(100% - 84px) !important;
 
183
  }
184
 
185
  #chuanhu-chatbot {
186
+ height: calc(100dvh - 65px) !important;
187
  border-radius: 0;
188
  }
189
  #chuanhu-chatbot > .wrapper > .bubble-wrap {