-
Notifications
You must be signed in to change notification settings - Fork 695
/
Copy pathrouter.js
100 lines (92 loc) · 2.29 KB
/
router.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { createRouter, createWebHashHistory } from 'vue-router'
import i18n from './i18n'
import RouterComponent from './views/Router'
import DocumentComponent from './views/Document'
import ExampleComponent from './views/Example'
import FullExampleComponent from './views/examples/Full'
import SimpleExampleComponent from './views/examples/Simple'
import AvatarExampleComponent from './views/examples/Avatar'
import DragExampleComponent from './views/examples/Drag'
import MultipleExampleComponent from './views/examples/Multiple'
import ChunkExampleComponent from './views/examples/Chunk'
import VuexExampleComponent from './views/examples/Vuex'
import TypescriptExampleComponent from './views/examples/Typescript'
import AsyncEventsExampleComponent from './views/examples/AsyncEvents'
// console.log(i18n)
let examples = [{
path: '',
component: FullExampleComponent,
},
{
path: 'full',
component: FullExampleComponent,
},
{
path: '',
component: SimpleExampleComponent,
},
{
path: 'simple',
component: SimpleExampleComponent,
},
{
path: 'avatar',
component: AvatarExampleComponent,
},
{
path: 'drag',
component: DragExampleComponent,
},
{
path: 'multiple',
component: MultipleExampleComponent,
},
{
path: 'chunk',
component: ChunkExampleComponent,
},
{
path: 'vuex',
component: VuexExampleComponent,
},
{
path: 'typescript',
component: TypescriptExampleComponent,
},
{
path: 'asyncevents',
component: AsyncEventsExampleComponent,
},
]
const router = createRouter({
history: createWebHashHistory(),
scrollBehavior(to, from, savedPosition) {
if (savedPosition) {
return savedPosition
} else if (to.hash) {
return { el: to.hash, top: document.querySelector('#header').offsetHeight }
} else {
return { x: 0, y: 0 }
}
},
routes: [{
path: '/:locale(' + i18n.global.availableLocales.join('|') + ')?',
component: RouterComponent,
children: [{
path: 'documents',
component: DocumentComponent,
},
{
path: 'examples',
component: ExampleComponent,
children: examples,
},
{
path: '',
component: ExampleComponent,
children: examples,
},
]
}, ]
})
export default router