IntentDetail.vue 1.76 KB
<template>
  <el-card shadow="never" class="detail">
    <template #header>
      <div class="h">
        <div class="name">{{ intent.name }}</div>
        <el-tag type="info" effect="light">{{ intent.domain }}</el-tag>
      </div>
    </template>

    <div class="section">
      <div class="k">tree_text</div>
      <div class="v">{{ intent.tree_text }}</div>
    </div>

    <div class="section">
      <div class="k">embed_text</div>
      <div class="v mono">{{ intent.embed_text }}</div>
    </div>

    <div class="section">
      <div class="k">示例</div>
      <div class="chips">
        <el-tag
          v-for="ex in intent.examples"
          :key="ex"
          effect="plain"
          type="info"
          class="chip"
          @click="onUseExample(ex)"
        >
          {{ ex }}
        </el-tag>
      </div>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import type { IntentItem } from "../../types";

defineProps<{ intent: IntentItem }>();

const emit = defineEmits<{ (e: "use-example", text: string): void }>();

function onUseExample(text: string): void {
  emit("use-example", text);
}
</script>

<style scoped>
.detail {
  border-radius: 12px;
}
.h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section {
  margin: 10px 0;
}
.k {
  color: var(--el-text-color-secondary);
  margin-bottom: 4px;
}
.v {
  color: var(--el-text-color-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  max-width: 100%;
  cursor: pointer;
}
</style>