From b4a4bd6723c85af1158f66270c18bac8e4681a9a Mon Sep 17 00:00:00 2001 From: fanwenqi <3042633706@qq.com> Date: Thu, 11 Apr 2024 23:21:24 +0800 Subject: [PATCH] Fix Bug547 --- app/static/js/read.js | 17 +++++- app/templates/userpage_get.html | 91 ++++++++++++++++++++++++--------- 2 files changed, 82 insertions(+), 26 deletions(-) diff --git a/app/static/js/read.js b/app/static/js/read.js index 814f627..676ba64 100644 --- a/app/static/js/read.js +++ b/app/static/js/read.js @@ -3,13 +3,14 @@ var Reader = (function() { let current_position = 0; let original_position = 0; let to_speak = ""; + let current_rate = 1; // 添加这一行,设置默认速率为 1 function makeUtterance(str, rate) { let msg = new SpeechSynthesisUtterance(str); msg.rate = rate; msg.lang = "en-US"; msg.onboundary = ev => { - if (ev.name == "word") { + if (ev.name === "word") { current_position = ev.charIndex; } } @@ -24,12 +25,24 @@ var Reader = (function() { reader.speak(msg); } + function updateRate(rate) { + // 停止当前的朗读 + stopRead(); + + // 更新当前速率 + current_rate = rate; + + // 重新开始朗读 + read(to_speak, current_rate); + } + function stopRead() { reader.cancel(); } return { read: read, - stopRead: stopRead + stopRead: stopRead, + updateRate: updateRate // 添加这一行,将 updateRate 方法暴露出去 }; })(); diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 68997ef..4ab4001 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -5,6 +5,8 @@ + + {{ yml['header'] | safe }} {% if yml['css']['item'] %} @@ -21,17 +23,35 @@ EnglishPal Study Room for {{ username }} @@ -45,22 +65,28 @@ 重设密码

-{# {% for message in flashed_messages %}#} {# 根据user_service.userpage,取消了参数flashed_messages,因此注释了这段代码 #} -{# #} -{# {% endfor %}#} + {% for message in get_flashed_messages() %} + + {% endfor %} - - + +

阅读文章并回答问题

- +

Article added on: {{ today_article["date"] }}


-

-

{{ today_article["article_title"] }}


-

{{ today_article["article_body"] }}


-

{{ today_article['source'] }}


+

+

{{ today_article["article_title"] }}


+

{{ today_article["article_body"] }}


+
+

{{ today_article['source'] }}


+
+

{{ today_article['question'] }}