mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-14 09:38:13 +08:00
🎨 一些代码调整
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { onMounted, shallowRef } from "vue";
|
||||
import JsonViewer from "vue-json-viewer";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
@@ -21,8 +21,8 @@ const route = useRoute();
|
||||
const annoId = Number(route.params.anno_id);
|
||||
const region = <AnnoServer>route.params.region;
|
||||
const lang = <AnnoLang>route.params.lang;
|
||||
const jsonList = ref<TGApp.BBS.Announcement.AnnoSingle>();
|
||||
const jsonContent = ref<TGApp.BBS.Announcement.ContentItem>();
|
||||
const jsonList = shallowRef<TGApp.BBS.Announcement.AnnoSingle>();
|
||||
const jsonContent = shallowRef<TGApp.BBS.Announcement.ContentItem>();
|
||||
|
||||
onMounted(async () => {
|
||||
showLoading.start("正在获取公告数据...");
|
||||
@@ -32,11 +32,14 @@ onMounted(async () => {
|
||||
}
|
||||
showLoading.update("正在获取数据...", `公告ID: ${annoId}`);
|
||||
const listData = await Hk4eApi.anno.list(region, lang);
|
||||
listData.list.map((item: TGApp.BBS.Announcement.ListItem) => {
|
||||
return item.list.map((single: TGApp.BBS.Announcement.AnnoSingle) => {
|
||||
return single.ann_id === annoId ? (jsonList.value = single) : null;
|
||||
});
|
||||
});
|
||||
for (const listItem of listData.list) {
|
||||
for (const single of listItem.list) {
|
||||
if (single.ann_id === annoId) {
|
||||
jsonList.value = single;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
jsonContent.value = await Hk4eApi.anno.content(annoId, region, lang);
|
||||
showLoading.end();
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<TSwitchTheme />
|
||||
<TPinWin />
|
||||
<TShareBtn v-model="annoRef" :title="annoTitle" />
|
||||
<TShareBtn selector=".anno-body" :title="`Anno_${route.params.anno_id}`" />
|
||||
<div class="anno-body" v-if="annoData">
|
||||
<div class="anno-info">AnnoID: {{ annoId }} | Render by TeyvatGuide v{{ appVersion }}</div>
|
||||
<div class="anno-title">{{ annoData.title }}</div>
|
||||
@@ -13,7 +13,7 @@
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { app, webviewWindow } from "@tauri-apps/api";
|
||||
import { ref, onMounted } from "vue";
|
||||
import { onMounted, ref, shallowRef } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import TPinWin from "../components/app/t-pinWin.vue";
|
||||
@@ -26,16 +26,12 @@ import TGLogger from "../utils/TGLogger.js";
|
||||
import { createTGWindow } from "../utils/TGWindow.js";
|
||||
import Hk4eApi, { AnnoLang, AnnoServer } from "../web/request/hk4eReq.js";
|
||||
|
||||
const annoRef = ref<HTMLElement>(<HTMLElement>{});
|
||||
const annoTitle = ref<string>("");
|
||||
|
||||
// 数据
|
||||
const route = useRoute();
|
||||
const annoId = Number(route.params.anno_id);
|
||||
const region = <AnnoServer>route.params.region;
|
||||
const lang = <AnnoLang>route.params.lang;
|
||||
const appVersion = ref<string>();
|
||||
const annoData = ref<TGApp.BBS.Announcement.ContentItem | undefined>();
|
||||
const annoData = shallowRef<TGApp.BBS.Announcement.ContentItem | undefined>();
|
||||
|
||||
onMounted(async () => {
|
||||
showLoading.start("正在加载公告数据...");
|
||||
@@ -49,11 +45,9 @@ onMounted(async () => {
|
||||
try {
|
||||
annoData.value = await Hk4eApi.anno.content(annoId, region, lang);
|
||||
showLoading.update("正在渲染数据...", `公告ID:${annoId}`);
|
||||
annoTitle.value = `Anno_${annoId}`;
|
||||
await webviewWindow
|
||||
.getCurrentWebviewWindow()
|
||||
.setTitle(`Anno_${annoId} ${annoData.value.title}`);
|
||||
annoRef.value = <HTMLElement>document.querySelector(".anno-body");
|
||||
} catch (error) {
|
||||
if (error instanceof Error)
|
||||
await TGLogger.Error(`[t-anno.vue][${annoId}] ${error.name}:${error.message}`);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { onMounted, ref, shallowRef } from "vue";
|
||||
import JsonViewer from "vue-json-viewer";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
@@ -19,8 +19,8 @@ import Mys from "../plugins/Mys/index.js";
|
||||
import TGLogger from "../utils/TGLogger.js";
|
||||
|
||||
const postId = Number(useRoute().params.post_id);
|
||||
const jsonData = ref<TGApp.Plugins.Mys.Post.FullData>();
|
||||
const parseData = ref<TGApp.Plugins.Mys.SctPost.Base[]>();
|
||||
const jsonData = shallowRef<TGApp.Plugins.Mys.Post.FullData>();
|
||||
const parseData = shallowRef<TGApp.Plugins.Mys.SctPost.Base[]>();
|
||||
const isEmpty = ref<boolean>(false);
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<TSwitchTheme />
|
||||
<TPinWin />
|
||||
<VpBtnCollect :model-value="postId" :data="postData" />
|
||||
<TShareBtn v-model="postRef" :title="shareTitle" />
|
||||
<TShareBtn selector=".tp-post-body" :title="`Post_${postId}`" />
|
||||
<VpBtnReply :gid="postData.post.game_id" :post-id="postData.post.post_id" v-if="postData" />
|
||||
<div class="tp-post-body" v-if="postData">
|
||||
<div class="tp-post-info">
|
||||
@@ -83,10 +83,9 @@
|
||||
/>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { app } from "@tauri-apps/api";
|
||||
import { webviewWindow } from "@tauri-apps/api";
|
||||
import { app, webviewWindow } from "@tauri-apps/api";
|
||||
import { emit } from "@tauri-apps/api/event";
|
||||
import { nextTick, onMounted, onUnmounted, ref } from "vue";
|
||||
import { nextTick, onMounted, onUnmounted, ref, shallowRef } from "vue";
|
||||
import { useRoute } from "vue-router";
|
||||
|
||||
import TPinWin from "../components/app/t-pinWin.vue";
|
||||
@@ -106,21 +105,14 @@ import TGLogger from "../utils/TGLogger.js";
|
||||
import { createTGWindow } from "../utils/TGWindow.js";
|
||||
import TGConstant from "../web/constant/TGConstant.js";
|
||||
|
||||
// share
|
||||
const postRef = ref<HTMLElement>(<HTMLElement>{});
|
||||
const shareTitle = ref<string>("");
|
||||
|
||||
// 数据
|
||||
const appVersion = ref<string>();
|
||||
const appVersion = await app.getVersion();
|
||||
const postId = Number(useRoute().params.post_id);
|
||||
const renderPost = ref<TGApp.Plugins.Mys.SctPost.Base[]>([]);
|
||||
const postData = ref<TGApp.Plugins.Mys.Post.FullData>();
|
||||
// 当前时间,秒级时间戳
|
||||
const renderPost = shallowRef<TGApp.Plugins.Mys.SctPost.Base[]>([]);
|
||||
const postData = shallowRef<TGApp.Plugins.Mys.Post.FullData>();
|
||||
const showCollection = ref<boolean>(false);
|
||||
const shareTime = ref<number>(Math.floor(Date.now() / 1000));
|
||||
// eslint-disable-next-line no-undef
|
||||
const shareTimeTimer = ref<NodeJS.Timeout | undefined>(undefined);
|
||||
// 合集
|
||||
const showCollection = ref<boolean>(false);
|
||||
|
||||
function getGameIcon(gameId: number): string {
|
||||
const find = TGConstant.BBS.CHANNELS.find((item) => item.gid === gameId.toString());
|
||||
@@ -130,7 +122,6 @@ function getGameIcon(gameId: number): string {
|
||||
|
||||
onMounted(async () => {
|
||||
showLoading.start(`正在加载帖子数据...`);
|
||||
appVersion.value = await app.getVersion();
|
||||
// 检查数据
|
||||
if (!postId) {
|
||||
showLoading.empty("未找到数据", "PostID 不存在");
|
||||
@@ -150,7 +141,6 @@ onMounted(async () => {
|
||||
postData.value = resp;
|
||||
showLoading.update("正在渲染数据...", `帖子ID: ${postId}`);
|
||||
renderPost.value = getRenderPost(postData.value);
|
||||
shareTitle.value = `Post_${postId}`;
|
||||
await webviewWindow
|
||||
.getCurrentWebviewWindow()
|
||||
.setTitle(`Post_${postId} ${postData.value.post.subject}`);
|
||||
@@ -167,7 +157,6 @@ onMounted(async () => {
|
||||
shareTimeTimer.value = undefined;
|
||||
}
|
||||
shareTimeTimer.value = setInterval(() => (shareTime.value = Math.floor(Date.now() / 1000)), 1000);
|
||||
postRef.value = <HTMLElement>document.querySelector(".tp-post-body");
|
||||
showLoading.end();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user