Skip to content

Commit eba2200

Browse files
perf: chat share
1 parent ca0034a commit eba2200

File tree

4 files changed

+126
-95
lines changed

4 files changed

+126
-95
lines changed

ui/src/components/ai-chat/component/operation-button/ChatOperationButton.vue

Lines changed: 56 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -36,33 +36,29 @@
3636
<AppIcon class="color-secondary" iconName="app-video-play"></AppIcon>
3737
</el-button>
3838
</el-tooltip>
39-
40-
<el-divider direction="vertical" />
4139
</span>
4240
<span v-if="type == 'ai-chat' || type == 'log'">
43-
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
44-
<el-button text @click="copy(data)">
45-
<AppIcon class="color-secondary" iconName="app-copy"></AppIcon>
46-
</el-button>
47-
</el-tooltip>
48-
<el-divider direction="vertical" />
49-
<el-tooltip effect="dark" :content="$t('chat.operation.regeneration')" placement="top">
50-
<el-button :disabled="chat_loading" text @click="regeneration">
51-
<AppIcon iconName="app-refresh" class="color-secondary"></AppIcon>
52-
</el-button>
53-
</el-tooltip>
54-
<el-divider direction="vertical" />
55-
56-
<el-tooltip
57-
v-if="buttonData?.vote_status === '-1' && mode === 'mobile'"
58-
effect="dark"
59-
:content="$t('chat.operation.like')"
60-
placement="top"
61-
>
62-
<el-button text :disabled="loading" @click="mobileVoteReasonHandler('0')">
63-
<AppIcon class="color-secondary" iconName="app-like"></AppIcon>
64-
</el-button>
65-
</el-tooltip>
41+
<span class="ml-8">
42+
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
43+
<el-button text @click="copy(data)">
44+
<AppIcon class="color-secondary" iconName="app-copy"></AppIcon>
45+
</el-button>
46+
</el-tooltip>
47+
</span>
48+
<span class="ml-8">
49+
<el-tooltip effect="dark" :content="$t('chat.operation.regeneration')" placement="top">
50+
<el-button :disabled="chat_loading" text @click="regeneration">
51+
<AppIcon iconName="app-refresh" class="color-secondary"></AppIcon>
52+
</el-button>
53+
</el-tooltip>
54+
</span>
55+
<span class="ml-8" v-if="buttonData?.vote_status === '-1' && mode === 'mobile'">
56+
<el-tooltip effect="dark" :content="$t('chat.operation.like')" placement="top">
57+
<el-button text :disabled="loading" @click="mobileVoteReasonHandler('0')">
58+
<AppIcon class="color-secondary" iconName="app-like"></AppIcon>
59+
</el-button>
60+
</el-tooltip>
61+
</span>
6662

6763
<el-popover
6864
ref="likePopoverRef"
@@ -74,7 +70,7 @@
7470
v-if="buttonData?.vote_status === '-1' && mode !== 'mobile'"
7571
>
7672
<template #reference>
77-
<span>
73+
<span class="ml-8">
7874
<el-tooltip effect="dark" :content="$t('chat.operation.like')" placement="top">
7975
<el-button text :disabled="loading">
8076
<AppIcon class="color-secondary" iconName="app-like"></AppIcon>
@@ -91,28 +87,21 @@
9187
>
9288
</VoteReasonContent>
9389
</el-popover>
90+
<span v-if="buttonData?.vote_status === '0'" class="ml-8">
91+
<el-tooltip effect="dark" :content="$t('chat.operation.cancelLike')" placement="top">
92+
<el-button text @click="cancelVoteHandle('-1')" :disabled="loading">
93+
<AppIcon class="color-secondary" iconName="app-like-color"></AppIcon>
94+
</el-button>
95+
</el-tooltip>
96+
</span>
97+
<span v-if="buttonData?.vote_status === '-1' && mode === 'mobile'" class="ml-8">
98+
<el-tooltip effect="dark" :content="$t('chat.operation.oppose')" placement="top">
99+
<el-button text :disabled="loading" @click="mobileVoteReasonHandler('1')">
100+
<AppIcon class="color-secondary" iconName="app-oppose"></AppIcon>
101+
</el-button>
102+
</el-tooltip>
103+
</span>
94104

95-
<el-tooltip
96-
effect="dark"
97-
:content="$t('chat.operation.cancelLike')"
98-
placement="top"
99-
v-if="buttonData?.vote_status === '0'"
100-
>
101-
<el-button text @click="cancelVoteHandle('-1')" :disabled="loading">
102-
<AppIcon class="color-secondary" iconName="app-like-color"></AppIcon>
103-
</el-button>
104-
</el-tooltip>
105-
<el-divider direction="vertical" v-if="buttonData?.vote_status === '-1'" />
106-
<el-tooltip
107-
v-if="buttonData?.vote_status === '-1' && mode === 'mobile'"
108-
effect="dark"
109-
:content="$t('chat.operation.oppose')"
110-
placement="top"
111-
>
112-
<el-button text :disabled="loading" @click="mobileVoteReasonHandler('1')">
113-
<AppIcon class="color-secondary" iconName="app-oppose"></AppIcon>
114-
</el-button>
115-
</el-tooltip>
116105
<el-popover
117106
ref="opposePopoverRef"
118107
trigger="click"
@@ -123,7 +112,7 @@
123112
v-if="buttonData?.vote_status === '-1' && mode !== 'mobile'"
124113
>
125114
<template #reference>
126-
<span>
115+
<span class="ml-8">
127116
<el-tooltip effect="dark" :content="$t('chat.operation.oppose')" placement="top">
128117
<el-button text :disabled="loading">
129118
<AppIcon class="color-secondary" iconName="app-oppose"></AppIcon>
@@ -140,16 +129,20 @@
140129
>
141130
</VoteReasonContent>
142131
</el-popover>
143-
<el-tooltip
144-
effect="dark"
145-
:content="$t('chat.operation.cancelOppose')"
146-
placement="top"
147-
v-if="buttonData?.vote_status === '1'"
148-
>
149-
<el-button text @click="cancelVoteHandle('-1')" :disabled="loading">
150-
<AppIcon class="color-secondary" iconName="app-oppose-color"></AppIcon>
151-
</el-button>
152-
</el-tooltip>
132+
<span class="ml-8" v-if="buttonData?.vote_status === '1'">
133+
<el-tooltip effect="dark" :content="$t('chat.operation.cancelOppose')" placement="top">
134+
<el-button text @click="cancelVoteHandle('-1')" :disabled="loading">
135+
<AppIcon class="color-secondary" iconName="app-oppose-color"></AppIcon>
136+
</el-button>
137+
</el-tooltip>
138+
</span>
139+
<span class="ml-8">
140+
<el-tooltip effect="dark" :content="$t('chat.share')" placement="top">
141+
<el-button text @click.stop="clickShareHandle(props.data.record_id)">
142+
<AppIcon class="color-secondary" iconName="app-share"></AppIcon>
143+
</el-button>
144+
</el-tooltip>
145+
</span>
153146
</span>
154147
<div ref="audioCiontainer"></div>
155148
</div>
@@ -196,7 +189,11 @@ const props = withDefaults(
196189
},
197190
)
198191
199-
const emit = defineEmits(['update:data', 'regeneration'])
192+
const emit = defineEmits(['update:data', 'regeneration', 'clickShare'])
193+
194+
const clickShareHandle = (id: string) => {
195+
bus.emit('click:share', id)
196+
}
200197
201198
const copy = (data: any) => {
202199
try {

ui/src/components/ai-chat/component/operation-button/LogOperationButton.vue

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,41 @@
2424
<AppIcon iconName="app-video-pause" class="color-secondary"></AppIcon>
2525
</el-button>
2626
</el-tooltip>
27-
<el-divider direction="vertical" />
2827
</span>
29-
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
30-
<el-button text @click="copyClick(data?.answer_text)">
31-
<AppIcon iconName="app-copy" class="color-secondary"></AppIcon>
32-
</el-button>
33-
</el-tooltip>
34-
<el-divider direction="vertical" />
35-
<template v-if="permissionPrecise.chat_log_add_knowledge(id)">
36-
<el-tooltip
37-
v-if="buttonData.improve_paragraph_id_list.length === 0"
38-
effect="dark"
39-
:content="$t('views.chatLog.editContent')"
40-
placement="top"
41-
>
42-
<el-button text @click="editContent(data)">
43-
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
28+
<span class="ml-8">
29+
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
30+
<el-button text @click="copyClick(data?.answer_text)">
31+
<AppIcon iconName="app-copy" class="color-secondary"></AppIcon>
4432
</el-button>
4533
</el-tooltip>
34+
</span>
4635

47-
<el-tooltip v-else effect="dark" :content="$t('views.chatLog.editMark')" placement="top">
48-
<el-button text @click="editMark(data)">
49-
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
50-
</el-button>
51-
</el-tooltip>
36+
<template v-if="permissionPrecise.chat_log_add_knowledge(id)">
37+
<span class="ml-8" v-if="buttonData.improve_paragraph_id_list.length === 0">
38+
<el-tooltip effect="dark" :content="$t('views.chatLog.editContent')" placement="top">
39+
<el-button text @click="editContent(data)">
40+
<AppIcon iconName="app-edit" class="color-secondary"></AppIcon>
41+
</el-button>
42+
</el-tooltip>
43+
</span>
44+
<span v-else class="ml-8">
45+
<el-tooltip effect="dark" :content="$t('views.chatLog.editMark')" placement="top">
46+
<el-button text @click="editMark(data)">
47+
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
48+
</el-button>
49+
</el-tooltip>
50+
</span>
5251
</template>
53-
54-
<el-divider direction="vertical" v-if="buttonData?.vote_status !== '-1'" />
55-
<el-button text disabled v-if="buttonData?.vote_status === '0'">
56-
<AppIcon iconName="app-like-color"></AppIcon>
57-
</el-button>
58-
59-
<el-button text disabled v-if="buttonData?.vote_status === '1'">
60-
<AppIcon iconName="app-oppose-color"></AppIcon>
61-
</el-button>
52+
<span class="ml-8" v-if="buttonData?.vote_status === '0'">
53+
<el-button text disabled>
54+
<AppIcon iconName="app-like-color"></AppIcon>
55+
</el-button>
56+
</span>
57+
<span class="ml-8" v-if="buttonData?.vote_status === '1'">
58+
<el-button text disabled>
59+
<AppIcon iconName="app-oppose-color"></AppIcon>
60+
</el-button>
61+
</span>
6262
<EditContentDialog ref="EditContentDialogRef" @refresh="refreshContent" />
6363
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refreshMark" />
6464
<!-- 先渲染,不然不能播放 -->

ui/src/components/ai-chat/index.vue

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
<el-checkbox :value="item.id" v-if="selection" />
4444
<div
4545
class="w-full border-r-8"
46-
:class="selection ? 'is-selected p-12 mt-8 mb-8' : 'mt-24'"
46+
:class="selection ? 'is-selected p-12 mt-8 mb-8 cursor' : 'mt-24'"
47+
@click="toggleSelect(item.id)"
4748
>
4849
<!-- 问题 -->
4950
<QuestionContent
@@ -59,7 +60,11 @@
5960
</div>
6061
<div class="flex align-center w-full">
6162
<el-checkbox :value="item.id" v-if="selection" />
62-
<div class="w-full border-r-8" :class="selection ? 'is-selected p-12' : ''">
63+
<div
64+
class="w-full border-r-8"
65+
:class="selection ? 'is-selected p-12 cursor' : ''"
66+
@click="toggleSelect(item.id)"
67+
>
6368
<!-- 回答 -->
6469
<AnswerContent
6570
:application="applicationDetails"
@@ -299,6 +304,21 @@ watch(
299304
},
300305
)
301306
307+
watch(
308+
() => props.selection,
309+
(value) => {
310+
if (value) {
311+
if (value && multipleSelectionChat.value.length === 0) {
312+
multipleSelectionChat.value = chatList.value.map((v) => v.id)
313+
checkAll.value = true
314+
}
315+
}
316+
},
317+
{
318+
immediate: true,
319+
},
320+
)
321+
302322
// 选择对话分享
303323
const checkAll = ref(false)
304324
const multipleSelectionChat = ref<any[]>([])
@@ -323,6 +343,15 @@ const handleCheckedChatChange = (value: CheckboxValueType[]) => {
323343
const checkedCount = value.length
324344
checkAll.value = checkedCount === chatList.value.length
325345
}
346+
347+
function toggleSelect(id: number) {
348+
const index = multipleSelectionChat.value.indexOf(id)
349+
if (index === -1) {
350+
multipleSelectionChat.value.push(id)
351+
} else {
352+
multipleSelectionChat.value.splice(index, 1)
353+
}
354+
}
326355
function cancelCheckHandle() {
327356
checkAll.value = false
328357
multipleSelectionChat.value = []
@@ -820,6 +849,10 @@ onMounted(() => {
820849
}
821850
})
822851
})
852+
bus.on('click:share', (id: string) => {
853+
multipleSelectionChat.value.push(id)
854+
emit('update:selection', true)
855+
})
823856
})
824857
825858
onBeforeUnmount(() => {

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@
125125
<span v-if="paginationConfig.total" class="lighter">
126126
{{ paginationConfig.total }} {{ $t('chat.question_count') }}
127127
</span>
128-
<el-button text class="ml-12" @click="clickShareHandle">
129-
<AppIcon iconName="app-share"></AppIcon>
130-
</el-button>
131-
128+
<el-tooltip effect="dark" :content="$t('chat.share')" placement="top">
129+
<el-button text class="ml-12" @click="clickShareHandle">
130+
<AppIcon iconName="app-share"></AppIcon>
131+
</el-button>
132+
</el-tooltip>
132133
<el-dropdown class="ml-8">
133134
<el-button text>
134135
<AppIcon iconName="app-export" :title="$t('chat.exportRecords')"></AppIcon>

0 commit comments

Comments
 (0)