mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
⚡️ 对签到链接跳转进行处理,优化部分网页活动打开
This commit is contained in:
25
src/App.vue
25
src/App.vue
@@ -189,13 +189,26 @@ async function getDeepLink(): Promise<UnlistenFn> {
|
|||||||
e.payload.startsWith("teyvatguide://import_uiaf")
|
e.payload.startsWith("teyvatguide://import_uiaf")
|
||||||
) {
|
) {
|
||||||
await toUIAF(e.payload);
|
await toUIAF(e.payload);
|
||||||
} else {
|
return;
|
||||||
showSnackbar({
|
|
||||||
text: "无效的 deep link!",
|
|
||||||
color: "error",
|
|
||||||
timeout: 3000,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
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,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -223,6 +223,10 @@ async function toNav(item: TGApp.BBS.Navigator.Navigator): Promise<void> {
|
|||||||
window.open(item.app_path);
|
window.open(item.app_path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (item.name === "签到福利") {
|
||||||
|
await TGClient.open("web_act_thin", item.app_path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
const modeConfirm = await showConfirm({
|
const modeConfirm = await showConfirm({
|
||||||
title: "是否采用宽屏模式打开?",
|
title: "是否采用宽屏模式打开?",
|
||||||
text: "取消则采用竖屏模式打开",
|
text: "取消则采用竖屏模式打开",
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
* @file src/utils/linkParser.ts
|
* @file src/utils/linkParser.ts
|
||||||
* @description 处理链接
|
* @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 showConfirm from "../components/func/confirm";
|
||||||
import showSnackbar from "../components/func/snackbar";
|
import showSnackbar from "../components/func/snackbar";
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ export async function parsePost(link: string): Promise<false | string> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @function parseLink
|
* @function parseLink
|
||||||
* @since Beta v0.3.9
|
* @since Beta v0.4.7
|
||||||
* @description 处理链接
|
* @description 处理链接
|
||||||
* @param {string} link - 链接
|
* @param {string} link - 链接
|
||||||
* @param {boolean} useInner - 是否采用内置 JSBridge 打开
|
* @param {boolean} useInner - 是否采用内置 JSBridge 打开
|
||||||
@@ -78,6 +80,16 @@ export async function parseLink(
|
|||||||
const urlTransform = decodeURIComponent(url.search.replace("?url=", ""));
|
const urlTransform = decodeURIComponent(url.search.replace("?url=", ""));
|
||||||
return await parseLink(urlTransform, useInner);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user