Skip to content

Commit 29b75a9

Browse files
authored
测试结果展示框 增加 放大弹窗功能 (#90)
Co-authored-by: MacX
1 parent f4374df commit 29b75a9

File tree

2 files changed

+74
-7
lines changed

2 files changed

+74
-7
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<template>
2+
<Teleport to="body">
3+
<div v-if="modelValue" class="fixed inset-0 theme-mask z-[60] flex items-center justify-center overflow-y-auto">
4+
<div class="relative theme-manager-container min-h-[50vh] max-h-[90vh] w-[90vw] m-4 flex flex-col">
5+
<!-- 标题栏 -->
6+
<div class="flex items-center justify-between p-4 border-b theme-manager-border">
7+
<h3 class="text-lg font-semibold theme-manager-text">{{ title }}</h3>
8+
<button
9+
@click="$emit('update:modelValue', false)"
10+
class="theme-manager-text-secondary hover:theme-manager-text transition-colors text-xl"
11+
>
12+
×
13+
</button>
14+
</div>
15+
16+
<!-- 内容区域 -->
17+
<div class="flex-1 p-4 overflow-auto">
18+
<slot></slot>
19+
</div>
20+
</div>
21+
</div>
22+
</Teleport>
23+
</template>
24+
25+
<script setup lang="ts">
26+
defineProps({
27+
modelValue: {
28+
type: Boolean,
29+
required: true
30+
},
31+
title: {
32+
type: String,
33+
default: ''
34+
}
35+
})
36+
37+
defineEmits(['update:modelValue'])
38+
</script>
39+
40+
<style scoped>
41+
.overflow-auto {
42+
scrollbar-width: none;
43+
-ms-overflow-style: none;
44+
}
45+
.overflow-auto::-webkit-scrollbar {
46+
display: none;
47+
}
48+
</style>

packages/ui/src/components/OutputPanel.vue

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,24 @@
66
<div v-else-if="!hideTitle" class="text-lg font-semibold theme-text">{{ t('output.title') }}</div>
77
<div v-else></div>
88

9-
<button
10-
v-if="contentTokens.length > 0 && !isStreaming"
11-
@click="copySelectedText"
12-
class="px-3 py-1.5 theme-button-secondary flex items-center space-x-2"
13-
>
14-
<span>{{ t('prompt.copy') }}</span>
15-
</button>
9+
<div class="flex items-center space-x-2">
10+
<button
11+
v-if="contentTokens.length > 0 && !isStreaming"
12+
@click="copySelectedText"
13+
class="px-3 py-1.5 theme-button-secondary flex items-center space-x-2"
14+
>
15+
<span>{{ t('prompt.copy') }}</span>
16+
</button>
17+
<button
18+
@click="isFullscreen = true"
19+
class="px-3 py-1.5 theme-button-secondary flex items-center space-x-2"
20+
:title="t('output.expand')"
21+
>
22+
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
23+
<path stroke-linecap="round" stroke-linejoin="round" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4" />
24+
</svg>
25+
</button>
26+
</div>
1627
</div>
1728

1829
<div class="flex-1 min-h-0 relative">
@@ -44,6 +55,12 @@
4455
</div>
4556
</div>
4657
</div>
58+
<FullscreenDialog v-model="isFullscreen" :title="resultTitle || t('output.title')">
59+
<div class="h-full theme-input whitespace-pre-wrap">
60+
<MarkdownRenderer v-if="props.enableMarkdown" :content="displayContent" />
61+
<span v-else v-text="displayContent" class="theme-text"></span>
62+
</div>
63+
</FullscreenDialog>
4764
</template>
4865

4966
<script setup lang="ts">
@@ -53,12 +70,14 @@ import { useToast } from '../composables/useToast'
5370
import { useAutoScroll } from '../composables/useAutoScroll'
5471
import { useClipboard } from '../composables/useClipboard'
5572
import MarkdownRenderer from './MarkdownRenderer.vue'
73+
import FullscreenDialog from './FullscreenDialog.vue'
5674

5775
const { t } = useI18n()
5876
const toast = useToast()
5977
const { copyText } = useClipboard()
6078
const contentTokens = ref<string[]>([])
6179
const isStreaming = ref(false)
80+
const isFullscreen = ref(false)
6281

6382
// 使用自动滚动组合式函数
6483
const { elementRef: resultContainer, onContentChange, forceScrollToBottom, shouldAutoScroll } = useAutoScroll<HTMLDivElement>({

0 commit comments

Comments
 (0)