- {% if today_article %}
+ {% if result_of_generate_article == 'found' %}
diff --git a/app/user_service.py b/app/user_service.py
index a306724..4f81c6e 100644
--- a/app/user_service.py
+++ b/app/user_service.py
@@ -31,7 +31,10 @@ def user_reset(username):
'''
if request.method == 'GET':
had_read_articles = session.get("had_read_articles")
- had_read_articles["index"] += 1
+ if had_read_articles['article_ids'][-1] == "null": # 如果当前还是“null”,则将“null”pop出来,无需index+=1
+ had_read_articles['article_ids'].pop()
+ else: # 当前不为“null”,直接 index+=1
+ had_read_articles["index"] += 1
session["had_read_articles"] = had_read_articles
return redirect(url_for('user_bp.userpage', username=username))
else:
@@ -45,10 +48,11 @@ def user_back(username):
:return: 返回页面内容
'''
if request.method == 'GET':
- 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
+ had_read_articles = session.get("had_read_articles")
+ had_read_articles["index"] -= 1 # 上一篇,index-=1
+ if had_read_articles['article_ids'][-1] == "null": # 如果当前还是“null”,则将“null”pop出来
+ had_read_articles['article_ids'].pop()
+ session["had_read_articles"] = had_read_articles
return redirect(url_for('user_bp.userpage', username=username))
@@ -137,10 +141,6 @@ def userpage(username):
words += x[0] + ' '
had_read_articles, today_article, result_of_generate_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,
From fc3e27488b3b55c1013a970e6abb95b88caff9aa 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: Fri, 21 Apr 2023 05:33:26 +0800
Subject: [PATCH 7/7] =?UTF-8?q?=E7=BB=99=E6=A0=87=E7=AD=BE=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0id=EF=BC=8C=E6=96=B9=E4=BE=BF=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/templates/userpage_get.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html
index 68948df..cb892db 100644
--- a/app/templates/userpage_get.html
+++ b/app/templates/userpage_get.html
@@ -37,7 +37,7 @@
English Pal for {{ username }}
- 退出
+ 退出
重设密码
{# {% for message in flashed_messages %}#} {# 根据user_service.userpage,取消了参数flashed_messages,因此注释了这段代码 #}