first commit

This commit is contained in:
闫旭隆
2025-10-17 09:31:28 +08:00
commit 4698145045
589 changed files with 196795 additions and 0 deletions

View File

@ -0,0 +1,71 @@
/**
* 动态监测聊天输入框高度变化
* 当输入框高度变化时如多行文本扩展自动更新CSS变量
*/
(function() {
'use strict';
document.addEventListener('DOMContentLoaded', function() {
// 获取聊天输入框容器
const chatInputContainer = document.getElementById('chatModeInput');
if (!chatInputContainer) {
console.log('Chat input container not found, will retry when chat mode is activated');
return;
}
// 创建 ResizeObserver 监测高度变化
const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) {
const height = entry.contentRect.height;
// 更新CSS变量
document.documentElement.style.setProperty('--chat-input-height', height + 'px');
// 调试信息
console.log('Chat input height updated:', height + 'px');
}
});
// 开始观察
resizeObserver.observe(chatInputContainer);
// 初始设置高度
const initialHeight = chatInputContainer.offsetHeight;
if (initialHeight > 0) {
document.documentElement.style.setProperty('--chat-input-height', initialHeight + 'px');
}
// 监听聊天模式切换
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
// 检查是否进入聊天模式
if (document.body.classList.contains('chat-mode')) {
// 重新计算高度
setTimeout(() => {
const chatInput = document.getElementById('chatModeInput');
if (chatInput) {
const height = chatInput.offsetHeight;
document.documentElement.style.setProperty('--chat-input-height', height + 'px');
}
}, 100);
}
}
});
});
// 观察body的class变化
observer.observe(document.body, { attributes: true });
});
// 处理窗口大小变化
window.addEventListener('resize', function() {
const chatInputContainer = document.getElementById('chatModeInput');
if (chatInputContainer && document.body.classList.contains('chat-mode')) {
const height = chatInputContainer.offsetHeight;
document.documentElement.style.setProperty('--chat-input-height', height + 'px');
}
});
})();