X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Frouter.js;h=b2efee78e292b78242ae521bb694271b985afd6f;hb=8418f0d79395f40172b11d62eef8b83112f1d240;hp=a4d3236929800d970e8d06967e2cf79f1127f43e;hpb=41cb9b940084d6f56351a772f0340ebf0bc8d1bc;p=vchess.git diff --git a/client/src/router.js b/client/src/router.js index a4d32369..b2efee78 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", @@ -66,9 +49,9 @@ const router = new Router({ component: loadView("Game"), }, { - path: "/analyze/:vname([a-zA-Z0-9]+)", - name: "analyze", - component: loadView("Game"), + 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;