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