🎨 Optimized structure

This commit is contained in:
LittleSheep 2024-03-09 17:47:39 +08:00
parent 1f69fcbfb4
commit 192d0c40bb
6 changed files with 13 additions and 10 deletions

View File

@ -24,7 +24,8 @@ const editor = useEditor()
const props = defineProps<{ const props = defineProps<{
comments: any[] comments: any[]
model: any model: string
dataset: string
alias: any alias: any
item: any item: any
}>() }>()
@ -38,7 +39,7 @@ const pagination = reactive({ page: 0, pageSize: 10, total: 0 })
async function readComments() { async function readComments() {
loading.value = true loading.value = true
const res = await request( const res = await request(
`/api/p/${props.model}/${props.alias}/comments?` + `/api/p/${props.dataset}/${props.alias}/comments?` +
new URLSearchParams({ new URLSearchParams({
take: pagination.pageSize.toString(), take: pagination.pageSize.toString(),
offset: (pagination.page * pagination.pageSize).toString() offset: (pagination.page * pagination.pageSize).toString()
@ -71,7 +72,7 @@ watch(editor, (val) => {
function leaveComment() { function leaveComment() {
editor.related.comment_to = props.item editor.related.comment_to = props.item
editor.related.comment_to.model_type += "s" editor.related.comment_to.model_type = props.dataset
editor.show.comment = true editor.show.comment = true
} }
</script> </script>

View File

@ -7,7 +7,7 @@
<div v-if="props.brief"> <div v-if="props.brief">
<router-link <router-link
:to="{ name: 'posts.details', params: { postType: 'articles', alias: props.item?.alias ?? 'not-found' } }" :to="{ name: 'posts.details.articles', params: { alias: props.item?.alias ?? 'not-found' } }"
append-icon="mdi-arrow-right" append-icon="mdi-arrow-right"
class="link underline text-primary font-medium" class="link underline text-primary font-medium"
> >

View File

@ -126,7 +126,7 @@ async function postArticle(evt: SubmitEvent) {
if (res.status === 200) { if (res.status === 200) {
const data = await res.json() const data = await res.json()
form.reset() form.reset()
router.push({ name: "posts.details", params: { postType: "articles", alias: data.alias } }) router.push({ name: "posts.details.articles", params: { alias: data.alias } })
success.value = true success.value = true
editor.show.article = false editor.show.article = false
} else { } else {

View File

@ -15,9 +15,9 @@ const router = createRouter({
}, },
{ {
path: "/p/:postType/:alias", path: "/p/articles/:alias",
name: "posts.details", name: "posts.details.articles",
component: () => import("@/views/posts/details.vue") component: () => import("@/views/posts/articles.vue")
} }
] ]
} }

View File

@ -7,6 +7,7 @@
<div class="aside sticky top-0 w-full h-fit md:min-w-[280px] md:max-w-[320px] max-md:order-first"> <div class="aside sticky top-0 w-full h-fit md:min-w-[280px] md:max-w-[320px] max-md:order-first">
<v-card title="Categories"> <v-card title="Categories">
<v-list density="compact"> <v-list density="compact">
<v-list-item title="All" prepend-icon="mdi-apps" active></v-list-item>
</v-list> </v-list>
</v-card> </v-card>
</div> </div>

View File

@ -30,9 +30,10 @@
<v-card title="Comments"> <v-card title="Comments">
<div class="px-[1rem] pb-[0.825rem] mt-[-12px]"> <div class="px-[1rem] pb-[0.825rem] mt-[-12px]">
<comment-list <comment-list
model="article"
dataset="articles"
v-model:comments="comments" v-model:comments="comments"
:item="post" :item="post"
:model="route.params.postType"
:alias="route.params.alias" :alias="route.params.alias"
/> />
</div> </div>
@ -59,7 +60,7 @@ const route = useRoute()
async function readPost() { async function readPost() {
loading.value = true loading.value = true
const res = await request(`/api/p/${route.params.postType}/${route.params.alias}`) const res = await request(`/api/p/articles/${route.params.alias}`)
if (res.status !== 200) { if (res.status !== 200) {
error.value = await res.text() error.value = await res.text()
} else { } else {