Skip to content

Commit 5cb21a6

Browse files
fix: clear history
1 parent bf657ac commit 5cb21a6

File tree

6 files changed

+44
-25
lines changed

6 files changed

+44
-25
lines changed

ui/src/views/chat/component/HistoryPanel.vue

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040
<div v-show="!isPcCollapse" class="flex-between p-8 pb-0 color-secondary mt-8">
4141
<span>{{ $t('chat.history') }}</span>
4242
<el-tooltip effect="dark" :content="$t('chat.clearChat')" placement="right">
43-
<!-- // TODO: 清空 -->
44-
<el-button
45-
text
46-
@click="clearChat"
47-
>
43+
<el-button text @click.stop="clearChat">
4844
<el-icon>
4945
<Delete />
5046
</el-icon>
@@ -118,8 +114,7 @@
118114
<div class="flex-between w-full">
119115
<span>{{ $t('chat.history') }}</span>
120116
<el-tooltip effect="dark" :content="$t('chat.clearChat')" placement="right">
121-
<!-- // TODO: 清空 -->
122-
<el-button text>
117+
<el-button text @click.stop="clearChat">
123118
<el-icon>
124119
<Delete />
125120
</el-icon>
@@ -178,16 +173,14 @@
178173
import { ref } from 'vue'
179174
import { isAppIcon } from '@/utils/common'
180175
import EditTitleDialog from './EditTitleDialog.vue'
181-
import useStore from '@/stores'
182-
const { common, chatUser } = useStore()
183176
const props = defineProps<{
184177
applicationDetail: any
185178
chatLogData: any[]
186-
leftLoading: boolean
179+
leftLoading?: boolean
187180
currentChatId: string
188181
isPcCollapse?: boolean
189182
}>()
190-
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle','clearChat'])
183+
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle', 'clearChat'])
191184
192185
const EditTitleDialogRef = ref()
193186

ui/src/views/chat/embed/component/ChatHistoryDrawer.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@
88
:size="280"
99
style="--el-drawer-padding-primary: 0"
1010
>
11-
<el-button
12-
class="collapse cursor"
13-
circle
14-
@click="show = !show"
15-
>
11+
<el-button class="collapse cursor" circle @click="show = !show">
1612
<el-icon>
1713
<component :is="!show ? 'ArrowRightBold' : 'ArrowLeftBold'" />
1814
</el-icon>
@@ -26,6 +22,7 @@
2622
@clickLog="handleClickList"
2723
@delete-log="deleteChatLog"
2824
@refreshFieldTitle="refreshFieldTitle"
25+
@clear-chat="clearChat"
2926
>
3027
<div class="user-info p-16 cursor">
3128
<el-avatar
@@ -112,10 +109,14 @@ const props = defineProps<{
112109
currentChatId: string
113110
}>()
114111
115-
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle'])
112+
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle', 'clearChat'])
116113
117114
const { chatUser, chatLog } = useStore()
118115
116+
const clearChat = () => {
117+
emit('clearChat')
118+
}
119+
119120
const newChat = () => {
120121
emit('newChat')
121122
}
@@ -138,7 +139,7 @@ const openResetPassword = () => {
138139
139140
const handleResetPassword = (param: ResetCurrentUserPasswordRequest) => {
140141
chatAPI.resetCurrentPassword(param).then(() => {
141-
router.push({name: 'login'})
142+
router.push({ name: 'login' })
142143
})
143144
}
144145

ui/src/views/chat/embed/index.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
@clickLog="clickListHandle"
8282
@delete-log="deleteLog"
8383
@refreshFieldTitle="refreshFieldTitle"
84+
@clear-chat="clearChat"
8485
/>
8586
</div>
8687
</div>
@@ -124,6 +125,16 @@ const customStyle = computed(() => {
124125
}
125126
})
126127
128+
function clearChat() {
129+
chatAPI.clearChat(left_loading).then(() => {
130+
currentChatId.value = 'new'
131+
paginationConfig.current_page = 1
132+
paginationConfig.total = 0
133+
currentRecordList.value = []
134+
getChatLog(applicationDetail.value.id)
135+
})
136+
}
137+
127138
function deleteLog(row: any) {
128139
chatAPI.deleteChat(row.id, left_loading).then(() => {
129140
if (currentChatId.value === row.id) {

ui/src/views/chat/mobile/component/ChatHistoryDrawer.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
@clickLog="handleClickList"
1818
@delete-log="deleteChatLog"
1919
@refreshFieldTitle="refreshFieldTitle"
20+
@clear-chat="clearChat"
2021
>
2122
<div class="flex align-center user-info p-16" @click="toUserCenter">
2223
<el-avatar
@@ -47,14 +48,18 @@ const show = defineModel<boolean>('show')
4748
const props = defineProps<{
4849
applicationDetail: any
4950
chatLogData: any[]
50-
leftLoading: boolean
51+
leftLoading?: boolean
5152
currentChatId: string
5253
}>()
5354
54-
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle'])
55+
const emit = defineEmits(['newChat', 'clickLog', 'deleteLog', 'refreshFieldTitle', 'clearChat'])
5556
5657
const { chatUser, chatLog } = useStore()
5758
59+
const clearChat = () => {
60+
emit('clearChat')
61+
}
62+
5863
const newChat = () => {
5964
emit('newChat')
6065
}
@@ -70,7 +75,6 @@ function refreshFieldTitle(chatId: string, abstract: string) {
7075
emit('refreshFieldTitle', chatId, abstract)
7176
}
7277
73-
7478
const userCenterDrawerShow = ref(false)
7579
function toUserCenter() {
7680
if (

ui/src/views/chat/mobile/index.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<template>
22
<div
33
class="chat-mobile layout-bg chat-background"
4-
v-loading="loading"
54
:class="classObj"
65
:style="{
76
'--el-color-primary': applicationDetail?.custom_theme?.theme_color,
@@ -82,6 +81,7 @@
8281
@clickLog="clickListHandle"
8382
@delete-log="deleteLog"
8483
@refreshFieldTitle="refreshFieldTitle"
84+
@clear-chat="clearChat"
8585
/>
8686
</div>
8787
</template>
@@ -133,6 +133,16 @@ const classObj = computed(() => {
133133
}
134134
})
135135
136+
function clearChat() {
137+
chatAPI.clearChat(left_loading).then(() => {
138+
currentChatId.value = 'new'
139+
paginationConfig.current_page = 1
140+
paginationConfig.total = 0
141+
currentRecordList.value = []
142+
getChatLog(applicationDetail.value.id)
143+
})
144+
}
145+
136146
function deleteLog(row: any) {
137147
chatAPI.deleteChat(row.id, left_loading).then(() => {
138148
if (currentChatId.value === row.id) {

ui/src/views/chat/pc/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div
33
class="chat-pc"
44
:class="classObj"
5-
v-loading="loading || left_loading"
5+
v-loading="loading"
66
:style="{
77
'--el-color-primary': applicationDetail?.custom_theme?.theme_color,
88
'--el-color-primary-light-9': hexToRgba(
@@ -205,7 +205,7 @@
205205
<ExecutionDetailContent
206206
v-if="rightPanelType === 'executionDetail'"
207207
:detail="executionDetail"
208-
:type="applicationDetail?.type"
208+
:appType="applicationDetail?.type"
209209
/>
210210
<ParagraphDocumentContent :detail="rightPanelDetail" v-else />
211211
</div>
@@ -450,8 +450,8 @@ const clickListHandle = (item: any) => {
450450
}
451451
452452
function refresh(id: string) {
453-
getChatLog(applicationDetail.value.id, true)
454453
currentChatId.value = id
454+
getChatLog(applicationDetail.value.id, true)
455455
}
456456
457457
async function exportMarkdown(): Promise<void> {

0 commit comments

Comments
 (0)