From 4dbbb423e7fb4fd1edb3b0b30d57885e0a5d4246 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sat, 10 Feb 2024 12:05:34 +0800 Subject: [PATCH] :sparkles: Changeable permalink --- pkg/server/posts_api.go | 4 ++-- pkg/view/src/components/PostItem.tsx | 2 +- pkg/view/src/components/PostPublish.tsx | 25 ++++++++++++++++++++++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/pkg/server/posts_api.go b/pkg/server/posts_api.go index 6b43744..5759d2d 100644 --- a/pkg/server/posts_api.go +++ b/pkg/server/posts_api.go @@ -13,12 +13,12 @@ import ( ) func getPost(c *fiber.Ctx) error { - id, _ := c.ParamsInt("postId", 0) + id := c.Params("postId") take := c.QueryInt("take", 0) offset := c.QueryInt("offset", 0) tx := database.C.Where(&models.Post{ - BaseModel: models.BaseModel{ID: uint(id)}, + Alias: id, }) post, err := services.GetPost(tx) diff --git a/pkg/view/src/components/PostItem.tsx b/pkg/view/src/components/PostItem.tsx index ea6a7c3..c49fd9f 100644 --- a/pkg/view/src/components/PostItem.tsx +++ b/pkg/view/src/components/PostItem.tsx @@ -69,7 +69,7 @@ export default function PostItem(props: {

{props.post.title}

- + {content} diff --git a/pkg/view/src/components/PostPublish.tsx b/pkg/view/src/components/PostPublish.tsx index a28358d..8ee090c 100644 --- a/pkg/view/src/components/PostPublish.tsx +++ b/pkg/view/src/components/PostPublish.tsx @@ -261,6 +261,9 @@ export default function PostPublish(props: {
+ @@ -281,6 +284,26 @@ export default function PostPublish(props: {
+ + + +
-