From df5d22d39b2220f2c46ae4ccfed0447dfeb42770 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Mon, 18 Dec 2023 18:32:46 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=80=BB=E8=BE=91=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/TGWindow.ts | 11 ++--------- src/views/t-post.vue | 13 +++++++++++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/utils/TGWindow.ts b/src/utils/TGWindow.ts index 26231e65..1308e925 100644 --- a/src/utils/TGWindow.ts +++ b/src/utils/TGWindow.ts @@ -73,7 +73,7 @@ export function createTGWindow( /** * @description 打开帖子 - * @since Beta v0.3.7 + * @since Beta v0.3.8 * @param {TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard} item 帖子内容或ID * @param {string} title 帖子标题 * @returns {void} @@ -82,22 +82,15 @@ export function createPost( item: TGApp.Plugins.Mys.News.RenderCard | string | number | TGApp.Plugins.Mys.Forum.RenderCard, title?: string, ): void { - let postId, postTitle, jsonTitle; + let postId, postTitle; if (typeof item === "string" || typeof item === "number") { postId = item.toString(); postTitle = title ? `Post_${postId} ${title}` : `Post_${postId}`; - jsonTitle = title ? `Post_${postId}_JSON ${title}` : `Post_${postId}_JSON`; } else { postId = item.postId.toString(); postTitle = `Post_${postId} ${item.title}`; - jsonTitle = `Post_${postId}_JSON ${item.title}`; } const postPath = `/post_detail/${postId}`; - const jsonPath = `/post_detail_json/${postId}`; - const isDev = useAppStore().devMode ?? false; - if (isDev) { - createTGWindow(jsonPath, "Dev_JSON", jsonTitle, 960, 720, false, false); - } createTGWindow(postPath, "Sub_window", postTitle, 960, 720, false, false); } diff --git a/src/views/t-post.vue b/src/views/t-post.vue index 806d3a3c..a4a2e689 100644 --- a/src/views/t-post.vue +++ b/src/views/t-post.vue @@ -75,6 +75,8 @@ import TShareBtn from "../components/main/t-shareBtn.vue"; import ToLoading from "../components/overlay/to-loading.vue"; import TpParser from "../components/post/tp-parser.vue"; import Mys from "../plugins/Mys"; +import { useAppStore } from "../store/modules/app"; +import { createTGWindow } from "../utils/TGWindow"; interface PostRender { title: string; @@ -161,6 +163,11 @@ onMounted(async () => { await appWindow.setTitle(`Post_${postId} Parsing Error`); return; } + // 打开 json + const isDev = useAppStore().devMode ?? false; + if (isDev) { + createPostJson(postId.toString()); + } await nextTick(() => { loading.value = false; }); @@ -228,6 +235,12 @@ function parseContent(content: string): string { }); return JSON.stringify(result); } + +function createPostJson(postId: string): void { + const jsonPath = `/post_detail_json/${postId}`; + const jsonTitle = `Post_${postId}_JSON`; + createTGWindow(jsonPath, "Dev_JSON", jsonTitle, 960, 720, false, false); +}