This repository has been archived by the owner on Jun 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
router.ts
78 lines (75 loc) · 2.16 KB
/
router.ts
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
import {createRouter, createWebHistory, LocationQuery} from 'vue-router'
import Home from './Home.vue'
import CompositionHome from './CompositionHome.vue'
import {ParsedQuery, QueryParameterDefinitions} from "@/library";
const routes = [
{
path: '/composition-api',
name: 'composition-api',
meta: {
query: {
num: 'int:10',
check: 'bool:',
option: 'array:',
search: 'string:',
option2: 'commaarray:',
option3: 'spacearray:',
unusedOption: 'string:test'
},
querySettings: {
onInit: (props: QueryParameterDefinitions) => {
console.log('onInit', props)
props['search'].defaultValue =
window.localStorage.getItem('searchDefaultValue')
return props
},
onLoad: (params: ParsedQuery) => {
console.log('onLoad', params)
return params
},
onChange: (query: LocationQuery, queryValues: ParsedQuery) => {
window.localStorage.setItem('searchDefaultValue', queryValues.search || '')
console.log('onChange', query, queryValues)
}
}
},
component: CompositionHome
},
{
path: '/',
name: 'home',
meta: {
query: {
num: 'int:10',
check: 'bool:',
option: 'array:',
search: 'string:',
option2: 'commaarray:',
option3: 'spacearray:',
unusedOption: 'string:test'
},
querySettings: {
onInit: (props: QueryParameterDefinitions) => {
console.log('onInit', props)
props['search'].defaultValue =
window.localStorage.getItem('searchDefaultValue')
return props
},
onLoad: (params: ParsedQuery) => {
console.log('onLoad', params)
return params
},
onChange: (query: LocationQuery, queryValues: ParsedQuery) => {
window.localStorage.setItem('searchDefaultValue', queryValues.search || '')
console.log('onChange', query, queryValues)
}
}
},
component: Home
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
export default router