feat(json-view): 写了个看json的页面,顺带更新了下依赖

This commit is contained in:
BTMuli
2023-03-29 22:07:11 +08:00
parent e53114cb91
commit 6faec8d7cd
8 changed files with 470 additions and 348 deletions

View File

@@ -1,2 +1,40 @@
<template></template>
<script lang="ts"></script>
<template>
<div v-if="loading">
<t-loading :empty="loadingEmpty" :title="loadingTitle" />
</div>
<div v-else class="mys-post-json">
<json-viewer :value="jsonData" copyable boxed />
</div>
</template>
<script lang="ts" setup>
// vue
import { ref, onMounted, reactive } from "vue";
import { useRoute } from "vue-router";
import TLoading from "../components/t-loading.vue";
// plugins
import MysOper from "../plugins/Mys";
// loading
const loading = ref(true as boolean);
const loadingTitle = ref("正在加载");
const loadingEmpty = ref(false as boolean);
// 数据
const post_id = Number(useRoute().params.post_id);
let jsonData = reactive({});
onMounted(async () => {
// 检查数据
if (!post_id) {
loadingEmpty.value = true;
loadingTitle.value = "未找到数据";
return;
}
// 获取数据
loadingTitle.value = "正在获取数据...";
jsonData = await MysOper.Post.get(post_id);
setInterval(() => {
loading.value = false;
}, 200);
});
</script>