TestControlCenter.vue
3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<template>
<div class="panel">
<div class="panel-head">
<div class="title-group">
<div class="title">测试案例</div>
<div class="subtitle">选择数据集并点击案例快速测试</div>
</div>
<el-select
v-model="selectedDatasetKey"
size="small"
class="dataset-select"
:loading="catalog.datasetLoading"
placeholder="选择数据集"
@change="onDatasetChange"
>
<el-option v-for="d in catalog.datasets" :key="d.key" :label="d.label" :value="d.key" />
</el-select>
</div>
<div class="list">
<div
v-for="(c, idx) in visibleCases"
:key="idx"
class="item"
tabindex="0"
@click="emitSend(c.message)"
@keydown.enter.prevent="emitSend(c.message)"
>
<div class="item-text">{{ c.message }}</div>
<div class="item-meta">
<span class="pill">{{ c.expected_intent }}</span>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { computed, ref, watchEffect } from "vue";
import { useCatalogStore } from "../../stores/catalog";
const emit = defineEmits<{ (e: "send", text: string): void }>();
const catalog = useCatalogStore();
const selectedDatasetKey = ref("");
const visibleCases = computed(() => catalog.cases.slice(0, 28));
watchEffect(() => {
if (catalog.datasets.length === 0 && !catalog.datasetLoading) {
catalog.refreshDatasets();
}
if (!selectedDatasetKey.value && catalog.datasetKey) {
selectedDatasetKey.value = catalog.datasetKey;
}
});
async function onDatasetChange(key: string): Promise<void> {
await catalog.switchDataset(key);
}
function emitSend(text: string): void {
const value = text.trim();
if (!value) return;
emit("send", value);
}
</script>
<style scoped>
.panel {
display: flex;
flex-direction: column;
background: transparent;
}
.panel-head {
padding: 4px 0 16px;
display: flex;
flex-direction: column;
gap: 12px;
border-bottom: 1px solid #f1f5f9;
margin-bottom: 16px;
}
.title-group {
display: flex;
flex-direction: column;
gap: 2px;
}
.title {
font-family: 'Plus Jakarta Sans', sans-serif;
font-weight: 800;
font-size: 15px;
color: #0f172a;
}
.subtitle {
font-size: 11px;
color: #64748b;
font-weight: 500;
}
.dataset-select {
width: 100%;
}
.dataset-select :deep(.el-input__wrapper) {
border-radius: 8px;
border: 1px solid #e2e8f0;
box-shadow: none !important;
height: 32px;
}
.dataset-select :deep(.el-input__wrapper):hover,
.dataset-select :deep(.el-input__wrapper.is-focus) {
border-color: #818cf8;
}
.list {
padding: 0;
display: flex;
flex-direction: column;
gap: 10px;
}
.item {
border-radius: 10px;
padding: 12px;
background: #ffffff;
border: 1px solid #e2e8f0;
cursor: pointer;
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}
.item:hover,
.item:focus {
outline: none;
border-color: #c7d2fe;
background: #faf5ff;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}
.item:active {
transform: translateY(0);
}
.item-text {
font-size: 13px;
line-height: 1.45;
font-weight: 500;
color: #1e293b;
word-break: break-word;
}
.item-meta {
margin-top: 8px;
display: flex;
gap: 8px;
flex-wrap: wrap;
}
.pill {
font-size: 11px;
padding: 2px 8px;
border-radius: 6px;
font-weight: 600;
color: #4f46e5;
background: #eeebff;
border: 1px solid #e0dbff;
}
</style>