-
-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathDockStandalone.vue
More file actions
82 lines (74 loc) · 2.57 KB
/
DockStandalone.vue
File metadata and controls
82 lines (74 loc) · 2.57 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
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
<script setup lang="ts">
import type { DocksContext } from '@vitejs/devtools-kit/client'
import { computed, markRaw, ref, useTemplateRef, watch } from 'vue'
import { filterPopupDockEntry, isDockPopupEntryVisible } from '../state/popup'
import { PersistedDomViewsManager } from '../utils/PersistedDomViewsManager'
import DockEntriesWithCategories from './DockEntriesWithCategories.vue'
import FloatingElements from './FloatingElements.vue'
import VitePlus from './icons/VitePlus.vue'
import ViewBuiltinClientAuthNotice from './ViewBuiltinClientAuthNotice.vue'
import ViewEntry from './ViewEntry.vue'
const props = defineProps<{
context: DocksContext
}>()
const context = props.context
const viewsContainer = useTemplateRef<HTMLElement>('viewsContainer')
const persistedDoms = markRaw(new PersistedDomViewsManager(viewsContainer))
const isRpcTrusted = ref(context.rpc.isTrusted)
context.rpc.events.on('rpc:is-trusted:updated', (isTrusted) => {
isRpcTrusted.value = isTrusted
})
watch(
() => context.docks.entries,
() => {
context.docks.selectedId ||= context.docks.entries[0]?.id ?? null
},
{ immediate: true },
)
const groupedEntries = computed(() => {
if (isDockPopupEntryVisible())
return context.docks.groupedEntries
return filterPopupDockEntry(context.docks.groupedEntries)
})
function switchEntry(id: string | undefined) {
if (id) {
context.docks.switchEntry(id)
}
}
</script>
<template>
<div v-if="!isRpcTrusted" class="h-screen w-screen of-hidden">
<ViewBuiltinClientAuthNotice :context="context" />
</div>
<div v-else class="h-screen w-screen of-hidden grid cols-[max-content_1fr]">
<div class="border-r border-base flex flex-col">
<div class="p2 border-b border-base flex">
<VitePlus class="w-7 h-7 ma" />
</div>
<div class="transition duration-200 p2">
<DockEntriesWithCategories
:context="context"
:groups="groupedEntries"
:is-vertical="false"
:selected="context.docks.selected"
@select="(e) => switchEntry(e?.id)"
>
<template #separator>
<div class="border-base border-b w-full my-2" />
</template>
</DockEntriesWithCategories>
</div>
</div>
<div>
<div id="vite-devtools-views-container" ref="viewsContainer" class="pointer-events-auto" />
<ViewEntry
v-if="context.docks.selected && viewsContainer"
:key="context.docks.selected.id"
:entry="context.docks.selected"
:context
:persisted-doms="persistedDoms"
/>
</div>
</div>
<FloatingElements />
</template>