X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Frouter.js;h=ede2186bdd30f21b08afe1837165efd3a6d3bb2d;hb=714680114508183fba2c07231dbe8f90b5631b81;hp=1eb88f913a20f8b6c8a9687e9ba0538fdddd7018;hpb=652f40de91b2694093ba9755f24b76b81caff232;p=vchess.git diff --git a/client/src/router.js b/client/src/router.js index 1eb88f91..ede2186b 100644 --- a/client/src/router.js +++ b/client/src/router.js @@ -5,7 +5,7 @@ import Hall from "./views/Hall.vue"; Vue.use(Router); function loadView(view) { - return () => import(/* webpackChunkName: "view-[request]" */ `@/views/${view}.vue`) + return () => import(/* webpackChunkName: "view-[request]" */ `@/views/${view}.vue`) } import { ajax } from "@/utils/ajax"; @@ -31,29 +31,12 @@ const router = new Router({ { path: "/authenticate/:token", name: "authenticate", - beforeEnter: (to, from, next) => { - ajax( - "/authenticate", - "GET", - {token: to.params["token"]}, - (res) => { - if (!res.errmsg) //if not already logged in - { - store.state.user.id = res.id; - store.state.user.name = res.name; - store.state.user.email = res.email; - store.state.user.notify = res.notify; - localStorage["myname"] = res.name; - localStorage["myid"] = res.id; - } - // TODO: I don't like these 2 lines, "next('/')" should be enough - window.location = "/"; - next(); - } - ); - }, - component: Hall, - //redirect: "/", //problem: redirection before end of AJAX request + component: loadView("Auth"), + }, + { + path: "/logout", + name: "logout", + component: loadView("Logout"), }, { path: "/mygames", @@ -61,14 +44,14 @@ const router = new Router({ component: loadView("MyGames"), }, { - path: "/game/:id", + path: "/game/:id([a-zA-Z0-9]+)", name: "game", component: loadView("Game"), }, { - path: "/analyze/:vname([a-zA-Z0-9]+)", - name: "analyze", - component: loadView("Analyze"), + path: "/analyse/:vname([a-zA-Z0-9]+)", + name: "analyse", + component: loadView("Analyse"), }, { path: "/about", @@ -78,14 +61,4 @@ const router = new Router({ ] }); -router.beforeEach((to, from, next) => { - window.scrollTo(0, 0); - if (!!store.state.conn) //uninitialized at first page - { - // Notify WebSockets server (TODO: path or fullPath?) - store.state.conn.send(JSON.stringify({code: "pagechange", page: to.path})); - } - next(); -}); - export default router;