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

devtoolsPanel.vue

50 lines1.3 KB

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