@@ -3,7 +3,10 @@ import { debug } from '@tap/api/src/core/api-calls'
33import { fetchApiServerToken } from ' @tap/api/src/core/api-client'
44import { fetchWorkers } from ' @tap/api/src/core/workers'
55import VCodeEditor from ' @tap/component/src/base/VCodeEditor.vue'
6+ import { IconButton } from ' @tap/component/src/icon-button'
67import { useI18n } from ' @tap/i18n'
8+ import { copyToClipboard } from ' @tap/shared/src/util'
9+ import { useDark } from ' @vueuse/core'
710import {
811 computed ,
912 inject ,
@@ -33,6 +36,7 @@ const props = withDefaults(defineProps<Props>(), {
3336})
3437const form = inject <Ref <any >>(' form' )!
3538const { t } = useI18n ()
39+ const isDark = useDark ()
3640const workerStatus = ref (' ' )
3741const token = ref <Record <string , any >>({})
3842const templateType = ref (' java' )
@@ -42,6 +46,10 @@ const debugHttpInfo = ref<Record<string, any>>({})
4246const templates = ref <Record <string , string >>({})
4347const intervalId = ref ()
4448const loading = ref (false )
49+ const isFullscreen = ref (false )
50+ const resultRef = ref <HTMLElement | null >(null )
51+ const titleRef = ref <HTMLElement | null >(null )
52+ const jsonPrettyHeight = ref (280 )
4553
4654const urlsMap = computed (() => {
4755 return props .urlList .reduce ((acc : Record <string , string >, item ) => {
@@ -64,6 +72,22 @@ watch(
6472 },
6573)
6674
75+ watch (isFullscreen , (fullscreen ) => {
76+ if (fullscreen && titleRef .value ) {
77+ setTimeout (() => {
78+ const titleElement = titleRef .value !
79+ const titleHeight = titleElement .offsetHeight
80+ const style = getComputedStyle (titleElement )
81+ const marginTop = Number .parseFloat (style .marginTop )
82+ const marginBottom = Number .parseFloat (style .marginBottom )
83+ const totalHeight = titleHeight + marginTop + marginBottom
84+ jsonPrettyHeight .value = window .innerHeight - totalHeight - 32
85+ }, 100 )
86+ } else {
87+ jsonPrettyHeight .value = 280
88+ }
89+ })
90+
6791onBeforeUnmount (() => {
6892 intervalId .value && clearTimeout (intervalId .value )
6993})
@@ -237,6 +261,39 @@ const parseValue = (key: string, value: any, defaultVal?: any) => {
237261 }
238262}
239263
264+ function enterFullscreen(element : HTMLElement ) {
265+ if (element .requestFullscreen ) {
266+ element .requestFullscreen ()
267+ } else if (element .webkitRequestFullscreen ) {
268+ // Safari
269+ element .webkitRequestFullscreen ()
270+ } else if (element .msRequestFullscreen ) {
271+ // IE11
272+ element .msRequestFullscreen ()
273+ }
274+ }
275+
276+ function exitFullscreen() {
277+ if (document .exitFullscreen ) {
278+ document .exitFullscreen ()
279+ }
280+ }
281+
282+ const toggleFullscreen = () => {
283+ if (isFullscreen .value ) {
284+ exitFullscreen ()
285+ } else {
286+ enterFullscreen (resultRef .value ! )
287+ }
288+
289+ isFullscreen .value = ! isFullscreen .value
290+ }
291+
292+ const handleCopy = () => {
293+ copyToClipboard (JSON .stringify (debugResult .value , null , 2 ))
294+ ElMessage .success (t (' public_message_copy_success' ))
295+ }
296+
240297onMounted (() => {
241298 reflshToken ()
242299 getWorkers ()
@@ -268,30 +325,53 @@ onMounted(() => {
268325 >{{ $t('public_button_submit') }}
269326 </ElButton >
270327 </div >
271- <div class =" data-server-panel__title mt-4 mb-3" >
272- {{ $t('packages_business_data_server_drawer_fanhuijieguo') }}
273- <el-tag
274- v-if =" debugHttpInfo.httpCode"
275- style =" margin-left : 0.5rem "
276- :type ="
277- debugHttpInfo.httpCode &&
278- debugHttpInfo.httpCode >= 200 &&
279- debugHttpInfo.httpCode < 300
280- ? 'success'
281- : 'warning'
282- "
283- size =" small"
284- >{{ debugHttpInfo.httpCode }}</el-tag
328+ <div
329+ ref =" resultRef"
330+ style =" background-color : var (--el-bg-color )"
331+ :class =" { 'px-4': isFullscreen }"
332+ >
333+ <div
334+ ref =" titleRef"
335+ class =" data-server-panel__title mt-4 mb-3 flex align-center gap-2"
336+ style =" --btn-space : 0 "
285337 >
338+ {{ $t('packages_business_data_server_drawer_fanhuijieguo') }}
339+ <el-tag
340+ v-if =" debugHttpInfo.httpCode"
341+ :type ="
342+ debugHttpInfo.httpCode &&
343+ debugHttpInfo.httpCode >= 200 &&
344+ debugHttpInfo.httpCode < 300
345+ ? 'success'
346+ : 'warning'
347+ "
348+ size =" small"
349+ >{{ debugHttpInfo.httpCode }}</el-tag
350+ >
351+ <div class =" flex-1" />
352+
353+ <el-button text size =" small" @click =" handleCopy" >
354+ <template #icon >
355+ <i-lucide-copy />
356+ </template >
357+ </el-button >
358+
359+ <IconButton size="small" @click =" toggleFullscreen " >{{
360+ isFullscreen ? 'suoxiao' : 'fangda'
361+ }}</IconButton >
362+ </div >
363+ <div class =" bg-light rounded-xl p-2 pr-0 overflow-auto" >
364+ <VueJsonPretty
365+ :data =" debugResult "
366+ :height =" jsonPrettyHeight "
367+ virtual
368+ show-icon
369+ :show-line =" false "
370+ :theme =" isDark ? ' dark' : ' light' "
371+ />
372+ </div >
286373 </div >
287- <VueJsonPretty
288- class="bg-light rounded-xl p-2 pr-0"
289- :data =" debugResult "
290- :height =" 280 "
291- virtual
292- show-icon
293- :show-line =" false "
294- />
374+
295375 <div class =" position-relative mt-4" >
296376 <div
297377 class =" fs-7 fw-sub font-color-dark flex align-center"
0 commit comments