Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
•
dfcbb49
1
Parent(s):
0618646
feat: 使用js将移动端发送框固定在页面底部
Browse files细节:js获取了真实窗口高度然后计算并对chatbot高度重新赋值
- assets/custom.js +27 -1
assets/custom.js
CHANGED
@@ -134,6 +134,26 @@ function showOrHideUserInfo() {
|
|
134 |
}, 2000);
|
135 |
}
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
|
138 |
var observer = new MutationObserver(function (mutations) {
|
139 |
selectHistory(mutations);
|
@@ -144,7 +164,13 @@ observer.observe(targetNode, { childList: true, subtree: true });
|
|
144 |
|
145 |
|
146 |
window.addEventListener("DOMContentLoaded", function () {
|
|
|
147 |
setTimeout(function () {
|
148 |
showOrHideUserInfo();
|
|
|
149 |
}, 2000);
|
150 |
-
});
|
|
|
|
|
|
|
|
|
|
134 |
}, 2000);
|
135 |
}
|
136 |
|
137 |
+
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');
|
149 |
+
if (wrap) {
|
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 |
+
|
156 |
+
setChatbotHeight();
|
157 |
|
158 |
var observer = new MutationObserver(function (mutations) {
|
159 |
selectHistory(mutations);
|
|
|
164 |
|
165 |
|
166 |
window.addEventListener("DOMContentLoaded", function () {
|
167 |
+
setChatbotHeight();
|
168 |
setTimeout(function () {
|
169 |
showOrHideUserInfo();
|
170 |
+
setChatbotHeight();
|
171 |
}, 2000);
|
172 |
+
});
|
173 |
+
|
174 |
+
window.addEventListener('resize', setChatbotHeight);
|
175 |
+
window.addEventListener('scroll', setChatbotHeight);
|
176 |
+
|