From 2c1bc98833e2427aab810e23248a9476e85bc030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=B9=B8?= <2567198082@qq.com> Date: Thu, 21 Jul 2022 23:13:33 +0800 Subject: [PATCH] Bug422-XuXing (#46) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 增加了返回上一篇的按钮及相关功能的实现,当点击下一篇文章跳转至下一篇时,页面中会增加一个返回上一篇按钮,点击返回上一篇按钮后可以回到上一篇。 Co-authored-by: Lan Hui <1348141770@qq.com> Reviewed-on: http://121.4.94.30:3000/mrlan/EnglishPal/pulls/46 Co-authored-by: 徐幸 <2567198082@qq.com> Co-committed-by: 徐幸 <2567198082@qq.com> --- app/templates/userpage_get.html | 8 +++++++- app/user_service.py | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 8b11365..be503e6 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -28,7 +28,13 @@

{{ flashed_messages|safe }} -

下一篇 Next Article

+ 下一篇 Next Article + {% if session.get('articleID') != session.get('old_articleID') %} + {% if session.get('old_articleID') != None %} + 上一篇 Previous Article + {% endif%} + {% endif %} +

阅读文章并回答问题

{{ today_article|safe }}
diff --git a/app/user_service.py b/app/user_service.py index c8ac8a1..5148a60 100644 --- a/app/user_service.py +++ b/app/user_service.py @@ -29,12 +29,25 @@ def user_reset(username): :param username: 用户名 :return: 返回页面内容 ''' + session['old_articleID'] = session.get('articleID') if request.method == 'GET': session['articleID'] = None return redirect(url_for('user_bp.userpage', username=username)) else: return 'Under construction' +@userService.route("//back", methods=['GET']) +def user_back(username): + ''' + 用户界面 + :param username: 用户名 + :return: 返回页面内容 + ''' + if request.method == 'GET': + session['articleID'] = session.get('old_articleID') + return redirect(url_for('user_bp.userpage', username=username)) + + @userService.route("///unfamiliar", methods=['GET', 'POST']) def unfamiliar(username, word):