From da13e5bbd5da2a1ceb838c5a4836a0cabd8bdf69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E9=97=AE=E4=B8=89=E4=B8=8D=E7=9F=A5?= <178428409@qq.com> Date: Thu, 20 Apr 2023 21:28:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBug=EF=BC=88=E6=B2=A1?= =?UTF-8?q?=E6=89=BE=E5=88=B0=E6=96=87=E7=AB=A0=E5=90=8E=E7=AB=8B=E5=8D=B3?= =?UTF-8?q?=E4=B8=8A=E4=B8=80=E7=AF=87=E4=BC=9A=E5=9B=9E=E5=88=B0=E4=B8=8A?= =?UTF-8?q?=E4=B8=8A=E7=AF=87=E6=96=87=E7=AB=A0=EF=BC=89=20&=20=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E6=B7=BB=E5=8A=A0id=E6=96=B9=E4=BE=BF=E6=B5=8B?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/templates/userpage_get.html | 4 ++-- app/user_service.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index 8936ff7..6264ef0 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -44,9 +44,9 @@ {# #} {# {% endfor %}#} - 下一篇 Next Article + 下一篇 Next Article {% if session.get('had_read_articles') != None and session.get('had_read_articles')["index"] !=0 %} - 上一篇 Previous Article + 上一篇 Previous Article {% endif %}

阅读文章并回答问题

diff --git a/app/user_service.py b/app/user_service.py index b9f8d26..712fd13 100644 --- a/app/user_service.py +++ b/app/user_service.py @@ -45,9 +45,10 @@ def user_back(username): :return: 返回页面内容 ''' if request.method == 'GET': - had_read_articles = session.get("had_read_articles") - had_read_articles["index"] -= 1 - session["had_read_articles"] = had_read_articles + if session.get("found_article"): + had_read_articles = session.get("had_read_articles") + had_read_articles["index"] -= 1 + session["had_read_articles"] = had_read_articles return redirect(url_for('user_bp.userpage', username=username)) @@ -105,7 +106,6 @@ def userpage(username): :return: 返回用户界面 ''' # 未登录,跳转到未登录界面 - print("123123") if not session.get('logged_in'): return render_template('not_login.html') @@ -137,6 +137,10 @@ def userpage(username): words += x[0] + ' ' had_read_articles, today_article = get_today_article(user_freq_record, session.get('had_read_articles')) session['had_read_articles'] = had_read_articles + if today_article is None: + session["found_article"] = False + else: + session["found_article"] = True # 通过 today_article,加载前端的显示页面 return render_template('userpage_get.html', username=username,