This commit is contained in:
Surya Paolo
2023-12-29 01:27:59 +01:00
parent 42d37d8209
commit 2083655e99
8 changed files with 82 additions and 22 deletions

View File

@@ -3,6 +3,7 @@ import {
} from 'vue-router'
import { cfgrouter } from './route-config'
import { useGlobalStore } from '@src/store/globalStore';
export default function (/* { store, ssrContext } */) {
const routermode = process.env.VUE_ROUTER_MODE === 'history' ? createWebHistory : createWebHashHistory
@@ -11,15 +12,32 @@ export default function (/* { store, ssrContext } */) {
? createMemoryHistory
: routermode
return createRouter({
const router = createRouter({
scrollBehavior: () => ({ left: 0, top: 0 }),
routes: cfgrouter.getmenu(),
// Leave this as is and make changes in quasar.conf.js instead!
// quasar.conf.js -> build -> vueRouterMode
// quasar.conf.js -> build -> publicPath
history: createHistory(
process.env.MODE === 'ssr' ? void 0 : process.env.VUE_ROUTER_BASE,
),
})
});
// Add the beforeEach hook
router.beforeEach((to, from, next) => {
// Execute your command before each navigation
// executeCommand();
const globalStore = useGlobalStore()
try {
globalStore.editOn = false
} catch(e) {
}
// Continue with the navigation
next();
});
return router;
}