X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Frouter.js;h=599cfcb3dce5672dd2fd74207f491bedcfe7bca3;hb=dac395887d96e2d642b209c6db6aaacc3ffacb34;hp=380ccc6cd2575301da919dd85be5a487d7fa20a9;hpb=92a523d1a74cbabcfd7d6ade45f25fa622815f0b;p=vchess.git diff --git a/client/src/router.js b/client/src/router.js index 380ccc6c..599cfcb3 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"; @@ -46,24 +46,35 @@ const router = new Router({ localStorage["myname"] = res.name; localStorage["myid"] = res.id; } - next("/"); + // 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 }, + { + path: "/mygames", + name: "mygames", + component: loadView("MyGames"), + }, { path: "/game/:id", name: "game", component: loadView("Game"), }, + { + path: "/analyze/:vname([a-zA-Z0-9]+)", + name: "analyze", + component: loadView("Analyze"), + }, { path: "/about", name: "about", component: loadView("About"), }, - // TODO: myGames, problemId: https://router.vuejs.org/guide/essentials/dynamic-matching.html ] }); @@ -75,9 +86,6 @@ router.beforeEach((to, from, next) => { store.state.conn.send(JSON.stringify({code: "pagechange", page: to.path})); } next(); - // TODO?: redirect to current game (through GameStorage.getCurrent()) if any? - // (and if the URL doesn't already match it) (use next("/game/GID")) - //https://router.vuejs.org/guide/advanced/navigation-guards.html#global-before-guards }); export default router;