chore: 优化部份实现
This commit is contained in:
@@ -4,15 +4,6 @@ export function useChat() {
|
||||
const historyStore = useHistoryStore()
|
||||
|
||||
function addChat(message: string, args?: { reversal?: boolean; error?: boolean; options?: Chat.ChatOptions }) {
|
||||
if (historyStore.historyChat.length === 0) {
|
||||
historyStore.addHistory({
|
||||
title: message,
|
||||
isEdit: false,
|
||||
data: [],
|
||||
})
|
||||
historyStore.chooseHistory(historyStore.historyChat.length - 1)
|
||||
}
|
||||
|
||||
historyStore.addChat({
|
||||
dateTime: new Date().toLocaleString(),
|
||||
message,
|
||||
|
||||
@@ -34,14 +34,12 @@ function handleEnter(index: number, isEdit: boolean, event: KeyboardEvent) {
|
||||
class="relative flex items-center gap-3 px-3 py-3 break-all rounded-md cursor-pointer bg-neutral-50 pr-14 hover:bg-neutral-100 group"
|
||||
@click="handleSelect(index)"
|
||||
>
|
||||
<span>
|
||||
<span :class="[{ 'text-[#4b9e5f]': historyStore.active === index }]">
|
||||
<SvgIcon icon="ri:message-3-line" />
|
||||
</span>
|
||||
<div class="relative flex-1 overflow-hidden break-all text-ellipsis whitespace-nowrap">
|
||||
<NInput
|
||||
v-if="item.isEdit"
|
||||
v-model:value="item.title"
|
||||
size="tiny"
|
||||
v-if="item.isEdit" v-model:value="item.title" size="tiny"
|
||||
@keypress="handleEnter(index, false, $event)"
|
||||
/>
|
||||
<span v-else>{{ item.title }}</span>
|
||||
|
||||
Reference in New Issue
Block a user