feat(parser): 帖子跳转不用写入文件做中转了

This commit is contained in:
BTMuli
2023-03-29 20:42:10 +08:00
parent d6b5a38892
commit e47c339a1b
6 changed files with 124 additions and 104 deletions

View File

@@ -1,14 +1,41 @@
<template>
<div>TEST {{ $route.meta.isMain }}</div>
<div v-if="loading">
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else v-html="postHtml" class="mys-post-body" />
</template>
<script lang="ts" setup>
// 获取路由传参
// vue
import { ref, onMounted } from "vue";
import { useRoute } from "vue-router";
import TLoading from "../components/t-loading.vue";
// plugins
import MysOper from "../plugins/Mys";
const route = useRoute();
// loading
const loading = ref(true as boolean);
const loadingTitle = ref("正在加载");
const loadingEmpty = ref(false as boolean);
// 获取路由参
const id = route.params.post_id;
console.log(id);
// 数
const post_id = Number(useRoute().params.post_id);
const postHtml = ref("");
onMounted(async () => {
// 检查数据
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
const postData = await MysOper.Post.get(post_id);
loadingTitle.value = "正在渲染数据...";
postHtml.value = MysOper.Post.parser(postData.post.structured_content);
setInterval(() => {
loading.value = false;
}, 200);
});
</script>
<style lang="css"></style>