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