🚸 完善链接解析

This commit is contained in:
BTMuli
2023-12-11 15:52:38 +08:00
parent 07e944859c
commit 30a97e9973

View File

@@ -266,6 +266,10 @@ async function toNav(path: string): Promise<void> {
"https://bbs.mihoyo.com",
"https://qaa.miyoushe.com",
];
if (link.protocol != "https:") {
toBBS(link);
return;
}
// 如果不在上面的域名里面,就直接打开
if (!mysList.includes(link.origin)) {
window.open(path);
@@ -280,6 +284,27 @@ async function toNav(path: string): Promise<void> {
else await TGClient.open("web_act_thin", path);
}
// 处理 protocol
function toBBS(link: URL): void {
if (link.protocol == "mihoyobbs:") {
if (link.pathname.startsWith("//article")) {
const postId = link.pathname.split("/").pop();
createPost(<string>postId);
return;
}
if (link.pathname.startsWith("//forum")) {
const forumId = link.pathname.split("/").pop();
const url = `https://www.miyoushe.com/ys/home/${forumId}`;
window.open(url);
return;
}
}
showSnackbar({
text: `不支持的链接:${link.href}`,
color: "warn",
});
}
async function freshNavData(): Promise<void> {
nav.value = await Mys.Posts.nav(curGid.value);
}