This commit is contained in:
huangjinming 2023-07-04 14:11:45 +08:00
parent 487b0bb8df
commit 20802004ab
2 changed files with 13 additions and 14 deletions

Binary file not shown.

View File

@ -80,27 +80,26 @@ router.beforeEach((to, from, next) => {
if (to.meta.title) {
document.title = to.meta.title;
}
let link = document.querySelector("link[rel='canonical']")
let link = document.querySelector("link[rel='canonical']");
if (!link) {
link = document.createElement('link')
link.rel = 'canonical'
document.head.appendChild(link)
link = document.createElement("link");
link.rel = "canonical";
document.head.appendChild(link);
}
link.href = to.meta.canonical
let alternateLink = document.querySelector("link[rel='alternate']")
link.href = to.meta.canonical;
let alternateLink = document.querySelector("link[rel='alternate']");
if (!alternateLink) {
alternateLink = document.createElement('link')
alternateLink.rel = 'alternate'
alternateLink.media = 'only screen and (max-width: 640px)'
document.head.appendChild(alternateLink)
alternateLink = document.createElement("link");
alternateLink.rel = "alternate";
alternateLink.media = "only screen and (max-width: 640px)";
document.head.appendChild(alternateLink);
}
alternateLink.href = to.meta.alternate
alternateLink.href = to.meta.alternate;
next(); // 如果是 PC 设备,继续导航
} else {
window.location.href = `https://m.counterfire.games?code=${
to.query.code ? to.query.code : ""
window.location.href = `https://m.counterfire.games${ to.query.code ? '?code=' + to.query.code : ""
}`;
}
});