1
0
Fork 0

fix: using new pagination mod func

Alpha
吴宇涵 2023-03-25 21:31:32 +08:00
parent ce28a5bf65
commit f17995a35c
2 changed files with 2 additions and 2 deletions

View File

@ -49,7 +49,7 @@ def article():
max(1, int(request.args.get("size", 5))), _article_number max(1, int(request.args.get("size", 5))), _article_number
) # 最小的size是1 ) # 最小的size是1
_cur_page = min( _cur_page = min(
max(1, int(request.args.get("page", 1))), _article_number // _page_size + 1 max(1, int(request.args.get("page", 1))), _article_number // _page_size + (_article_number % _page_size > 0)
) # 最小的page是1 ) # 最小的page是1
except ValueError: except ValueError:
return "page parmas must be int!" return "page parmas must be int!"

View File

@ -83,7 +83,7 @@
<ul class="pagination pagination-sm justify-content-center"> <ul class="pagination pagination-sm justify-content-center">
<li class="page-item"><a class="page-link" href="/admin/article?page={{ cur_page - 1 }}&size={{ page_size }}">Previous</a> <li class="page-item"><a class="page-link" href="/admin/article?page={{ cur_page - 1 }}&size={{ page_size }}">Previous</a>
</li> </li>
{% for i in range(1, article_number // page_size + 2) %} {% for i in range(1, article_number // page_size + (article_number % page_size > 0) + 1) %}
{% if cur_page == i %} {% if cur_page == i %}
<li class="page-item active"><a class="page-link" href="/admin/article?page={{ i }}&size={{ page_size }}">{{ i }}</a> <li class="page-item active"><a class="page-link" href="/admin/article?page={{ i }}&size={{ page_size }}">{{ i }}</a>
</li> </li>