+
+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();
+ // 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;