|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
<script setup lang='ts'>
|
|
|
|
|
import { ref } from 'vue'
|
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
|
import { NDropdown } from 'naive-ui'
|
|
|
|
|
import AvatarComponent from './Avatar.vue'
|
|
|
|
|
import TextComponent from './Text.vue'
|
|
|
|
@ -29,7 +29,10 @@ const { iconRender } = useIconRender()
|
|
|
|
|
|
|
|
|
|
const textRef = ref<HTMLElement>()
|
|
|
|
|
|
|
|
|
|
const options = [
|
|
|
|
|
const asRawText = ref(props.inversion)
|
|
|
|
|
|
|
|
|
|
const options = computed(() => {
|
|
|
|
|
const common = [
|
|
|
|
|
{
|
|
|
|
|
label: t('chat.copy'),
|
|
|
|
|
key: 'copyText',
|
|
|
|
@ -40,13 +43,27 @@ const options = [
|
|
|
|
|
key: 'delete',
|
|
|
|
|
icon: iconRender({ icon: 'ri:delete-bin-line' }),
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
if (!props.inversion) {
|
|
|
|
|
common.unshift({
|
|
|
|
|
label: asRawText.value ? t('chat.preview') : t('chat.showRawText'),
|
|
|
|
|
key: 'toggleRenderType',
|
|
|
|
|
icon: iconRender({ icon: asRawText.value ? 'ic:outline-code-off' : 'ic:outline-code' }),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleSelect(key: 'copyRaw' | 'copyText' | 'delete') {
|
|
|
|
|
return common
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
function handleSelect(key: 'copyText' | 'delete' | 'toggleRenderType') {
|
|
|
|
|
switch (key) {
|
|
|
|
|
case 'copyText':
|
|
|
|
|
copyText({ text: props.text ?? '' })
|
|
|
|
|
return
|
|
|
|
|
case 'toggleRenderType':
|
|
|
|
|
asRawText.value = !asRawText.value
|
|
|
|
|
return
|
|
|
|
|
case 'delete':
|
|
|
|
|
emit('delete')
|
|
|
|
|
}
|
|
|
|
@ -79,6 +96,7 @@ function handleRegenerate() {
|
|
|
|
|
:error="error"
|
|
|
|
|
:text="text"
|
|
|
|
|
:loading="loading"
|
|
|
|
|
:as-raw-text="asRawText"
|
|
|
|
|
/>
|
|
|
|
|
<div class="flex flex-col">
|
|
|
|
|
<button
|
|
|
|
|