WebIndex/pages/article/[cid].vue

55 lines
1.7 KiB
Vue
Raw Normal View History

2024-11-17 13:05:55 +08:00
<script setup lang="ts">
2025-01-13 21:51:37 +08:00
const route = useRoute(),
cid = route.params.cid as string,
content = ref<IBlogResponse<IPostFull>>(),
2024-12-01 13:09:44 +08:00
2025-01-13 21:51:37 +08:00
getPost = get<IBlogResponse<IPostFull>, any>('/blog/index.php/api/post', {
params: {
cid,
md: false,
},
}),
2024-12-02 20:00:21 +08:00
2025-01-13 21:51:37 +08:00
title = computed(() => content.value?.data.title || 'Can not see me... can not see me...'),
text = computed(() => content.value?.data.text || '## Ops!'),
date = computed(() => new Date((content.value?.data.date.timeStamp || 0) * 1000)
2024-12-02 20:00:21 +08:00
.toISOString()
2025-01-13 21:51:37 +08:00
.split('T')[0],
),
category = computed(() => content.value?.data.category || 'default'),
url = computed(() => content.value?.data.url || '/error/404')
2024-12-02 20:00:21 +08:00
content.value = await getPost()
2024-11-17 13:05:55 +08:00
</script>
<template>
2024-12-18 08:44:37 +08:00
<section class="container m-4 mx-auto rounded-xl bg-white p-8 shadow-md lg:max-w-screen-lg">
<div class="mb-4 border-b-2 border-dashed border-gray-200 pb-4">
2025-01-13 21:51:37 +08:00
<h1 class="text-center text-3xl font-bold">
{{ title }}
</h1>
2024-12-18 08:44:37 +08:00
<div class="flex w-full items-center justify-center gap-4 text-gray-600">
2024-12-02 20:00:21 +08:00
<!-- 日期 -->
<div class="flex items-center gap-2">
<font-awesome-icon :icon="['far', 'clock']" />
<time>{{ date }}</time>
</div>
<!-- 分类 -->
<div class="flex items-center gap-2">
<font-awesome-icon :icon="['far', 'folder']" />
<span>{{ category }}</span>
</div>
<div class="flex items-center gap-2">
<font-awesome-icon :icon="['fas', 'link']" />
<a :href="url">原文链接</a>
</div>
</div>
</div>
2025-01-13 21:51:37 +08:00
<markdown-section :content="text" />
2024-12-02 20:00:21 +08:00
</section>
2024-11-17 13:05:55 +08:00
</template>
<style scoped>
2025-01-13 21:51:37 +08:00
</style>