feat(cli): add Post page view

This commit is contained in:
Tim
2025-07-03 14:43:04 +08:00
parent 992cc01aa1
commit 2f54574815
3 changed files with 47 additions and 1 deletions

View File

@@ -0,0 +1,40 @@
<template>
<div class="post-page">
<h2>{{ post?.title }}</h2>
<div v-if="post">{{ post.content }}</div>
<div v-else>Loading...</div>
</div>
</template>
<script>
import { onMounted, ref } from 'vue'
import { useRoute } from 'vue-router'
export default {
name: 'PostPageView',
setup() {
const route = useRoute()
const post = ref(null)
onMounted(async () => {
const id = route.params.id
try {
const res = await fetch(`/api/posts/${id}`)
if (res.ok) {
post.value = await res.json()
}
} catch (err) {
console.error(err)
}
})
return { post }
}
}
</script>
<style scoped>
.post-page {
padding: 20px;
}
</style>