-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Expand file tree
/
Copy pathdevtools.vue
More file actions
48 lines (41 loc) · 1.31 KB
/
devtools.vue
File metadata and controls
48 lines (41 loc) · 1.31 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
<script setup lang="ts">
import { onMounted, onScopeDispose, ref, watchEffect } from 'vue'
import { onlineManager, useQueryClient } from '@tanstack/vue-query'
import { TanstackQueryDevtools } from '@tanstack/query-devtools'
import type { DevtoolsOptions } from './types'
const props = defineProps<DevtoolsOptions>()
const div = ref<HTMLElement>()
const client = props.client || useQueryClient()
const devtools = new TanstackQueryDevtools({
client,
queryFlavor: 'Vue Query',
version: '5',
onlineManager,
buttonPosition: props.buttonPosition,
position: props.position,
initialIsOpen: props.initialIsOpen,
errorTypes: props.errorTypes,
styleNonce: props.styleNonce,
shadowDOMTarget: props.shadowDOMTarget,
hideDisabledQueries: props.hideDisabledQueries,
theme: props.theme,
})
watchEffect(() => {
devtools.setButtonPosition(props.buttonPosition || 'bottom-right')
devtools.setPosition(props.position || 'bottom')
devtools.setInitialIsOpen(props.initialIsOpen)
devtools.setErrorTypes(props.errorTypes || [])
devtools.setTheme(props.theme || 'system')
})
let mounted = false
onMounted(() => {
devtools.mount(div.value as HTMLElement)
mounted = true
})
onScopeDispose(() => {
if (mounted) devtools.unmount()
})
</script>
<template>
<div className="tsqd-parent-container" ref="div"></div>
</template>