|
1 | | -<template> |
2 | | - <div class="reasoning"> |
3 | | - <button class="rc-head" @click="isExpanded = !isExpanded"> |
4 | | - <svg class="rc-chevron" :class="{ open: isExpanded }" viewBox="0 0 16 16" fill="none"> |
5 | | - <path d="M6 4l4 4-4 4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/> |
6 | | - </svg> |
7 | | - <span class="rc-title">思考过程</span> |
8 | | - </button> |
9 | | - <div v-show="isExpanded" class="rc-body"> |
10 | | - <pre class="rc-text">{{ content.content }}</pre> |
11 | | - </div> |
12 | | - </div> |
13 | | -</template> |
14 | | - |
15 | 1 | <script setup lang="ts"> |
16 | 2 | import { ref, watch } from 'vue' |
17 | 3 |
|
18 | | -const props = defineProps<{ content: any }>() |
| 4 | +defineOptions({ name: 'ConversationReasoningContent' }) |
| 5 | +
|
| 6 | +const props = defineProps<{ content: { content?: string | null; status?: string } }>() |
19 | 7 | const isExpanded = ref(true) |
20 | 8 | let prevStatus = props.content.status |
21 | 9 |
|
22 | | -watch(() => props.content.status, (status) => { |
23 | | - if (prevStatus === 'RUNNING' && status !== 'RUNNING') { |
24 | | - isExpanded.value = false |
25 | | - } |
26 | | - prevStatus = status |
27 | | -}) |
| 10 | +watch( |
| 11 | + () => props.content.status, |
| 12 | + (status) => { |
| 13 | + if (prevStatus === 'RUNNING' && status !== 'RUNNING') { |
| 14 | + isExpanded.value = false |
| 15 | + } |
| 16 | + prevStatus = status |
| 17 | + }, |
| 18 | +) |
28 | 19 | </script> |
29 | 20 |
|
30 | | -<style scoped lang="scss"> |
31 | | -.reasoning { |
32 | | - width: 100%; |
33 | | - margin-bottom: 8px; |
34 | | -} |
35 | | -
|
36 | | -.rc-head { |
37 | | - display: inline-flex; |
38 | | - align-items: center; |
39 | | - gap: 6px; |
40 | | - padding: 3px 0; |
41 | | - border: none; |
42 | | - background: none; |
43 | | - cursor: pointer; |
44 | | - font-family: inherit; |
45 | | - color: var(--t3, #909399); |
46 | | - transition: color 0.15s; |
47 | | -} |
48 | | -
|
49 | | -.rc-head:hover { |
50 | | - color: var(--t1, #303133); |
51 | | -} |
52 | | -
|
53 | | -.rc-chevron { |
54 | | - width: 14px; |
55 | | - height: 14px; |
56 | | - flex-shrink: 0; |
57 | | - transition: transform 0.15s; |
58 | | -} |
59 | | -
|
60 | | -.rc-chevron.open { |
61 | | - transform: rotate(90deg); |
62 | | -} |
63 | | -
|
64 | | -.rc-title { |
65 | | - font-size: 13px; |
66 | | - font-weight: 500; |
67 | | - color: var(--t2, #606266); |
68 | | -} |
69 | | -
|
70 | | -.rc-body { |
71 | | - padding: 6px 0 4px 8px; |
72 | | -} |
| 21 | +<template> |
| 22 | + <!-- 展开或收起思考内容 --> |
| 23 | + <MkCollapse v-model:expanded="isExpanded" indicator-position="after" trigger-class="group text-N500! mb-2 w-fit hover:text-N900!"> |
| 24 | + <template #indicator="{ expanded }"> |
| 25 | + <MkIcon |
| 26 | + name="icon_right_outlined" |
| 27 | + :size="12" |
| 28 | + class="transition-transform text-N500! group-hover:text-N900!" |
| 29 | + :class="{ 'rotate-90': expanded }" |
| 30 | + /> |
| 31 | + </template> |
| 32 | + <template #label> |
| 33 | + <MkIcon name="icon_two-ellipses_outlined" /> |
| 34 | + <span class="-mx-1">思考中</span> |
| 35 | + </template> |
| 36 | + <div class="text-N500! whitespace-pre-wrap break-words"> |
| 37 | + {{ content.content }} |
| 38 | + </div> |
| 39 | + </MkCollapse> |
| 40 | +</template> |
73 | 41 |
|
74 | | -.rc-text { |
75 | | - margin: 0; |
76 | | - font-size: 13px; |
77 | | - line-height: 1.65; |
78 | | - color: var(--t2, #606266); |
79 | | - white-space: pre-wrap; |
80 | | - word-break: break-word; |
81 | | - font-family: inherit; |
82 | | -} |
83 | | -</style> |
| 42 | +<style scoped lang="scss"></style> |
0 commit comments