diff --git a/dist-pc.rar b/dist.rar similarity index 78% rename from dist-pc.rar rename to dist.rar index 5b966bf..7d7e65e 100644 Binary files a/dist-pc.rar and b/dist.rar differ diff --git a/src/router/index.js b/src/router/index.js index 623f6b8..02507ee 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,31 +1,60 @@ -import { createRouter, createWebHistory } from 'vue-router'; +import { createRouter, createWebHistory } from "vue-router"; const routes = [ - { - path: '/', - redirect: '/quest', + path: "/", + name: "index1", + component: () => + import(/* webpackChunkName "index1" */ "@/views/TaskView.vue"), + meta: { + title: "Counter Fire", + canonical: "https://www.counterfire.games", + alternate: "https://m.counterfire.games", + }, }, { - path: '/quest', - name: 'QUEST', - component: () => import(/* webpackChunkName "marketplace" */ '@/views/TaskView.vue'), - + path: "/quest", + name: "QUEST", + meta: { + title: "Counter Fire Quest", + canonical: "https://www.counterfire.games/quest", + alternate: "https://m.counterfire.games/quest", + }, + component: () => + import(/* webpackChunkName "marketplace" */ "@/views/TaskView.vue"), }, { - path: '/index.html', - name: 'index', - component: () => import(/* webpackChunkName "index" */ '@/views/TaskView.vue'), + path: "/index.html", + name: "index", + component: () => + import(/* webpackChunkName "index" */ "@/views/TaskView.vue"), + meta: { + title: "Counter Fire index", + canonical: "https://www.counterfire.games/index.html", + alternate: "https://m.counterfire.games/index.html", + }, }, { - path: '/undertest', - name: 'TaskOne', - component: () => import(/* webpackChunkName "TaskOne" */ '@/components/task/TaskOne.vue'), + path: "/undertest", + name: "TaskOne", + meta: { + title: "Counter Fire Undertest", + canonical: "https://www.counterfire.games/undertest", + alternate: "https://m.counterfire.games/undertest", + }, + component: () => + import(/* webpackChunkName "TaskOne" */ "@/components/task/TaskOne.vue"), }, { - path: '/taskTwo', - name: 'TaskTwo', - component: () => import(/* webpackChunkName "TaskTwo" */ '@/components/task/TaskTwo.vue'), + path: "/taskTwo", + name: "TaskTwo", + meta: { + title: "Counter Fire TaskTwo", + canonical: "https://www.counterfire.games/taskTwo", + alternate: "https://m.counterfire.games/taskTwo", + }, + component: () => + import(/* webpackChunkName "TaskTwo" */ "@/components/task/TaskTwo.vue"), }, ]; @@ -38,7 +67,9 @@ const router = createRouter({ }); function isMobileDevice(userAgent) { - return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(userAgent); + return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( + userAgent + ); } router.beforeEach((to, from, next) => { @@ -46,9 +77,31 @@ router.beforeEach((to, from, next) => { // 对于 PC 端官网项目: if (!isMobile) { + if (to.meta.title) { + document.title = to.meta.title; + } + let link = document.querySelector("link[rel='canonical']") + if (!link) { + link = document.createElement('link') + link.rel = 'canonical' + document.head.appendChild(link) + } + 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.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?code=${ + to.query.code ? to.query.code : "" + }`; } });