From 6316cc42b2cbe4e48ebf8dcfdf25361d6f524431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Mon, 29 Apr 2024 00:30:02 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20=E5=AF=B9=E7=AD=BE?= =?UTF-8?q?=E5=88=B0=E9=93=BE=E6=8E=A5=E8=B7=B3=E8=BD=AC=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?= =?UTF-8?q?=E7=BD=91=E9=A1=B5=E6=B4=BB=E5=8A=A8=E6=89=93=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 25 +++++++++++++++++++------ src/pages/common/Posts.vue | 4 ++++ src/utils/linkParser.ts | 16 ++++++++++++++-- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/App.vue b/src/App.vue index 1f461a79..135023ad 100644 --- a/src/App.vue +++ b/src/App.vue @@ -189,13 +189,26 @@ async function getDeepLink(): Promise { e.payload.startsWith("teyvatguide://import_uiaf") ) { await toUIAF(e.payload); - } else { - showSnackbar({ - text: "无效的 deep link!", - color: "error", - timeout: 3000, - }); + return; } + if (e.payload.startsWith("router?path=")) { + const routerPath = e.payload.replace("router?path=", ""); + if (router.currentRoute.value.path === routerPath) { + showSnackbar({ + text: "已在当前页面!", + color: "warn", + timeout: 3000, + }); + return; + } + await router.push(routerPath); + return; + } + showSnackbar({ + text: "无效的 deep link!", + color: "error", + timeout: 3000, + }); }); } diff --git a/src/pages/common/Posts.vue b/src/pages/common/Posts.vue index e4507196..e9457440 100644 --- a/src/pages/common/Posts.vue +++ b/src/pages/common/Posts.vue @@ -223,6 +223,10 @@ async function toNav(item: TGApp.BBS.Navigator.Navigator): Promise { window.open(item.app_path); return; } + if (item.name === "签到福利") { + await TGClient.open("web_act_thin", item.app_path); + return; + } const modeConfirm = await showConfirm({ title: "是否采用宽屏模式打开?", text: "取消则采用竖屏模式打开", diff --git a/src/utils/linkParser.ts b/src/utils/linkParser.ts index fea18075..553cbb81 100644 --- a/src/utils/linkParser.ts +++ b/src/utils/linkParser.ts @@ -1,9 +1,11 @@ /** * @file src/utils/linkParser.ts * @description 处理链接 - * @since Beta v0.3.9 + * @since Beta v0.4.7 */ +import { emit } from "@tauri-apps/api/event"; + import showConfirm from "../components/func/confirm"; import showSnackbar from "../components/func/snackbar"; @@ -50,7 +52,7 @@ export async function parsePost(link: string): Promise { /** * @function parseLink - * @since Beta v0.3.9 + * @since Beta v0.4.7 * @description 处理链接 * @param {string} link - 链接 * @param {boolean} useInner - 是否采用内置 JSBridge 打开 @@ -78,6 +80,16 @@ export async function parseLink( const urlTransform = decodeURIComponent(url.search.replace("?url=", "")); return await parseLink(urlTransform, useInner); } + console.log(url.pathname, url.search); + // 处理特定路径 + if (url.pathname.startsWith("//discussion")) { + await emit("active_deep_link", "router?path=/posts"); + return true; + } + if (link === "mihoyobbs://homeForum?game_id=2&tab_type=2") { + await emit("active_deep_link", "router?path=/news/2/news"); + return true; + } } return false; }