11<script setup lang="ts">
22import type { ChatMessage } from ' @/api/chat.ts'
3+ import icon_copy_outlined from ' @/assets/embedded/icon_copy_outlined.svg'
34import { useI18n } from ' vue-i18n'
5+ import { useClipboard } from ' @vueuse/core'
46
57const props = defineProps <{
68 message? : ChatMessage
79}>()
810const { t } = useI18n ()
11+ const { copy } = useClipboard ({ legacy: true })
912
1013function clickAnalysis() {
1114 console .info (' analysis_record_id: ' + props .message ?.record ?.analysis_record_id )
1215}
1316function clickPredict() {
1417 console .info (' predict_record_id: ' + props .message ?.record ?.predict_record_id )
1518}
19+
20+ const copyCode = () => {
21+ const str = props .message ?.content || ' '
22+ copy (str as string )
23+ .then (function () {
24+ ElMessage .success (t (' embedded.copy_successful' ))
25+ })
26+ .catch (function () {
27+ ElMessage .error (t (' embedded.copy_failed' ))
28+ })
29+ }
1630 </script >
1731
1832<template >
@@ -24,6 +38,13 @@ function clickPredict() {
2438 {{ t('qa.data_predict') }}
2539 </span >
2640 <span style =" width : 100% " >{{ message?.content }}</span >
41+ <div style =" position : absolute ; right : 12px ; bottom : -24px " >
42+ <el-tooltip :offset =" 12" effect =" dark" :content =" t('datasource.copy')" placement =" top" >
43+ <el-icon style =" cursor : pointer " size =" 16" @click =" copyCode" >
44+ <icon _copy_outlined ></icon _copy_outlined >
45+ </el-icon >
46+ </el-tooltip >
47+ </div >
2748 </div >
2849</template >
2950
@@ -39,6 +60,7 @@ function clickPredict() {
3960 padding : 12px 16px ;
4061 color : rgba (31 , 35 , 41 , 1 );
4162 background : rgba (245 , 246 , 247 , 1 );
63+ position : relative ;
4264
4365 word-wrap : break-word ;
4466 white-space : pre-wrap ;
0 commit comments