-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathdevtoolsPanel.vue
More file actions
53 lines (46 loc) · 1.32 KB
/
devtoolsPanel.vue
File metadata and controls
53 lines (46 loc) · 1.32 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
<script setup lang="ts">
import { computed, onMounted, onScopeDispose, ref, watchEffect } from 'vue'
import { onlineManager, useQueryClient } from '@tanstack/vue-query'
import { TanstackQueryDevtoolsPanel } from '@tanstack/query-devtools'
import type { DevtoolsPanelOptions } from './types'
const props = defineProps<DevtoolsPanelOptions>()
const style = computed<any>(() => {
return {
height: '500px',
...props.style,
}
})
const div = ref<HTMLElement>()
const client = props.client || useQueryClient()
const devtools = new TanstackQueryDevtoolsPanel({
client,
queryFlavor: 'Vue Query',
version: '5',
onlineManager,
buttonPosition: 'bottom-left',
position: 'bottom',
initialIsOpen: true,
errorTypes: props.errorTypes,
styleNonce: props.styleNonce,
shadowDOMTarget: props.shadowDOMTarget,
hideDisabledQueries: props.hideDisabledQueries,
onClose: props.onClose,
theme: props.theme,
})
watchEffect(() => {
devtools.setOnClose(props.onClose ?? (() => {}))
devtools.setErrorTypes(props.errorTypes || [])
devtools.setTheme(props.theme)
})
let mounted = false
onMounted(() => {
devtools.mount(div.value as HTMLElement)
mounted = true
})
onScopeDispose(() => {
if (mounted) devtools.unmount()
})
</script>
<template>
<div :style="style" className="tsqd-parent-container" ref="div"></div>
</template>