feat(video): add video fit toggle button and update styling

- Add toggle button to switch between 'cover' and 'contain' video fit modes
- Update video background styling for simpler positioning
- Group upload and fit buttons in a flex container
This commit is contained in:
2025-07-16 14:21:15 +08:00
parent 6906829305
commit 27d9cea6d2
4 changed files with 30 additions and 10 deletions
+15
View File
@@ -7,6 +7,8 @@ document.addEventListener('DOMContentLoaded', function() {
const micButton = document.getElementById('mic-button');
const favorabilityBar = document.getElementById('favorability-bar');
const toggleFitButton = document.getElementById('toggle-fit-button');
// --- 视频上传功能 ---
videoUploadInput.addEventListener('change', function(event) {
const file = event.target.files[0];
@@ -27,6 +29,19 @@ document.addEventListener('DOMContentLoaded', function() {
}
});
// --- 视频适应模式切换功能 ---
let isFitHeight = false;
toggleFitButton.addEventListener('click', function() {
isFitHeight = !isFitHeight;
if (isFitHeight) {
bgVideo.style.objectFit = 'contain';
toggleFitButton.textContent = '适应宽度';
} else {
bgVideo.style.objectFit = 'cover';
toggleFitButton.textContent = '适应高度';
}
});
// --- 麦克风按钮交互和好感度条模拟 ---
let isListening = false;
let currentFavorability = 65; // 与 CSS 中的初始宽度保持一致