♻️ 公告页的窗口创建逻辑也顺便改一下

This commit is contained in:
BTMuli
2023-12-20 00:47:26 +08:00
parent 0d5d77e2bd
commit 568b0b5db7
4 changed files with 23 additions and 25 deletions

View File

@@ -44,7 +44,7 @@ import { nextTick, onMounted, ref } from "vue";
import { useRouter } from "vue-router";
import ToLoading from "../../components/overlay/to-loading.vue";
import { createAnno } from "../../utils/TGWindow";
import { createTGWindow } from "../../utils/TGWindow";
import TGRequest from "../../web/request/TGRequest";
import TGUtils from "../../web/utils/TGUtils";
@@ -100,6 +100,12 @@ function parseTitle(title: string): string {
async function switchNews(): Promise<void> {
await router.push("/news/2");
}
function createAnno(item: TGApp.App.Announcement.ListCard): void {
const annoPath = `/anno_detail/${item.id}`;
const annoTitle = `Anno_${item.id} ${item.title}`;
createTGWindow(annoPath, "Sub_window", annoTitle, 960, 720, false, false);
}
</script>
<style lang="css" scoped>

View File

@@ -5,9 +5,7 @@
*/
import { invoke, window as TauriWindow } from "@tauri-apps/api";
import type { WindowOptions } from "@tauri-apps/api/window";
import { useAppStore } from "../store/modules/app";
import type { WindowOptions } from "@tauri-apps/api/types/window";
/**
* @description 创建TG窗口
@@ -94,24 +92,6 @@ export function createPost(
createTGWindow(postPath, "Sub_window", postTitle, 960, 720, false, false);
}
/**
* @description 打开公告
* @since Beta v0.3.3
* @param {TGApp.App.Announcement.ListCard} item 公告内容或ID
* @returns {void}
*/
export function createAnno(item: TGApp.App.Announcement.ListCard): void {
const annoPath = `/anno_detail/${item.id}`;
const annoJsonPath = `/anno_detail_json/${item.id}`;
const annoTitle = `Anno_${item.id} ${item.title}`;
const annoJsonTitle = `Anno_${item.id}_JSON ${item.title}`;
const isDev = useAppStore().devMode ?? false;
if (isDev) {
createTGWindow(annoJsonPath, "Dev_JSON", annoJsonTitle, 960, 720, false, false);
}
createTGWindow(annoPath, "Sub_window", annoTitle, 960, 720, false, false);
}
/**
* @description 打开 Wiki
* @since Beta v0.3.8

View File

@@ -28,7 +28,9 @@ import { useRoute } from "vue-router";
import TSwitchTheme from "../components/app/t-switchTheme.vue";
import TShareBtn from "../components/main/t-shareBtn.vue";
import ToLoading from "../components/overlay/to-loading.vue";
import { useAppStore } from "../store/modules/app";
import { saveImgLocal } from "../utils/TGShare";
import { createTGWindow } from "../utils/TGWindow";
import TGRequest from "../web/request/TGRequest";
import TGUtils from "../web/utils/TGUtils";
@@ -59,7 +61,6 @@ onMounted(async () => {
}
// 获取数据
loadingTitle.value = "正在获取数据...";
loading.value = true;
try {
annoData.value = await TGRequest.Anno.getContent(annoId);
loadingTitle.value = "正在渲染数据...";
@@ -75,6 +76,11 @@ onMounted(async () => {
await appWindow.setTitle(`Anno_${annoId} Parsing Error`);
return;
}
// 打开 json
const isDev = useAppStore().devMode ?? false;
if (isDev) {
createAnnoJson(annoId);
}
setTimeout(() => {
loading.value = false;
}, 200);
@@ -90,5 +96,11 @@ watch(loadShare, (value) => {
loading.value = false;
}
});
function createAnnoJson(annoId: number) {
const jsonPath = `/anno_detail/${annoId}`;
const jsonTitle = `Anno_${annoId}_JSON`;
createTGWindow(jsonPath, "Dev_JSON", jsonTitle, 960, 720, false, false);
}
</script>
<style lang="css" src="../assets/css/anno-parser.css" scoped></style>

View File

@@ -166,7 +166,7 @@ onMounted(async () => {
// 打开 json
const isDev = useAppStore().devMode ?? false;
if (isDev) {
createPostJson(postId.toString());
createPostJson(postId);
}
await nextTick(() => {
loading.value = false;
@@ -236,7 +236,7 @@ function parseContent(content: string): string {
return JSON.stringify(result);
}
function createPostJson(postId: string): void {
function createPostJson(postId: number): void {
const jsonPath = `/post_detail_json/${postId}`;
const jsonTitle = `Post_${postId}_JSON`;
createTGWindow(jsonPath, "Dev_JSON", jsonTitle, 960, 720, false, false);