diff --git a/pkg/services/posts.go b/pkg/services/posts.go index 25177c1..aa6a6f3 100644 --- a/pkg/services/posts.go +++ b/pkg/services/posts.go @@ -75,9 +75,11 @@ func (v *PostTypeContext) SortCreatedAt(order string) *PostTypeContext { func (v *PostTypeContext) GetViaAlias(alias string) (models.Feed, error) { var item models.Feed table := viper.GetString("database.prefix") + v.TableName + userTable := viper.GetString("database.prefix") + "accounts" if err := v.Tx. Table(table). Select("*, ? as model_type", v.ColumnName). + Joins(fmt.Sprintf("INNER JOIN %s AS author ON author_id = author.id", userTable)). Where("alias = ?", alias). First(&item).Error; err != nil { return item, err @@ -99,9 +101,11 @@ func (v *PostTypeContext) GetViaAlias(alias string) (models.Feed, error) { func (v *PostTypeContext) Get(id uint, noComments ...bool) (models.Feed, error) { var item models.Feed table := viper.GetString("database.prefix") + v.TableName + userTable := viper.GetString("database.prefix") + "accounts" if err := v.Tx. Table(table). Select("*, ? as model_type", v.ColumnName). + Joins(fmt.Sprintf("INNER JOIN %s AS author ON author_id = author.id", userTable)). Where("id = ?", id).First(&item).Error; err != nil { return item, err } diff --git a/pkg/views/src/components/posts/ArticleContent.vue b/pkg/views/src/components/posts/ArticleContent.vue index 7bfd373..65cd7ff 100644 --- a/pkg/views/src/components/posts/ArticleContent.vue +++ b/pkg/views/src/components/posts/ArticleContent.vue @@ -5,14 +5,16 @@
{{ props.item?.description }}
-
- + - Read more... - + Read more +
@@ -22,12 +24,12 @@ \ No newline at end of file + diff --git a/pkg/views/src/components/posts/CommentContent.vue b/pkg/views/src/components/posts/CommentContent.vue index 4f81e3b..c3714c4 100644 --- a/pkg/views/src/components/posts/CommentContent.vue +++ b/pkg/views/src/components/posts/CommentContent.vue @@ -1,5 +1,5 @@ diff --git a/pkg/views/src/components/posts/PostItem.vue b/pkg/views/src/components/posts/PostItem.vue index 4cd657d..2758db8 100644 --- a/pkg/views/src/components/posts/PostItem.vue +++ b/pkg/views/src/components/posts/PostItem.vue @@ -33,7 +33,7 @@ @update="updateReactions" /> -
+
Posted at {{ new Date(props.item?.created_at).toLocaleString() }}
diff --git a/pkg/views/src/components/publish/MomentEditor.vue b/pkg/views/src/components/publish/MomentEditor.vue index 89e2414..85ba905 100644 --- a/pkg/views/src/components/publish/MomentEditor.vue +++ b/pkg/views/src/components/publish/MomentEditor.vue @@ -70,6 +70,7 @@ import { request } from "@/scripts/request" import { useEditor } from "@/stores/editor" import { getAtk } from "@/stores/userinfo" import { reactive, ref, watch } from "vue" +import { useRouter } from "vue-router" import PlannedPublish from "@/components/publish/parts/PlannedPublish.vue" import Media from "@/components/publish/parts/Media.vue" @@ -91,6 +92,8 @@ const success = ref(false) const loading = ref(false) const uploading = ref(false) +const router = useRouter() + async function postMoment(evt: SubmitEvent) { const form = evt.target as HTMLFormElement const payload = data.value @@ -108,8 +111,10 @@ async function postMoment(evt: SubmitEvent) { }) if (res.status === 200) { form.reset() + const data = await res.json() success.value = true editor.show.moment = false + router.push({ name: "posts.details.moments", params: { alias: data.alias } }) } else { error.value = await res.text() } diff --git a/pkg/views/src/router/index.ts b/pkg/views/src/router/index.ts index 4d403da..8c62b00 100644 --- a/pkg/views/src/router/index.ts +++ b/pkg/views/src/router/index.ts @@ -14,6 +14,12 @@ const router = createRouter({ component: () => import("@/views/explore.vue") }, + + { + path: "/p/moments/:alias", + name: "posts.details.moments", + component: () => import("@/views/posts/moments.vue") + }, { path: "/p/articles/:alias", name: "posts.details.articles", diff --git a/pkg/views/src/views/posts/articles.vue b/pkg/views/src/views/posts/articles.vue index d05f308..c16ce00 100644 --- a/pkg/views/src/views/posts/articles.vue +++ b/pkg/views/src/views/posts/articles.vue @@ -4,12 +4,24 @@
-

{{ post?.title }}

-

{{ post?.description }}

+
+

{{ post?.title }}

+

{{ post?.description }}

+
+ + + +
+ Written by {{ post?.author?.nick }} + ยท + Published at {{ new Date(post?.created_at).toLocaleString() }} +
- +
+ +
diff --git a/pkg/views/src/views/posts/moments.vue b/pkg/views/src/views/posts/moments.vue new file mode 100644 index 0000000..baf37a1 --- /dev/null +++ b/pkg/views/src/views/posts/moments.vue @@ -0,0 +1,108 @@ + + + + +