Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

devtoolsPanel.vue

52 lines1.4 KB

1<script setup lang="ts">
2import { TanstackQueryDevtoolsPanel } from '@tanstack/query-devtools'
3import { onlineManager, useQueryClient } from '@tanstack/vue-query'
4import { computed, onMounted, onScopeDispose, ref, watchEffect } from 'vue'
5import type { DevtoolsPanelOptions } from './types'
6​
7const props = defineProps<DevtoolsPanelOptions>()
8const style = computed<any>(() => {
9 return {
10 height: '100%',
11 display: 'flex',
12 flexDirection: 'column',
13 ...props.style,
14 }
15})
16​
17const div = ref<HTMLElement>()
18const client = props.client || useQueryClient()
19const devtools = new TanstackQueryDevtoolsPanel({
20 client,
21 queryFlavor: 'Vue Query',
22 version: '5',
23 onlineManager,
24 buttonPosition: 'bottom-left',
25 position: 'bottom',
26 initialIsOpen: true,
27 errorTypes: props.errorTypes,
28 shadowDOMTarget: props.shadowDOMTarget,
29 trustedTypesPolicy: props.trustedTypesPolicy,
30 hideDisabledQueries: props.hideDisabledQueries,
31 onClose: props.onClose,
32 theme: props.theme,
33})
34​
35watchEffect(() => {
36 devtools.setClient(props.client || client)
37 devtools.setOnClose(props.onClose ?? (() => {}))
38 devtools.setErrorTypes(props.errorTypes || [])
39 devtools.setTheme(props.theme)
40})
41​
42onMounted(() => {
43 devtools.mount(div.value as HTMLElement)
44 onScopeDispose(() => {
45 devtools.unmount()
46 })
47})
48</script>
49​
50<template>
51 <div :style="style" class="tsqd-parent-container" ref="div"></div>
52</template>