【解决todo】Chat message 增加刷新和编辑

This commit is contained in:
cherishsince 2024-05-24 10:32:08 +08:00
parent f1beb488ce
commit 03c6a6ce59
2 changed files with 39 additions and 3 deletions

View File

@ -43,6 +43,12 @@
<el-button class="btn-cus" link @click="onDelete(item.id)">
<img class="btn-image" src="@/assets/ai/delete.svg" style="height: 17px;margin-right: 12px;"/>
</el-button>
<el-button class="btn-cus" link @click="onRefresh(item)">
<el-icon size="17"><RefreshRight /></el-icon>
</el-button>
<el-button class="btn-cus" link @click="onEdit(item)">
<el-icon size="17"><Edit /></el-icon>
</el-button>
</div>
</div>
</div>
@ -59,7 +65,7 @@ import MarkdownView from "@/components/MarkdownView/index.vue";
import {ChatMessageApi, ChatMessageVO} from "@/api/ai/chat/message";
import {useClipboard} from "@vueuse/core";
import {PropType} from "vue";
import {ArrowDownBold} from "@element-plus/icons-vue";
import {ArrowDownBold, Edit, RefreshRight} from "@element-plus/icons-vue";
const {copy} = useClipboard() // copy
// ()
@ -125,6 +131,20 @@ const onDelete = async (id) => {
emits('onDeleteSuccess')
}
/**
* 刷新
*/
const onRefresh = async (message: ChatMessageVO) => {
emits('onRefresh', message)
}
/**
* 编辑
*/
const onEdit = async (message: ChatMessageVO) => {
emits('onEdit', message)
}
/**
* 回到底部
*/
@ -151,7 +171,7 @@ watch(list, async (newValue, oldValue) => {
defineExpose({scrollToBottom, handlerGoTop})
// emits
const emits = defineEmits(['onDeleteSuccess'])
const emits = defineEmits(['onDeleteSuccess', 'onRefresh', 'onEdit'])
// onMounted
onMounted(async () => {

View File

@ -39,7 +39,9 @@
<Message v-if="!listLoading && list.length > 0"
ref="messageRef"
:list="list"
@on-delete-success="handlerMessageDelete" />
@on-delete-success="handlerMessageDelete"
@on-edit="handlerMessageEdit"
@on-refresh="handlerMessageRefresh"/>
</div>
</div>
</el-main>
@ -513,6 +515,20 @@ const handlerMessageDelete = async () => {
await getMessageList()
}
/**
* 编辑 message
*/
const handlerMessageEdit = async (message: ChatMessageVO) => {
prompt.value = message.content
}
/**
* 编辑 message
*/
const handlerMessageRefresh = async (message: ChatMessageVO) => {
await doSend(message.content)
}
/**
* 回到顶部
*/