mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🧑💻 结构化内容解析显示,便于调试
This commit is contained in:
1
src/plugins/Mys/types/Post.d.ts
vendored
1
src/plugins/Mys/types/Post.d.ts
vendored
@@ -303,6 +303,7 @@ declare namespace TGApp.Plugins.Mys.Post {
|
||||
/**
|
||||
* @description 帖子结构化内容
|
||||
* @since Alpha v0.2.1
|
||||
* @todo 重构
|
||||
* @interface StructuredContent
|
||||
* @property {string|object} insert 插入内容
|
||||
* @property {string} insert.image 图片 URL
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<div class="post-json">
|
||||
<div class="post-title">帖子返回内容 JSON</div>
|
||||
<JsonViewer :value="jsonData" copyable boxed />
|
||||
<div class="post-title">结构化内容解析</div>
|
||||
<JsonViewer :value="parseData" copyable boxed />
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
@@ -25,7 +27,8 @@ const loadingEmpty = ref<boolean>(false);
|
||||
|
||||
// 数据
|
||||
const postId = Number(useRoute().params.post_id);
|
||||
let jsonData = reactive({});
|
||||
let jsonData = reactive<TGApp.Plugins.Mys.Post.FullData>(<TGApp.Plugins.Mys.Post.FullData>{});
|
||||
let parseData = reactive<TGApp.Plugins.Mys.Post.StructuredContent[]>([]);
|
||||
|
||||
onMounted(async () => {
|
||||
await appWindow.show();
|
||||
@@ -39,6 +42,7 @@ onMounted(async () => {
|
||||
loadingTitle.value = "正在获取数据...";
|
||||
try {
|
||||
jsonData = await Mys.Post.get(postId);
|
||||
parseData = JSON.parse(jsonData.post.structured_content);
|
||||
loading.value = false;
|
||||
} catch (e) {
|
||||
loadingTitle.value = "帖子不存在或解析失败";
|
||||
@@ -50,18 +54,18 @@ onMounted(async () => {
|
||||
.post-json {
|
||||
padding: 20px;
|
||||
border-radius: 20px;
|
||||
font-family: Consolas, serif;
|
||||
font-family: var(--font-text);
|
||||
}
|
||||
|
||||
.post-title {
|
||||
margin: 20px 0;
|
||||
color: #546d8b;
|
||||
font-family: Genshin-Light, serif;
|
||||
color: var(--common-text-title);
|
||||
font-family: var(--font-title);
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.jv-container {
|
||||
background: var(--content-bg-2) !important;
|
||||
background: var(--box-bg-2) !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user