mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
feat(parser): 帖子跳转不用写入文件做中转了
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user