From f6bea9b2e714200d350f7ad8169890259d328e05 Mon Sep 17 00:00:00 2001 From: BTMuli Date: Thu, 12 Oct 2023 00:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E8=A7=A3=E5=86=B3=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=8C=96=E6=97=A0=E6=B3=95=E5=94=A4=E8=B5=B7=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 70 ++++++++++++++++++++++++++--------------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/src/App.vue b/src/App.vue index d6ee3707..d1973ab2 100644 --- a/src/App.vue +++ b/src/App.vue @@ -167,43 +167,41 @@ async function initData(): Promise { } async function getDeepLink(): Promise { - await event.listen("active_deep_link", (e) => { - new TauriWindow.WebviewWindow("TeyvatGuide") - .setFocus() - .then(async () => { - if (typeof e.payload !== "string") { - showSnackbar({ - text: "无效的 deep link!", - color: "error", - timeout: 3000, - }); - return; - } - if (e.payload === "") return; - // 导入格式: teyvatguide://import_uigf?app=appName - // 跳转格式: localhost:4000/achievements/?app=appName - if (e.payload.startsWith("teyvatguide://import_uigf")) { - const param = (e.payload).split("teyvatguide://import_uigf/?")[1]; - let appName = ""; - if (param) { - appName = param.split("app=")[1]; - } - if (appName === "") { - await router.push("/achievements"); - } else { - await router.push("/achievements/?app=" + appName); - } - } else { - showSnackbar({ - text: "无效的 deep link!", - color: "error", - timeout: 3000, - }); - } - }) - .catch((e) => { - console.log(e); + await event.listen("active_deep_link", async (e) => { + const windowGet = new TauriWindow.WebviewWindow("TeyvatGuide"); + if (await windowGet.isMinimized()) { + await windowGet.unminimize(); + } + await windowGet.setFocus(); + if (typeof e.payload !== "string") { + showSnackbar({ + text: "无效的 deep link!", + color: "error", + timeout: 3000, + }); + return; + } + if (e.payload === "") return; + // 导入格式: teyvatguide://import_uigf?app=appName + // 跳转格式: localhost:4000/achievements/?app=appName + if (e.payload.startsWith("teyvatguide://import_uigf")) { + const param = (e.payload).split("teyvatguide://import_uigf/?")[1]; + let appName = ""; + if (param) { + appName = param.split("app=")[1]; + } + if (appName === "") { + await router.push("/achievements"); + } else { + await router.push("/achievements/?app=" + appName); + } + } else { + showSnackbar({ + text: "无效的 deep link!", + color: "error", + timeout: 3000, }); + } }); }