Skip to content

Commit 9172afc

Browse files
committed
refactor: chatHistoryDrawer
1 parent f6b36b7 commit 9172afc

File tree

4 files changed

+239
-359
lines changed

4 files changed

+239
-359
lines changed

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

Lines changed: 8 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class="chat-embed layout-bg chat-background"
44
:class="{ 'chat-embed--popup': isPopup }"
55
v-loading="loading"
6-
:style="{
6+
:style="{
77
'--el-color-primary': applicationDetail?.custom_theme?.theme_color,
88
'--el-color-primary-light-9': hexToRgba(applicationDetail?.custom_theme?.theme_color, 0.1),
99
backgroundImage: `url(${applicationDetail?.chat_background})`,
@@ -15,7 +15,7 @@
1515
<AppIcon
1616
iconName="app-history-outlined"
1717
style="font-size: 20px"
18-
class="ml-16"
18+
class="ml-16 cursor"
1919
:style="{
2020
color: applicationDetail?.custom_theme?.header_font_color,
2121
}"
@@ -60,109 +60,24 @@
6060
</AiChat>
6161
</div>
6262

63-
<el-drawer
64-
v-model="show"
65-
:with-header="false"
66-
class="left-drawer"
67-
direction="ltr"
68-
:size="280"
69-
>
70-
<div>
71-
<div class="flex align-center mb-16">
72-
<div class="flex mr-8">
73-
<el-avatar
74-
v-if="isAppIcon(applicationDetail?.icon)"
75-
shape="square"
76-
:size="32"
77-
style="background: none"
78-
>
79-
<img :src="applicationDetail?.icon" alt="" />
80-
</el-avatar>
81-
<LogoIcon v-else height="32px" />
82-
</div>
83-
<h4>{{ applicationDetail?.name }}</h4>
84-
</div>
85-
<el-button class="add-button w-full primary" @click="newChat">
86-
<AppIcon iconName="app-create-chat"></AppIcon>
87-
<span class="ml-4">{{ $t('chat.createChat') }}</span>
88-
</el-button>
89-
<p class="mt-20 mb-8">{{ $t('chat.history') }}</p>
90-
</div>
91-
92-
<div class="left-height pt-0">
93-
<el-scrollbar>
94-
<div>
95-
<common-list
96-
:style="{ '--el-color-primary': applicationDetail?.custom_theme?.theme_color }"
97-
:data="chatLogData"
98-
v-loading="left_loading"
99-
:defaultActive="currentChatId"
100-
@click="clickListHandle"
101-
@mouseenter="mouseenter"
102-
@mouseleave="mouseId = ''"
103-
>
104-
<template #default="{ row }">
105-
<div class="flex-between">
106-
<ReadWrite
107-
@change="editName($event, row)"
108-
:data="row.abstract"
109-
trigger="manual"
110-
:write="row.writeStatus"
111-
@close="closeWrite(row)"
112-
:maxlength="1024"
113-
/>
114-
<div
115-
@click.stop
116-
v-if="mouseId === row.id && row.id !== 'new' && !row.writeStatus"
117-
class="flex"
118-
>
119-
<el-button style="padding: 0" link @click.stop="openWrite(row)">
120-
<el-icon><EditPen /></el-icon>
121-
</el-button>
122-
<el-button style="padding: 0" link @click.stop="deleteLog(row)">
123-
<el-icon><Delete /></el-icon>
124-
</el-button>
125-
</div>
126-
</div>
127-
</template>
128-
<template #empty>
129-
<div class="text-center mt-24">
130-
<el-text type="info">{{ $t('chat.noHistory') }}</el-text>
131-
</div>
132-
</template>
133-
</common-list>
134-
</div>
135-
<div v-if="chatLogData.length" class="gradient-divider lighter mt-8">
136-
<span>{{ $t('chat.only20history') }}</span>
137-
</div>
138-
</el-scrollbar>
139-
</div>
140-
<div class="flex align-center user-info" @click="toUserCenter">
141-
<el-avatar :size="32">
142-
<img src="@/assets/user-icon.svg" style="width: 54%" alt="" />
143-
</el-avatar>
144-
<span v-if="chatUser.chat_profile?.authentication" class="ml-8 color-text-primary">{{
145-
chatUser.chatUserProfile?.nick_name
146-
}}</span>
147-
</div>
148-
</el-drawer>
63+
<ChatHistoryDrawer v-model:show="show" :application-detail="applicationDetail" :chat-log-data="chatLogData"
64+
:left-loading="left_loading" :currentChatId="currentChatId" @new-chat="newChat"
65+
@clickLog="clickListHandle" @delete-log="deleteLog" />
14966
</div>
15067

151-
<UserCenter v-model:show="userCenterDrawerShow" />
15268
</div>
15369
</template>
15470
<script setup lang="ts">
15571
import { ref, onMounted, reactive, nextTick, computed } from 'vue'
15672
import { useRoute } from 'vue-router'
15773
import { isAppIcon } from '@/utils/common'
15874
import { hexToRgba } from '@/utils/theme'
159-
import { MsgError } from '@/utils/message'
16075
import useStore from '@/stores'
16176
import { t } from '@/locales'
162-
import UserCenter from '../mobile/component/UserCenter.vue'
77+
import ChatHistoryDrawer from '../mobile/component/ChatHistoryDrawer.vue'
16378
import chatAPI from '@/api/chat/chat'
16479
165-
const { user, chatLog, chatUser } = useStore()
80+
const { user, chatLog } = useStore()
16681
const route = useRoute()
16782
16883
const isPopup = computed(() => {
@@ -192,7 +107,6 @@ const paginationConfig = reactive({
192107
const currentRecordList = ref<any>([])
193108
const currentChatId = ref('new') // 当前历史记录Id 默认为'new'
194109
195-
const mouseId = ref('')
196110
197111
const customStyle = computed(() => {
198112
return {
@@ -201,34 +115,6 @@ const customStyle = computed(() => {
201115
}
202116
})
203117
204-
function editName(val: string, item: any) {
205-
if (val) {
206-
const obj = {
207-
abstract: val,
208-
}
209-
chatLog.asyncPutChatClientLog(applicationDetail.value.id, item.id, obj, loading).then(() => {
210-
const find = chatLogData.value.find((row: any) => row.id === item.id)
211-
if (find) {
212-
find.abstract = val
213-
}
214-
item['writeStatus'] = false
215-
})
216-
} else {
217-
MsgError(t('views.applicationWorkflow.tip.nameMessage'))
218-
}
219-
}
220-
221-
function openWrite(item: any) {
222-
item['writeStatus'] = true
223-
}
224-
225-
function closeWrite(item: any) {
226-
item['writeStatus'] = false
227-
}
228-
229-
function mouseenter(row: any) {
230-
mouseId.value = row.id
231-
}
232118
function deleteLog(row: any) {
233119
chatLog.asyncDelChatClientLog(applicationDetail.value.id, row.id, left_loading).then(() => {
234120
if (currentChatId.value === row.id) {
@@ -340,12 +226,6 @@ const init = () => {
340226
onMounted(() => {
341227
init()
342228
})
343-
344-
const userCenterDrawerShow = ref(false)
345-
function toUserCenter() {
346-
if (!chatUser.chat_profile?.authentication) return
347-
userCenterDrawerShow.value = true
348-
}
349229
</script>
350230
<style lang="scss">
351231
.chat-embed {
@@ -371,31 +251,6 @@ function toUserCenter() {
371251
z-index: 11;
372252
font-size: 1rem;
373253
}
374-
// 历史对话弹出层
375-
.left-drawer {
376-
.el-drawer__body {
377-
padding: 16px;
378-
background:
379-
linear-gradient(187.61deg, rgba(235, 241, 255, 0.5) 39.6%, rgba(231, 249, 255, 0.5) 94.3%),
380-
#eef1f4;
381-
overflow: hidden;
382-
383-
.add-button {
384-
border: 1px solid var(--el-color-primary);
385-
}
386-
387-
.left-height {
388-
height: calc(100vh - 212px);
389-
}
390-
391-
.user-info {
392-
border-radius: 6px;
393-
padding: 4px 8px;
394-
margin-top: 16px;
395-
box-sizing: border-box;
396-
}
397-
}
398-
}
399254
&.chat-embed--popup {
400255
.chat-popover-button {
401256
right: 85px;
@@ -412,29 +267,7 @@ function toUserCenter() {
412267
top: var(--app-header-height);
413268
z-index: 2008;
414269
}
415-
.gradient-divider {
416-
position: relative;
417-
text-align: center;
418-
color: var(--el-color-info);
419-
::before {
420-
content: '';
421-
width: 17%;
422-
height: 1px;
423-
background: linear-gradient(90deg, rgba(222, 224, 227, 0) 0%, #dee0e3 100%);
424-
position: absolute;
425-
left: 16px;
426-
top: 50%;
427-
}
428-
::after {
429-
content: '';
430-
width: 17%;
431-
height: 1px;
432-
background: linear-gradient(90deg, #dee0e3 0%, rgba(222, 224, 227, 0) 100%);
433-
position: absolute;
434-
right: 16px;
435-
top: 50%;
436-
}
437-
}
270+
438271
.AiChat-embed {
439272
.ai-chat__operate {
440273
padding-top: 12px;

0 commit comments

Comments
 (0)