mirror of
https://github.com/BTMuli/TeyvatGuide.git
synced 2025-12-13 09:28:14 +08:00
🚸 完善链接解析
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user