From f1baedae66c2c75db4b9b39ed7cd9f225e57ef9e Mon Sep 17 00:00:00 2001 From: Trim21 Date: Wed, 21 Aug 2024 04:29:31 +0800 Subject: [PATCH] move /user/ router to /contrib/ --- server/__init__.py | 2 +- server/templates/component/header.html | 4 ++++ server/templates/error.html.jinja2 | 7 ++++--- server/templates/list.html.jinja2 | 9 ++++++--- server/templates/patch.html.jinja2 | 6 ++---- 5 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 server/templates/component/header.html diff --git a/server/__init__.py b/server/__init__.py index 951ecf4..25bd12f 100644 --- a/server/__init__.py +++ b/server/__init__.py @@ -96,7 +96,7 @@ async def index(request: Request) -> Template: ) -@litestar.get("/user/{user_id:int}", guards=[require_user_login]) +@litestar.get("/contrib/{user_id:int}", guards=[require_user_login]) async def show_user(user_id: int, request: Request) -> Template: rows = await pg.fetch( "select * from patch where from_user_id = $1 and deleted_at is NULL order by created_at desc", diff --git a/server/templates/component/header.html b/server/templates/component/header.html new file mode 100644 index 0000000..38579e1 --- /dev/null +++ b/server/templates/component/header.html @@ -0,0 +1,4 @@ +
+

返回首页

+
+
diff --git a/server/templates/error.html.jinja2 b/server/templates/error.html.jinja2 index 72bc2b3..bfacbef 100644 --- a/server/templates/error.html.jinja2 +++ b/server/templates/error.html.jinja2 @@ -1,7 +1,8 @@ {% extends "layout/base.html.jinja2" %} {% block content %} - {{ error }} -
- 返回首页 + {% include 'component/header.html' %} +
+ {{ error }} +
{% endblock %} diff --git a/server/templates/list.html.jinja2 b/server/templates/list.html.jinja2 index 4bfeaf5..b688637 100644 --- a/server/templates/list.html.jinja2 +++ b/server/templates/list.html.jinja2 @@ -9,13 +9,16 @@ } {% if user_id is defined %} + {% include 'component/header.html' %}
-

用户 {{ user_id }} 的个人主页

+ +

用户 {{ user_id }} 的个人主页

+
{% else %} {% if not auth.allow_edit %} -
- 添加Patch + {% endif %} {% endif %} diff --git a/server/templates/patch.html.jinja2 b/server/templates/patch.html.jinja2 index 4666bf0..2887e39 100644 --- a/server/templates/patch.html.jinja2 +++ b/server/templates/patch.html.jinja2 @@ -16,9 +16,7 @@ {% endblock %} {% block content %} - - -
+ {% include 'component/header.html' %}