1408 lines
62 KiB
HTML
1408 lines
62 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>物理知识测验 - 万有引力定律</title>
|
||
<style>
|
||
* {
|
||
margin: 0;
|
||
padding: 0;
|
||
box-sizing: border-box;
|
||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||
}
|
||
|
||
body {
|
||
background-color: #f5f7fa;
|
||
color: #333;
|
||
line-height: 1.6;
|
||
padding: 20px;
|
||
}
|
||
|
||
.container {
|
||
max-width: 1000px;
|
||
margin: 0 auto;
|
||
background-color: white;
|
||
border-radius: 12px;
|
||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
|
||
padding: 30px;
|
||
}
|
||
|
||
header {
|
||
text-align: center;
|
||
margin-bottom: 30px;
|
||
padding-bottom: 20px;
|
||
border-bottom: 1px solid #eee;
|
||
}
|
||
|
||
h1 {
|
||
color: #2c3e50;
|
||
margin-bottom: 10px;
|
||
font-size: 28px;
|
||
}
|
||
|
||
.difficulty-indicator {
|
||
display: inline-block;
|
||
padding: 5px 15px;
|
||
border-radius: 20px;
|
||
font-weight: bold;
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
.difficulty-easy {
|
||
background-color: #e8f5e9;
|
||
color: #2e7d32;
|
||
}
|
||
|
||
.difficulty-medium {
|
||
background-color: #fff8e1;
|
||
color: #ff8f00;
|
||
}
|
||
|
||
.difficulty-hard {
|
||
background-color: #ffebee;
|
||
color: #c62828;
|
||
}
|
||
|
||
.quiz-info {
|
||
color: #666;
|
||
font-size: 16px;
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.question-section {
|
||
margin-bottom: 30px;
|
||
}
|
||
|
||
.question {
|
||
background-color: #f9f9f9;
|
||
border-radius: 8px;
|
||
padding: 20px;
|
||
margin-bottom: 20px;
|
||
transition: all 0.3s ease;
|
||
}
|
||
|
||
.question.hidden {
|
||
display: none;
|
||
}
|
||
|
||
.question:hover {
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
||
}
|
||
|
||
.question-header {
|
||
display: flex;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
.question-number {
|
||
font-weight: bold;
|
||
color: #2980b9;
|
||
font-size: 18px;
|
||
}
|
||
|
||
.question-points {
|
||
background-color: #e3f2fd;
|
||
color: #2980b9;
|
||
padding: 3px 10px;
|
||
border-radius: 12px;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.question-text {
|
||
margin-bottom: 15px;
|
||
font-size: 16px;
|
||
line-height: 1.7;
|
||
}
|
||
|
||
.options {
|
||
display: grid;
|
||
grid-template-columns: 1fr 1fr;
|
||
gap: 12px;
|
||
margin-bottom: 15px;
|
||
}
|
||
|
||
@media (max-width: 768px) {
|
||
.options {
|
||
grid-template-columns: 1fr;
|
||
}
|
||
}
|
||
|
||
.option {
|
||
background-color: white;
|
||
border: 1px solid #ddd;
|
||
border-radius: 6px;
|
||
padding: 12px 15px;
|
||
cursor: pointer;
|
||
transition: all 0.2s ease;
|
||
display: flex;
|
||
align-items: center;
|
||
}
|
||
|
||
.option:hover {
|
||
border-color: #2980b9;
|
||
background-color: #f0f7ff;
|
||
}
|
||
|
||
.option input {
|
||
margin-right: 10px;
|
||
}
|
||
|
||
.option label {
|
||
cursor: pointer;
|
||
flex: 1;
|
||
}
|
||
|
||
.question-explanation {
|
||
margin-top: 15px;
|
||
padding: 15px;
|
||
background-color: #e8f5e9;
|
||
border-left: 4px solid #4caf50;
|
||
border-radius: 4px;
|
||
display: none;
|
||
}
|
||
|
||
.navigation-section {
|
||
text-align: center;
|
||
margin: 20px 0;
|
||
padding: 20px;
|
||
background-color: #f5f5f5;
|
||
border-radius: 8px;
|
||
display: none;
|
||
}
|
||
|
||
#next-btn {
|
||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||
color: white;
|
||
border: none;
|
||
padding: 15px 40px;
|
||
border-radius: 30px;
|
||
cursor: pointer;
|
||
font-size: 18px;
|
||
font-weight: bold;
|
||
text-transform: uppercase;
|
||
letter-spacing: 1px;
|
||
transition: all 0.3s ease;
|
||
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
|
||
position: relative;
|
||
overflow: hidden;
|
||
}
|
||
|
||
#next-btn:before {
|
||
content: '';
|
||
position: absolute;
|
||
top: 0;
|
||
left: -100%;
|
||
width: 100%;
|
||
height: 100%;
|
||
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
||
transition: all 0.5s ease;
|
||
}
|
||
|
||
#next-btn:hover:before {
|
||
left: 100%;
|
||
}
|
||
|
||
#next-btn:hover {
|
||
transform: translateY(-3px);
|
||
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
|
||
}
|
||
|
||
#next-btn:active {
|
||
transform: translateY(-1px);
|
||
box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4);
|
||
}
|
||
|
||
.navigation-message {
|
||
font-size: 16px;
|
||
color: #333;
|
||
margin-bottom: 20px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.submit-section {
|
||
text-align: center;
|
||
margin-top: 40px;
|
||
}
|
||
|
||
#submit-btn {
|
||
background-color: #2980b9;
|
||
color: white;
|
||
border: none;
|
||
padding: 12px 30px;
|
||
border-radius: 6px;
|
||
cursor: pointer;
|
||
font-size: 16px;
|
||
transition: all 0.2s ease;
|
||
}
|
||
|
||
#submit-btn:hover {
|
||
background-color: #1e6fa5;
|
||
transform: translateY(-2px);
|
||
}
|
||
|
||
#result {
|
||
margin-top: 30px;
|
||
padding: 20px;
|
||
border-radius: 8px;
|
||
display: none;
|
||
}
|
||
|
||
.result-header {
|
||
font-size: 22px;
|
||
font-weight: bold;
|
||
margin-bottom: 15px;
|
||
color: #2c3e50;
|
||
}
|
||
|
||
.score {
|
||
font-size: 18px;
|
||
margin-bottom: 20px;
|
||
color: #333;
|
||
}
|
||
|
||
.correct-answers {
|
||
background-color: #e8f5e9;
|
||
color: #2e7d32;
|
||
padding: 10px 15px;
|
||
border-radius: 6px;
|
||
margin-bottom: 10px;
|
||
}
|
||
|
||
.incorrect-answers {
|
||
background-color: #ffebee;
|
||
color: #c62828;
|
||
padding: 10px 15px;
|
||
border-radius: 6px;
|
||
}
|
||
/* 学伴模型选择器样式 */
|
||
.model-selector {
|
||
position: fixed; top: 40px; left: 20px; z-index: 1000;
|
||
padding: 10px; background-color: rgba(255, 255, 255, 0.8);
|
||
border-radius: 5px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||
display: flex; flex-direction: column; gap: 15px;
|
||
}
|
||
select { padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; background-color: white; font-size: 14px; }
|
||
|
||
/* 录音控制样式 */
|
||
.recording-controls {
|
||
position: static; display: flex; flex-direction: column; gap: 10px; margin: 0;
|
||
}
|
||
.record-button {
|
||
width: 70px; height: 70px; border-radius: 50%;
|
||
background-color: #dc3545; border: none; color: white;
|
||
font-size: 16px; cursor: pointer; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||
display: flex; align-items: center; justify-content: center;
|
||
opacity: 1 !important; visibility: visible !important;
|
||
}
|
||
.record-button:hover { background-color: #c82333; }
|
||
.stop-button {
|
||
width: 70px; height: 70px; border-radius: 50%;
|
||
background-color: #6c757d; border: none; color: white;
|
||
font-size: 16px; cursor: pointer; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||
display: flex; align-items: center; justify-content: center; display: none;
|
||
opacity: 1 !important; visibility: visible !important;
|
||
}
|
||
|
||
/* 录音指示器样式 */
|
||
.recording-indicator {
|
||
position: fixed; bottom: 20px; left: 20px; z-index: 1000;
|
||
padding: 10px 15px; background-color: rgba(220, 53, 69, 0.9);
|
||
color: white; border-radius: 20px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||
display: none; align-items: center;
|
||
}
|
||
.recording-dot {
|
||
width: 10px; height: 10px; background-color: white;
|
||
border-radius: 50%; margin-right: 8px; animation: pulse 1.5s infinite;
|
||
}
|
||
|
||
/* 思考中动画样式 */
|
||
.thinking-indicator {
|
||
position: fixed; bottom: 20px; right: 120px; z-index: 1000;
|
||
padding: 10px 15px; background-color: rgba(0, 123, 255, 0.9);
|
||
color: white; border-radius: 20px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
||
display: none; align-items: center;
|
||
}
|
||
.thinking-dots { display: flex; gap: 4px; margin-right: 8px; }
|
||
.thinking-dot {
|
||
width: 8px; height: 8px; background-color: white; border-radius: 50%;
|
||
}
|
||
.thinking-dot:nth-child(1) { animation: pulse 1.5s infinite 0s; }
|
||
.thinking-dot:nth-child(2) { animation: pulse 1.5s infinite 0.3s; }
|
||
.thinking-dot:nth-child(3) { animation: pulse 1.5s infinite 0.6s; }
|
||
|
||
/* 结果显示容器样式 */
|
||
.result-container {
|
||
position: fixed; bottom: 80px; left: 20px; z-index: 1000;
|
||
padding: 15px; background-color: rgba(255, 255, 255, 0.95);
|
||
border-radius: 8px; box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
|
||
max-width: 400px; width: 90%;
|
||
display: none; flex-direction: column; gap: 10px;
|
||
}
|
||
.result-header {
|
||
font-weight: bold; color: #495057; margin-bottom: 5px;
|
||
display: flex; align-items: center; gap: 5px;
|
||
}
|
||
.result-header.asr { color: #007bff; }
|
||
.result-header.feedback { color: #28a745; }
|
||
.result-text {
|
||
color: #333; line-height: 1.5; max-height: 200px; overflow-y: auto;
|
||
padding-right: 5px; word-break: break-all;
|
||
}
|
||
|
||
/* 音频播放器样式 */
|
||
.audio-player-container {
|
||
margin-top: 10px; display: flex; align-items: center; gap: 10px;
|
||
}
|
||
.play-button {
|
||
background-color: #28a745; color: white; border: none;
|
||
border-radius: 50%; width: 40px; height: 40px;
|
||
cursor: pointer; display: flex; align-items: center; justify-content: center;
|
||
}
|
||
.play-button:hover { background-color: #218838; }
|
||
.audio-progress {
|
||
flex-grow: 1; height: 6px; background-color: #e9ecef; border-radius: 3px;
|
||
overflow: hidden; cursor: pointer;
|
||
}
|
||
.progress-bar {
|
||
height: 100%; background-color: #28a745; width: 0%;
|
||
}
|
||
.audio-time { font-size: 12px; color: #6c757d; }
|
||
|
||
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<header>
|
||
<h1>物理知识测验 - 万有引力定律</h1>
|
||
<div class="difficulty-indicator difficulty-medium">当前难度:中等</div>
|
||
<div class="quiz-info">
|
||
共15道题,分三个难度级别。完成当前难度后将根据您的表现推荐下一难度。
|
||
</div>
|
||
</header>
|
||
|
||
<div class="question-section">
|
||
<!-- 中等难度题目 (初始显示) -->
|
||
<div class="question" data-difficulty="medium" data-question="1">
|
||
<div class="question-header">
|
||
<div class="question-number">中等难度 - 问题 1</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
下列关于万有引力定律的说法中,正确的是:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="mq1" id="mq1-a" value="A">
|
||
<label for="mq1-a">A. 万有引力定律只适用于天体之间的相互作用</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq1" id="mq1-b" value="B">
|
||
<label for="mq1-b">B. 两个物体之间的万有引力大小与它们距离的平方成反比</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq1" id="mq1-c" value="C">
|
||
<label for="mq1-c">C. 万有引力的方向总是垂直于两个物体的连线方向</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq1" id="mq1-d" value="D">
|
||
<label for="mq1-d">D. 万有引力常量G是牛顿通过实验测量得出的</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:B</strong><br>
|
||
解析:万有引力定律适用于宇宙中任何两个有质量的物体之间的相互作用,不仅限于天体,故A错误;根据万有引力公式F=G(m₁m₂)/r²,两个物体之间的万有引力大小与它们距离的平方成反比,故B正确;万有引力的方向总是沿着两个物体的连线方向,故C错误;万有引力常量G是卡文迪许通过扭秤实验测量得出的,故D错误。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question" data-difficulty="medium" data-question="2">
|
||
<div class="question-header">
|
||
<div class="question-number">中等难度 - 问题 2</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
地球表面的重力加速度为g,若地球的质量不变,但半径变为原来的一半,则地球表面的重力加速度变为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="mq2" id="mq2-a" value="A">
|
||
<label for="mq2-a">A. g/4</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq2" id="mq2-b" value="B">
|
||
<label for="mq2-b">B. g/2</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq2" id="mq2-c" value="C">
|
||
<label for="mq2-c">C. 2g</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq2" id="mq2-d" value="D">
|
||
<label for="mq2-d">D. 4g</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:D</strong><br>
|
||
解析:根据重力加速度公式g=GM/R²,其中G为万有引力常量,M为地球质量,R为地球半径。当地球质量M不变,半径R变为原来的一半时,新的重力加速度g'=GM/(R/2)²=4GM/R²=4g,故答案为D。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question" data-difficulty="medium" data-question="3">
|
||
<div class="question-header">
|
||
<div class="question-number">中等难度 - 问题 3</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
人造地球卫星绕地球做匀速圆周运动,若轨道半径增大到原来的2倍,则卫星的线速度大小变为原来的:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="mq3" id="mq3-a" value="A">
|
||
<label for="mq3-a">A. 1/2</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq3" id="mq3-b" value="B">
|
||
<label for="mq3-b">B. 1/√2</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq3" id="mq3-c" value="C">
|
||
<label for="mq3-c">C. √2倍</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq3" id="mq3-d" value="D">
|
||
<label for="mq3-d">D. 2倍</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:B</strong><br>
|
||
解析:根据万有引力提供向心力的公式GMm/r²=mv²/r,可得 satellite line speed v=√(GM/r)。当轨道半径r增大到原来的2倍时,新的线速度v'=√(GM/(2r))=v/√2,故答案为B。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question" data-difficulty="medium" data-question="4">
|
||
<div class="question-header">
|
||
<div class="question-number">中等难度 - 问题 4</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
两个质量分别为m和M的物体相距为r,它们之间的万有引力大小为F。若将它们的距离变为2r,质量分别变为2m和3M,则它们之间的万有引力大小变为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="mq4" id="mq4-a" value="A">
|
||
<label for="mq4-a">A. 3F/2</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq4" id="mq4-b" value="B">
|
||
<label for="mq4-b">B. 3F/4</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq4" id="mq4-c" value="C">
|
||
<label for="mq4-c">C. F/2</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq4" id="mq4-d" value="D">
|
||
<label for="mq4-d">D. 2F/3</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:A</strong><br>
|
||
解析:根据万有引力公式F=G(mM)/r²,变化后的万有引力F'=G(2m·3M)/(2r)²=6GMm/4r²=3GMm/2r²=3F/2,故答案为A。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question" data-difficulty="medium" data-question="5">
|
||
<div class="question-header">
|
||
<div class="question-number">中等难度 - 问题 5</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
关于开普勒行星运动定律,下列说法正确的是:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="mq5" id="mq5-a" value="A">
|
||
<label for="mq5-a">A. 所有行星绕太阳运动的轨道都是正圆形</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq5" id="mq5-b" value="B">
|
||
<label for="mq5-b">B. 行星在近日点的速率小于在远日点的速率</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq5" id="mq5-c" value="C">
|
||
<label for="mq5-c">C. 所有行星的轨道半长轴的三次方与公转周期的二次方的比值都相等</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="mq5" id="mq5-d" value="D">
|
||
<label for="mq5-d">D. 开普勒定律仅适用于行星绕太阳的运动</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:C</strong><br>
|
||
解析:开普勒第一定律指出所有行星绕太阳运动的轨道都是椭圆,太阳处在椭圆的一个焦点上,故A错误;根据开普勒第二定律,行星与太阳的连线在相等时间内扫过相等的面积,因此行星在近日点的速率大于在远日点的速率,故B错误;开普勒第三定律表明所有行星的轨道半长轴的三次方与公转周期的二次方的比值都相等,故C正确;开普勒定律不仅适用于行星绕太阳的运动,也适用于卫星绕行星的运动,只是比值不同,故D错误。
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 简单难度题目 (初始隐藏) -->
|
||
<div class="question hidden" data-difficulty="easy" data-question="1">
|
||
<div class="question-header">
|
||
<div class="question-number">简单难度 - 问题 1</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
万有引力定律是由哪位科学家提出的?
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="eq1" id="eq1-a" value="A">
|
||
<label for="eq1-a">A. 爱因斯坦</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq1" id="eq1-b" value="B">
|
||
<label for="eq1-b">B. 牛顿</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq1" id="eq1-c" value="C">
|
||
<label for="eq1-c">C. 伽利略</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq1" id="eq1-d" value="D">
|
||
<label for="eq1-d">D. 开普勒</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:B</strong><br>
|
||
解析:万有引力定律是由英国科学家牛顿在1687年提出的,故答案为B。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="easy" data-question="2">
|
||
<div class="question-header">
|
||
<div class="question-number">简单难度 - 问题 2</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
地球对物体的吸引力称为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="eq2" id="eq2-a" value="A">
|
||
<label for="eq2-a">A. 重力</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq2" id="eq2-b" value="B">
|
||
<label for="eq2-b">B. 摩擦力</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq2" id="eq2-c" value="C">
|
||
<label for="eq2-c">C. 弹力</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq2" id="eq2-d" value="D">
|
||
<label for="eq2-d">D. 向心力</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:A</strong><br>
|
||
解析:地球对物体的吸引力称为重力,故答案为A。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="easy" data-question="3">
|
||
<div class="question-header">
|
||
<div class="question-number">简单难度 - 问题 3</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
下列哪个现象与万有引力无关?
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="eq3" id="eq3-a" value="A">
|
||
<label for="eq3-a">A. 苹果落地</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq3" id="eq3-b" value="B">
|
||
<label for="eq3-b">B. 月球绕地球运动</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq3" id="eq3-c" value="C">
|
||
<label for="eq3-c">C. 磁铁吸引铁钉</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq3" id="eq3-d" value="D">
|
||
<label for="eq3-d">D. 地球绕太阳公转</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:C</strong><br>
|
||
解析:磁铁吸引铁钉是磁力作用的结果,与万有引力无关,故答案为C。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="easy" data-question="4">
|
||
<div class="question-header">
|
||
<div class="question-number">简单难度 - 问题 4</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
物体的质量越大,它受到的重力就:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="eq4" id="eq4-a" value="A">
|
||
<label for="eq4-a">A. 越小</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq4" id="eq4-b" value="B">
|
||
<label for="eq4-b">B. 越大</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq4" id="eq4-c" value="C">
|
||
<label for="eq4-c">C. 不变</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq4" id="eq4-d" value="D">
|
||
<label for="eq4-d">D. 无法确定</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:B</strong><br>
|
||
解析:根据重力公式G=mg,物体受到的重力与质量成正比,质量越大,重力越大,故答案为B。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="easy" data-question="5">
|
||
<div class="question-header">
|
||
<div class="question-number">简单难度 - 问题 5</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
在地球表面,重力加速度g的近似值为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="eq5" id="eq5-a" value="A">
|
||
<label for="eq5-a">A. 9.8 m/s²</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq5" id="eq5-b" value="B">
|
||
<label for="eq5-b">B. 5.0 m/s²</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq5" id="eq5-c" value="C">
|
||
<label for="eq5-c">C. 15.6 m/s²</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="eq5" id="eq5-d" value="D">
|
||
<label for="eq5-d">D. 3.0 m/s²</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:A</strong><br>
|
||
解析:在地球表面,重力加速度g的近似值为9.8 m/s²,故答案为A。
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 高级难度题目 (初始隐藏) -->
|
||
<div class="question hidden" data-difficulty="hard" data-question="1">
|
||
<div class="question-header">
|
||
<div class="question-number">高级难度 - 问题 1</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
已知地球质量为M,半径为R,万有引力常量为G。一颗人造卫星在离地面高度为R的圆形轨道上运行,则该卫星的运行周期为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="hq1" id="hq1-a" value="A">
|
||
<label for="hq1-a">A. 2π√(2R³/GM)</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq1" id="hq1-b" value="B">
|
||
<label for="hq1-b">B. 4π√(2R³/GM)</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq1" id="hq1-c" value="C">
|
||
<label for="hq1-c">C. 2π√(8R³/GM)</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq1" id="hq1-d" value="D">
|
||
<label for="hq1-d">D. 4π√(R³/GM)</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:C</strong><br>
|
||
解析:卫星轨道半径r=R+h=2R,根据万有引力提供向心力:GMm/r²=m(2π/T)²r,解得T=2π√(r³/GM)=2π√((2R)³/GM)=2π√(8R³/GM),故答案为C。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="hard" data-question="2">
|
||
<div class="question-header">
|
||
<div class="question-number">高级难度 - 问题 2</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
两个质量分别为m1和m2的星球组成双星系统,它们绕两者连线上某一点做匀速圆周运动,两星球之间的距离为L。则它们的运行周期T为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="hq2" id="hq2-a" value="A">
|
||
<label for="hq2-a">A. 2π√(L³/G(m1+m2))</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq2" id="hq2-b" value="B">
|
||
<label for="hq2-b">B. 2π√(L³/2G(m1+m2))</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq2" id="hq2-c" value="C">
|
||
<label for="hq2-c">C. 2π√(L³/Gm1m2)</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq2" id="hq2-d" value="D">
|
||
<label for="hq2-d">D. 2π√(L³/G|m1-m2|)</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:A</strong><br>
|
||
解析:双星系统中,万有引力提供向心力,且两星球的角速度相等。设m1和m2到质心的距离分别为r1和r2,则r1+r2=L,m1ω²r1=m2ω²r2=Gm1m2/L²,解得ω=√(G(m1+m2)/L³),周期T=2π/ω=2π√(L³/G(m1+m2)),故答案为A。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="hard" data-question="3">
|
||
<div class="question-header">
|
||
<div class="question-number">高级难度 - 问题 3</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
一物体在地球表面的重量为G,若将该物体移至距离地心4R的位置(R为地球半径),则它的重量变为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="hq3" id="hq3-a" value="A">
|
||
<label for="hq3-a">A. G/4</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq3" id="hq3-b" value="B">
|
||
<label for="hq3-b">B. G/8</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq3" id="hq3-c" value="C">
|
||
<label for="hq3-c">C. G/16</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq3" id="hq3-d" value="D">
|
||
<label for="hq3-d">D. G/2</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:C</strong><br>
|
||
解析:重量即物体受到的重力,根据万有引力公式G=GMm/r²,当距离地心由R变为4R时,重力变为原来的1/16,故答案为C。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="hard" data-question="4">
|
||
<div class="question-header">
|
||
<div class="question-number">高级难度 - 问题 4</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
已知太阳质量为M,地球绕太阳做匀速圆周运动的轨道半径为r,万有引力常量为G。则地球绕太阳运动的动能为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="hq4" id="hq4-a" value="A">
|
||
<label for="hq4-a">A. GMm/2r</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq4" id="hq4-b" value="B">
|
||
<label for="hq4-b">B. GMm/r</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq4" id="hq4-c" value="C">
|
||
<label for="hq4-c">C. GMm/4r</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq4" id="hq4-d" value="D">
|
||
<label for="hq4-d">D. 2GMm/r</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:A</strong><br>
|
||
解析:地球绕太阳运动的向心力由万有引力提供:GMm/r²=mv²/r,动能Ek=1/2mv²=GMm/2r,故答案为A。
|
||
</div>
|
||
</div>
|
||
|
||
<div class="question hidden" data-difficulty="hard" data-question="5">
|
||
<div class="question-header">
|
||
<div class="question-number">高级难度 - 问题 5</div>
|
||
<div class="question-points">20分</div>
|
||
</div>
|
||
<div class="question-text">
|
||
某行星的质量是地球质量的4倍,半径是地球半径的2倍。一物体在地球表面的逃逸速度为v,则该物体在该行星表面的逃逸速度为:
|
||
</div>
|
||
<div class="options">
|
||
<div class="option">
|
||
<input type="radio" name="hq5" id="hq5-a" value="A">
|
||
<label for="hq5-a">A. v</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq5" id="hq5-b" value="B">
|
||
<label for="hq5-b">B. √2 v</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq5" id="hq5-c" value="C">
|
||
<label for="hq5-c">C. 2v</label>
|
||
</div>
|
||
<div class="option">
|
||
<input type="radio" name="hq5" id="hq5-d" value="D">
|
||
<label for="hq5-d">D. 4v</label>
|
||
</div>
|
||
</div>
|
||
<div class="question-explanation">
|
||
<strong>正确答案:B</strong><br>
|
||
解析:逃逸速度公式v=√(2GM/R),行星的M是地球的4倍,R是地球的2倍,则v'=√(2G·4M/2R)=√(4GM/R)=√2·√(2GM/R)=√2 v,故答案为B。
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="navigation-section" id="navigation">
|
||
<h3 id="navigation-message"></h3>
|
||
<button type="button" id="next-btn">开始答题</button>
|
||
</div>
|
||
|
||
<div class="submit-section">
|
||
<button type="button" id="submit-btn">提交答案</button>
|
||
<div id="result">
|
||
<div class="result-header">测验结果</div>
|
||
<div class="score">您的得分:<span id="score-value">0</span>/100分</div>
|
||
<div class="correct-answers">正确题数:<span id="correct-count">0</span>道</div>
|
||
<div class="incorrect-answers">错误题数:<span id="incorrect-count">0</span>道</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
// 存储各难度题目的正确答案
|
||
const correctAnswers = {
|
||
medium: {
|
||
mq1: 'B',
|
||
mq2: 'D',
|
||
mq3: 'B',
|
||
mq4: 'A',
|
||
mq5: 'C'
|
||
},
|
||
easy: {
|
||
eq1: 'B',
|
||
eq2: 'A',
|
||
eq3: 'C',
|
||
eq4: 'B',
|
||
eq5: 'A'
|
||
},
|
||
hard: {
|
||
hq1: 'C',
|
||
hq2: 'A',
|
||
hq3: 'C',
|
||
hq4: 'A',
|
||
hq5: 'B'
|
||
}
|
||
};
|
||
|
||
// 跟踪测验状态
|
||
const quizState = {
|
||
currentDifficulty: 'medium', // 初始难度
|
||
completedDifficulties: [],
|
||
scores: {}
|
||
};
|
||
|
||
// DOM元素
|
||
const submitBtn = document.getElementById('submit-btn');
|
||
const nextBtn = document.getElementById('next-btn');
|
||
const navigationSection = document.getElementById('navigation');
|
||
const navigationMessage = document.getElementById('navigation-message');
|
||
const result = document.getElementById('result');
|
||
const scoreValue = document.getElementById('score-value');
|
||
const correctCount = document.getElementById('correct-count');
|
||
const incorrectCount = document.getElementById('incorrect-count');
|
||
const difficultyIndicator = document.querySelector('.difficulty-indicator');
|
||
|
||
// 提交当前难度的答案
|
||
submitBtn.addEventListener('click', function() {
|
||
const currentAnswers = correctAnswers[quizState.currentDifficulty];
|
||
const totalQuestions = Object.keys(currentAnswers).length;
|
||
let score = 0;
|
||
let correct = 0;
|
||
let incorrect = 0;
|
||
|
||
// 检查所有问题的答案
|
||
for (const [questionName, correctAnswer] of Object.entries(currentAnswers)) {
|
||
const selectedOption = document.querySelector(`input[name="${questionName}"]:checked`);
|
||
const questionNumber = questionName.substring(2); // 从mq1提取1
|
||
const explanationElement = document.querySelector(`[data-difficulty="${quizState.currentDifficulty}"][data-question="${questionNumber}"] .question-explanation`);
|
||
|
||
// 显示解析
|
||
explanationElement.style.display = 'block';
|
||
|
||
if (selectedOption) {
|
||
const userAnswer = selectedOption.value;
|
||
|
||
// 标记正确或错误
|
||
if (userAnswer === correctAnswer) {
|
||
score += 20; // 每题20分
|
||
correct++;
|
||
selectedOption.closest('.option').style.backgroundColor = '#e8f5e9';
|
||
selectedOption.closest('.option').style.borderColor = '#4caf50';
|
||
} else {
|
||
incorrect++;
|
||
selectedOption.closest('.option').style.backgroundColor = '#ffebee';
|
||
selectedOption.closest('.option').style.borderColor = '#c62828';
|
||
// 标记正确答案
|
||
const correctOption = document.querySelector(`input[name="${questionName}"][value="${correctAnswer}"]`);
|
||
correctOption.closest('.option').style.backgroundColor = '#e8f5e9';
|
||
correctOption.closest('.option').style.borderColor = '#4caf50';
|
||
}
|
||
} else {
|
||
// 未答题
|
||
incorrect++;
|
||
const questionElement = document.querySelector(`[data-difficulty="${quizState.currentDifficulty}"][data-question="${questionNumber}"]`);
|
||
questionElement.style.border = '2px solid #ff9800';
|
||
}
|
||
}
|
||
|
||
// 保存当前难度得分
|
||
quizState.scores[quizState.currentDifficulty] = {
|
||
score: score,
|
||
correct: correct,
|
||
incorrect: incorrect
|
||
};
|
||
quizState.completedDifficulties.push(quizState.currentDifficulty);
|
||
|
||
// 显示当前难度结果
|
||
scoreValue.textContent = score;
|
||
correctCount.textContent = correct;
|
||
incorrectCount.textContent = incorrect;
|
||
result.style.display = 'block';
|
||
|
||
// 隐藏提交按钮
|
||
submitBtn.style.display = 'none';
|
||
|
||
// 根据当前难度和得分决定下一步
|
||
if (quizState.currentDifficulty === 'medium') {
|
||
if (correct < 3) {
|
||
// 中等难度答对少于3题,推荐简单难度
|
||
showNavigation('您在中等难度题目中表现不佳,建议先完成简单难度题目来巩固基础。', 'easy');
|
||
} else {
|
||
// 中等难度答对3题及以上,推荐高级难度
|
||
showNavigation('恭喜您完成中等难度题目!接下来挑战高级难度题目吧。', 'hard');
|
||
}
|
||
} else {
|
||
// 简单或高级难度完成后,显示最终结果
|
||
showFinalResult();
|
||
}
|
||
});
|
||
|
||
// 显示导航信息
|
||
function showNavigation(message, nextDifficulty) {
|
||
navigationMessage.textContent = message;
|
||
navigationSection.dataset.nextDifficulty = nextDifficulty;
|
||
navigationSection.style.display = 'block';
|
||
}
|
||
|
||
// 开始下一组题目
|
||
nextBtn.addEventListener('click', function() {
|
||
const nextDifficulty = navigationSection.dataset.nextDifficulty;
|
||
if (!nextDifficulty) return;
|
||
|
||
// 更新当前难度
|
||
quizState.currentDifficulty = nextDifficulty;
|
||
|
||
// 隐藏导航和结果
|
||
navigationSection.style.display = 'none';
|
||
result.style.display = 'none';
|
||
|
||
// 显示提交按钮
|
||
submitBtn.style.display = 'inline-block';
|
||
|
||
// 更新难度指示器
|
||
difficultyIndicator.textContent = `当前难度:${getDifficultyName(nextDifficulty)}`;
|
||
difficultyIndicator.className = `difficulty-indicator difficulty-${nextDifficulty}`;
|
||
|
||
// 隐藏所有题目
|
||
document.querySelectorAll('.question').forEach(question => {
|
||
question.classList.add('hidden');
|
||
});
|
||
|
||
// 显示下一组题目
|
||
document.querySelectorAll(`[data-difficulty="${nextDifficulty}"]`).forEach(question => {
|
||
question.classList.remove('hidden');
|
||
});
|
||
|
||
// 滚动到页面顶部
|
||
window.scrollTo(0, 0);
|
||
});
|
||
|
||
// 获取难度名称
|
||
function getDifficultyName(difficulty) {
|
||
const names = {
|
||
easy: '简单',
|
||
medium: '中等',
|
||
hard: '高级'
|
||
};
|
||
return names[difficulty] || difficulty;
|
||
}
|
||
|
||
// 显示最终结果
|
||
function showFinalResult() {
|
||
// 计算总分
|
||
let totalScore = 0;
|
||
let totalCorrect = 0;
|
||
let totalIncorrect = 0;
|
||
|
||
for (const difficulty of quizState.completedDifficulties) {
|
||
totalScore += quizState.scores[difficulty].score;
|
||
totalCorrect += quizState.scores[difficulty].correct;
|
||
totalIncorrect += quizState.scores[difficulty].incorrect;
|
||
}
|
||
|
||
// 更新结果显示
|
||
scoreValue.textContent = totalScore;
|
||
correctCount.textContent = totalCorrect;
|
||
incorrectCount.textContent = totalIncorrect;
|
||
result.style.display = 'block';
|
||
|
||
// 显示完成信息
|
||
navigationMessage.textContent = '恭喜您完成所有推荐题目!';
|
||
navigationSection.style.display = 'block';
|
||
document.getElementById('next-btn').style.display = 'none';
|
||
}
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|
||
|
||
<!-- 学伴功能区域 -->
|
||
<div class="model-selector">
|
||
<label for="model-select">选择学伴:</label>
|
||
<select id="model-select">
|
||
<option value="shizuku">小智</option>
|
||
<option value="koharu">小荷</option>
|
||
<option value="wanko">汪喵</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="recording-indicator" id="recordingIndicator">
|
||
<div class="recording-dot"></div>
|
||
<span>正在录音...</span>
|
||
</div>
|
||
|
||
<div class="thinking-indicator" id="thinkingIndicator">
|
||
<div class="thinking-dots">
|
||
<div class="thinking-dot"></div>
|
||
<div class="thinking-dot"></div>
|
||
<div class="thinking-dot"></div>
|
||
</div>
|
||
<span>学伴正在思考中...</span>
|
||
</div>
|
||
|
||
<div class="recording-controls" style="position: fixed; right:37px; bottom: 230px; z-index: 998;">
|
||
<button class="record-button" id="startRecordBtn" style="font-size: 14px;">帮我讲题</button>
|
||
<button class="stop-button" id="stopRecordBtn" style="font-size: 14px;">停止讲话</button>
|
||
</div>
|
||
|
||
<div class="result-container" id="resultContainer">
|
||
<div>
|
||
<div class="result-header asr">
|
||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M12 1H4C2.89 1 2 1.9 2 3V13C2 14.1 2.89 15 4 15H12C13.11 15 14 14.1 14 13V3C14 1.9 13.11 1 12 1ZM12 13H4V3H12V13Z" fill="#007bff"/>
|
||
<path d="M8 4C6.34 4 5 5.34 5 7C5 8.66 6.34 10 8 10C9.66 10 11 8.66 11 7C11 5.34 9.66 4 8 4ZM8 8.5C7.17 8.5 6.5 7.83 6.5 7C6.5 6.17 7.17 5.5 8 5.5C8.83 5.5 9.5 6.17 9.5 7C9.5 7.83 8.83 8.5 8 8.5Z" fill="#007bff"/>
|
||
<path d="M8 11C5.79 11 4 12.79 4 15V16H12V15C12 12.79 10.21 11 8 11ZM8 13C9.1 13 10 13.9 10 15H6C6 13.9 6.9 13 8 13Z" fill="#007bff"/>
|
||
</svg>
|
||
你讲的话
|
||
</div>
|
||
<div class="result-text" id="asrResultText"></div>
|
||
</div>
|
||
<div>
|
||
<div class="result-header feedback">
|
||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M1 4C1 2.9 1.9 2 3 2H13C14.1 2 15 2.9 15 4V11C15 12.1 14.1 13 13 13H9L5 16V13H3C1.9 13 1 12.1 1 11V4Z" fill="#28a745"/>
|
||
<path d="M8 8H6V5H8V8ZM11 8H9V5H11V8ZM11 11H6V9H11V11Z" fill="#28a745"/>
|
||
</svg>
|
||
学伴回复
|
||
</div>
|
||
<div class="result-text" id="feedbackResultText"></div>
|
||
</div>
|
||
<div class="audio-player-container">
|
||
<button class="play-button" id="playAudioBtn">
|
||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M8 5V19L19 12L8 5Z" fill="white"/>
|
||
</svg>
|
||
</button>
|
||
<div class="audio-progress" id="audioProgress">
|
||
<div class="progress-bar" id="progressBar"></div>
|
||
</div>
|
||
<div class="audio-time" id="audioTime">00:00 / 00:00</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div>
|
||
有权限问题的话,请点击<a href="https://dsideal.obs.cn-north-1.myhuaweicloud.com/HuangHai/11%E3%80%81%E5%AD%A6%E4%BC%B4Chrome%E5%BD%95%E9%9F%B3%E9%85%8D%E7%BD%AE%E4%BF%AE%E6%94%B9.pdf">这里</a>
|
||
</div>
|
||
<script src="https://l2dwidget.js.org/lib/L2Dwidget.min.js"></script>
|
||
<script>
|
||
// 录音相关变量
|
||
let mediaRecorder; let audioChunks = []; let isRecording = false;
|
||
// 音频播放相关变量
|
||
let audioElement = null; let isPlaying = false;
|
||
|
||
// 开始录音
|
||
function startRecording() {
|
||
if (isRecording) return;
|
||
|
||
console.log("尝试开始录音");
|
||
navigator.mediaDevices.getUserMedia({ audio: true })
|
||
.then(stream => {
|
||
mediaRecorder = new MediaRecorder(stream);
|
||
audioChunks = [];
|
||
|
||
mediaRecorder.ondataavailable = event => {
|
||
if (event.data.size > 0) audioChunks.push(event.data);
|
||
};
|
||
|
||
mediaRecorder.onstop = () => {
|
||
const audioBlob = new Blob(audioChunks, { type: 'audio/wav' });
|
||
console.log("录音完成,音频数据大小:", audioBlob.size);
|
||
uploadAudioToServer(audioBlob);
|
||
};
|
||
|
||
mediaRecorder.start();
|
||
isRecording = true;
|
||
document.getElementById('recordingIndicator').style.display = 'flex';
|
||
document.getElementById('startRecordBtn').style.display = 'none';
|
||
document.getElementById('stopRecordBtn').style.display = 'flex';
|
||
console.log("开始录音成功");
|
||
|
||
// 设置最长录音时间为60秒
|
||
setTimeout(stopRecording, 60000);
|
||
})
|
||
.catch(error => {
|
||
console.error("获取麦克风权限失败:", error);
|
||
alert("请授权麦克风权限以使用录音功能");
|
||
});
|
||
}
|
||
|
||
// 停止录音
|
||
function stopRecording() {
|
||
if (!isRecording || !mediaRecorder) return;
|
||
|
||
mediaRecorder.stop();
|
||
isRecording = false;
|
||
document.getElementById('recordingIndicator').style.display = 'none';
|
||
document.getElementById('startRecordBtn').style.display = 'flex';
|
||
document.getElementById('stopRecordBtn').style.display = 'none';
|
||
console.log("停止录音");
|
||
|
||
if (mediaRecorder.stream) {
|
||
mediaRecorder.stream.getTracks().forEach(track => track.stop());
|
||
}
|
||
}
|
||
|
||
// 上传音频到服务器
|
||
function uploadAudioToServer(audioBlob) {
|
||
console.log("开始上传音频到服务器");
|
||
document.getElementById('thinkingIndicator').style.display = 'flex';
|
||
|
||
const formData = new FormData();
|
||
formData.append('file', audioBlob, 'recording.wav');
|
||
|
||
fetch('/api/xueban/upload-audio', {
|
||
method: 'POST',
|
||
body: formData
|
||
})
|
||
.then(response => {
|
||
if (!response.ok) throw new Error('服务器响应错误');
|
||
return response.json();
|
||
})
|
||
.then(data => {
|
||
console.log("处理结果:", data);
|
||
document.getElementById('thinkingIndicator').style.display = 'none';
|
||
|
||
if (data.success) {
|
||
showResults(data.data);
|
||
} else {
|
||
alert('音频处理失败: ' + data.message);
|
||
}
|
||
})
|
||
.catch(error => {
|
||
console.error("上传音频失败:", error);
|
||
document.getElementById('thinkingIndicator').style.display = 'none';
|
||
alert('上传音频失败: ' + error.message);
|
||
});
|
||
}
|
||
|
||
// 显示ASR识别结果和反馈
|
||
function showResults(data) {
|
||
const resultContainer = document.getElementById('resultContainer');
|
||
resultContainer.style.display = 'flex';
|
||
document.getElementById('asrResultText').textContent = data.asr_text || '未识别到内容';
|
||
document.getElementById('feedbackResultText').textContent = data.feedback_text || '无反馈内容';
|
||
|
||
if (data.audio_url) {
|
||
if (audioElement) audioElement.pause();
|
||
audioElement = new Audio(data.audio_url);
|
||
audioElement.onloadedmetadata = function() {
|
||
updateAudioTimeDisplay();
|
||
try { audioElement.play(); isPlaying = true; updatePlayButton(); }
|
||
catch (e) { console.error("自动播放失败:", e); }
|
||
document.getElementById('playAudioBtn').style.display = 'flex';
|
||
};
|
||
audioElement.ontimeupdate = function() { updateAudioProgress(); updateAudioTimeDisplay(); };
|
||
audioElement.onended = function() { isPlaying = false; updatePlayButton(); };
|
||
document.getElementById('playAudioBtn').onclick = togglePlayAudio;
|
||
document.getElementById('audioProgress').onclick = function(e) {
|
||
if (!audioElement) return;
|
||
const rect = this.getBoundingClientRect();
|
||
const clickPosition = (e.clientX - rect.left) / rect.width;
|
||
audioElement.currentTime = clickPosition * audioElement.duration;
|
||
};
|
||
}
|
||
}
|
||
|
||
// 音频播放控制函数
|
||
function togglePlayAudio() { if (!audioElement) return; isPlaying ? audioElement.pause() : audioElement.play(); isPlaying = !isPlaying; updatePlayButton(); }
|
||
function updatePlayButton() {
|
||
const btn = document.getElementById('playAudioBtn');
|
||
btn.innerHTML = isPlaying ? `
|
||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M6 19H10V5H6V19ZM14 19H18V5H14V19Z" fill="white"/>
|
||
</svg>` : `
|
||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||
<path d="M8 5V19L19 12L8 5Z" fill="white"/>
|
||
</svg>`;
|
||
}
|
||
function updateAudioProgress() { if (audioElement) document.getElementById('progressBar').style.width = `${(audioElement.currentTime/audioElement.duration)*100}%`; }
|
||
function updateAudioTimeDisplay() {
|
||
if (!audioElement) return;
|
||
const format = s => `${Math.floor(s/60).toString().padStart(2,'0')}:${Math.floor(s%60).toString().padStart(2,'0')}`;
|
||
document.getElementById('audioTime').textContent = `${format(audioElement.currentTime)} / ${format(audioElement.duration)}`;
|
||
}
|
||
|
||
// 模型配置映射
|
||
const modelConfig = {
|
||
shizuku: {
|
||
jsonPath: "https://unpkg.com/live2d-widget-model-shizuku@1.0.5/assets/shizuku.model.json"
|
||
},
|
||
koharu: {
|
||
jsonPath: "https://unpkg.com/live2d-widget-model-koharu@1.0.5/assets/koharu.model.json"
|
||
},
|
||
wanko: {
|
||
jsonPath: "https://unpkg.com/live2d-widget-model-wanko@1.0.5/assets/wanko.model.json"
|
||
}
|
||
};
|
||
|
||
let currentL2DWidget = null;
|
||
let modelElement = null;
|
||
|
||
// 获取URL参数
|
||
function getUrlParam(name) {
|
||
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
||
const r = window.location.search.substr(1).match(reg);
|
||
return r ? unescape(r[2]) : null;
|
||
}
|
||
|
||
// 初始化看板娘
|
||
function initL2DWidget(modelName) {
|
||
// 如果没有传入modelName,则从URL参数获取模型名称,默认使用shizuku
|
||
if (!modelName) {
|
||
modelName = getUrlParam('model') || 'shizuku';
|
||
}
|
||
console.log("切换模型: ", modelName);
|
||
const config = modelConfig[modelName];
|
||
if (!config) {
|
||
console.error("模型配置不存在: ", modelName);
|
||
return;
|
||
}
|
||
console.log("模型JSON路径: ", config.jsonPath);
|
||
|
||
// 彻底清理现有实例
|
||
if (currentL2DWidget) {
|
||
try {
|
||
currentL2DWidget.destroy();
|
||
console.log("旧模型实例已销毁");
|
||
} catch (e) {
|
||
console.error("销毁实例失败: ", e);
|
||
}
|
||
// 修复:强制移除所有canvas元素
|
||
const oldCanvases = document.querySelectorAll('canvas#l2dcanvas');
|
||
oldCanvases.forEach(canvas => canvas.remove());
|
||
currentL2DWidget = null;
|
||
modelElement = null;
|
||
}
|
||
|
||
// 创建新实例
|
||
try {
|
||
currentL2DWidget = L2Dwidget.init({
|
||
model: {
|
||
jsonPath: config.jsonPath,
|
||
scale: 1
|
||
},
|
||
display: {
|
||
position: "right",
|
||
width: 150,
|
||
height: 300,
|
||
hOffset: 0,
|
||
vOffset: -20
|
||
},
|
||
mobile: {
|
||
show: true,
|
||
scale: 0.5
|
||
},
|
||
react: {
|
||
opacityDefault: 0.7,
|
||
opacityOnHover: 0.8
|
||
}
|
||
});
|
||
// 保存模型DOM元素引用
|
||
// 修复:使用setTimeout确保DOM更新完成后再获取元素
|
||
setTimeout(() => {
|
||
modelElement = document.querySelector('canvas#l2dcanvas');
|
||
if (modelElement) {
|
||
console.log("新模型DOM元素已获取");
|
||
} else {
|
||
console.warn("未找到新模型canvas元素");
|
||
}
|
||
console.log("新模型初始化成功");
|
||
}, 100);
|
||
} catch (e) {
|
||
console.error("模型初始化失败: ", e);
|
||
}
|
||
}
|
||
|
||
// 监听模型选择变化
|
||
const modelSelect = document.getElementById('model-select');
|
||
if (modelSelect) {
|
||
// 设置当前选中项
|
||
const currentModel = getUrlParam('model') || 'shizuku';
|
||
modelSelect.value = currentModel;
|
||
|
||
modelSelect.addEventListener('change', function() {
|
||
console.log("选择模型: ", this.value);
|
||
// 通过URL参数刷新页面实现模型切换
|
||
window.location.search = '?model=' + this.value;
|
||
});
|
||
console.log("模型选择监听器已绑定");
|
||
} else {
|
||
console.error("未找到模型选择器元素");
|
||
}
|
||
|
||
// 初始加载默认模型
|
||
document.addEventListener('DOMContentLoaded', function() {
|
||
initL2DWidget();
|
||
// 添加录音按钮事件绑定
|
||
document.getElementById('startRecordBtn').addEventListener('click', startRecording);
|
||
document.getElementById('stopRecordBtn').addEventListener('click', stopRecording);
|
||
});
|
||
</script> |