From 7f5ffab2a71c43afe8277dd826bd1479552c1247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Tue, 25 Feb 2025 09:07:39 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E8=B0=83=E6=95=B4=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/common/PageConfig.vue | 3 ++- src/views/t-post.vue | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/pages/common/PageConfig.vue b/src/pages/common/PageConfig.vue index 6d7ae148..fbd2adb4 100644 --- a/src/pages/common/PageConfig.vue +++ b/src/pages/common/PageConfig.vue @@ -157,7 +157,7 @@ import TcGameBadge from "@comp/pageConfig/tc-gameBadge.vue"; import TcInfo from "@comp/pageConfig/tc-info.vue"; import TcUserBadge from "@comp/pageConfig/tc-userBadge.vue"; import TGSqlite from "@Sqlite/index.js"; -import { core } from "@tauri-apps/api"; +import { core, event } from "@tauri-apps/api"; import { open } from "@tauri-apps/plugin-dialog"; import { remove } from "@tauri-apps/plugin-fs"; import { platform } from "@tauri-apps/plugin-os"; @@ -513,6 +513,7 @@ function submitResize(): void { // 开启无痕浏览 async function switchIncognito(): Promise { + await event.emit("switchIncognito"); if (appStore.incognito) { showSnackbar.success("已关闭无痕浏览!"); return; diff --git a/src/views/t-post.vue b/src/views/t-post.vue index c07209c3..ff3c87fb 100644 --- a/src/views/t-post.vue +++ b/src/views/t-post.vue @@ -101,9 +101,9 @@ import VpBtnReply from "@comp/viewPost/vp-btn-reply.vue"; import VpOverlayCollection from "@comp/viewPost/vp-overlay-collection.vue"; import Mys from "@Mys/index.js"; import { app, webviewWindow } from "@tauri-apps/api"; -import { emit } from "@tauri-apps/api/event"; +import { emit, listen, UnlistenFn } from "@tauri-apps/api/event"; import { storeToRefs } from "pinia"; -import { onMounted, onUnmounted, ref, shallowRef } from "vue"; +import { onBeforeMount, onMounted, onUnmounted, ref, shallowRef } from "vue"; import { useRoute } from "vue-router"; import { useAppStore } from "@/store/modules/app.js"; @@ -126,6 +126,7 @@ const postData = shallowRef(); // eslint-disable-next-line no-undef let shareTimer: NodeJS.Timeout | null = null; +let incognitoListener: UnlistenFn | null = null; function getGameIcon(gameId: number): string { const find = TGBbs.channels.find((item) => item.gid === gameId); @@ -133,6 +134,17 @@ function getGameIcon(gameId: number): string { return "/platforms/mhy/mys.webp"; } +onBeforeMount(async () => { + incognitoListener = await listen("switchIncognito", () => window.location.reload()); +}); + +onUnmounted(() => { + if (incognitoListener !== null) { + incognitoListener(); + incognitoListener = null; + } +}); + onMounted(async () => { await showLoading.start(`正在加载帖子数据`); appVersion.value = await app.getVersion(); @@ -268,6 +280,10 @@ async function tryLike(): Promise { showSnackbar.error("数据未加载"); return; } + if (!incognito.value) { + showSnackbar.error("无法在无痕浏览模式下操作"); + return; + } const ck = { ltoken: cookie.value.ltoken, ltuid: cookie.value.ltuid }; const resp = await apiHubReq.post.like(postData.value.post.post_id, ck, isLike.value); if (resp.retcode !== 0) {