-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathindex.vue
79 lines (73 loc) · 1.85 KB
/
index.vue
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
<script setup lang="ts">
import { ref, watch } from 'vue'
import { onRpcConnected, rpc } from '@vue/devtools-core'
import About from './components/About.vue'
import Routes from './components/routes/Index.vue'
import Timeline from './components/timeline/Index.vue'
import { registerVirtualRouter } from '~/composables/virtual-router'
import { createCustomInspectorStateContext } from '~/composables/custom-inspector-state'
const props = defineProps<{
id: string
savedSelectedId?: string
}>()
const emit = defineEmits<{
(e: 'onSelectId', id: string): void
}>()
const inspectorState = createCustomInspectorStateContext()
const loading = ref(false)
const { VirtualRouterView, restoreRouter } = registerVirtualRouter([
{
path: '/routes',
name: 'Routes',
component: Routes,
icon: 'i-carbon-tree-view-alt',
},
{
path: '/timeline',
name: 'Timeline',
component: Timeline,
icon: 'i-mdi:timeline-clock-outline',
},
{
path: '/about',
name: 'About',
component: About,
icon: 'i-ri-route-line',
},
], {
defaultRoutePath: '/routes',
})
function getInspectorInfo() {
loading.value = true
onRpcConnected(() => {
rpc.value.getInspectorInfo(props.id).then((payload) => {
if (!payload) {
return
}
const state = {
homepage: payload?.homepage,
id: payload?.id,
label: payload?.label,
logo: payload?.logo,
timelineLayerIds: payload?.timelineLayers.map(item => item.id),
}
inspectorState.value = state
restoreRouter()
loading.value = false
})
})
}
watch(() => props.id, (v) => {
if (v) {
getInspectorInfo()
}
})
const handleSelectId = (id: string) => {
emit('onSelectId', id)
}
</script>
<template>
<div h-full w-full>
<VirtualRouterView :saved-selected-id="savedSelectedId" @on-select-id="handleSelectId" />
</div>
</template>