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

devtoolsPanel.vue

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