forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
55 lines (46 loc) · 1.34 KB
/
index.js
File metadata and controls
55 lines (46 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* global gtag */
import { createRouter, createMemoryHistory, createWebHistory } from 'vue-router'
import routes from './routes'
/*
* If not building with SSR mode, you can
* directly export the Router instantiation;
*
* The function below can be async too; either use
* async/await or return a Promise which resolves
* with the Router instance.
*/
export default function () {
const createHistory = process.env.SERVER
? createMemoryHistory
: createWebHistory
const Router = createRouter({
scrollBehavior: (to, _, savedPosition) => (
to.hash.length > 1
? false
: (savedPosition || { left: 0, top: 0 })
),
routes,
// Leave this as is and make changes in quasar.config.js instead!
// quasar.config.js -> build -> vueRouterMode
// quasar.config.js -> build -> publicPath
history: createHistory(process.env.MODE === 'ssr' ? void 0 : process.env.VUE_ROUTER_BASE)
})
Router.beforeEach((to, _, next) => {
if (to.fullPath.startsWith('/quasar-cli/') === true) {
next({
path: to.fullPath.replace('/quasar-cli/', '/quasar-cli-webpack/'),
query: to.query,
hash: to.hash
})
}
else {
next()
}
})
process.env.CLIENT === true && Router.afterEach(to => {
gtag('config', 'UA-6317975-6', {
page_path: to.path
})
})
return Router
}