Skip to content

Commit 5dcb615

Browse files
committed
fix: add conditional rendering for vote reason content and optimize user input field availability checks
1 parent f551ae2 commit 5dcb615

File tree

6 files changed

+97
-84
lines changed

6 files changed

+97
-84
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
</span>
6969
</template>
7070
<VoteReasonContent
71+
v-if="props.data.record_id"
7172
vote-type="0"
7273
:chat-id="props.chatId"
7374
:record-id="props.data.record_id"
@@ -104,6 +105,7 @@
104105
</span>
105106
</template>
106107
<VoteReasonContent
108+
v-if="props.data.record_id"
107109
vote-type="1"
108110
:chat-id="props.chatId"
109111
:record-id="props.data.record_id"

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

Lines changed: 82 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,94 @@
11
<template>
2-
<div class="flex-between mt-8">
3-
<div>
4-
<el-text type="info">
5-
<span class="ml-4">{{ datetimeFormat(data.create_time) }}</span>
6-
</el-text>
7-
</div>
8-
<div>
9-
<!-- 语音播放 -->
10-
<span v-if="tts">
11-
<el-tooltip
12-
effect="dark"
13-
:content="$t('chat.operation.play')"
14-
placement="top"
15-
v-if="!audioPlayerStatus"
16-
>
17-
<el-button text @click="playAnswerText(data?.answer_text)">
18-
<AppIcon iconName="app-video-play"></AppIcon>
19-
</el-button>
20-
</el-tooltip>
21-
<el-tooltip v-else effect="dark" :content="$t('chat.operation.pause')" placement="top">
22-
<el-button type="primary" text @click="pausePlayAnswerText()">
23-
<AppIcon iconName="app-video-pause"></AppIcon>
2+
<div>
3+
<div class="flex-between mt-8">
4+
<div>
5+
<el-text type="info">
6+
<span class="ml-4">{{ datetimeFormat(data.create_time) }}</span>
7+
</el-text>
8+
</div>
9+
<div>
10+
<!-- 语音播放 -->
11+
<span v-if="tts">
12+
<el-tooltip
13+
effect="dark"
14+
:content="$t('chat.operation.play')"
15+
placement="top"
16+
v-if="!audioPlayerStatus"
17+
>
18+
<el-button text @click="playAnswerText(data?.answer_text)">
19+
<AppIcon iconName="app-video-play"></AppIcon>
20+
</el-button>
21+
</el-tooltip>
22+
<el-tooltip v-else effect="dark" :content="$t('chat.operation.pause')" placement="top">
23+
<el-button type="primary" text @click="pausePlayAnswerText()">
24+
<AppIcon iconName="app-video-pause"></AppIcon>
25+
</el-button>
26+
</el-tooltip>
27+
<el-divider direction="vertical" />
28+
</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"></AppIcon>
2432
</el-button>
2533
</el-tooltip>
2634
<el-divider direction="vertical" />
27-
</span>
28-
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
29-
<el-button text @click="copyClick(data?.answer_text)">
30-
<AppIcon iconName="app-copy"></AppIcon>
31-
</el-button>
32-
</el-tooltip>
33-
<el-divider direction="vertical" />
34-
<template v-if="permissionPrecise.chat_log_add_knowledge(id)">
35-
<el-tooltip
36-
v-if="buttonData.improve_paragraph_id_list.length === 0"
37-
effect="dark"
38-
:content="$t('views.chatLog.editContent')"
39-
placement="top"
40-
>
41-
<el-button text @click="editContent(data)">
42-
<AppIcon iconName="app-edit"></AppIcon>
43-
</el-button>
44-
</el-tooltip>
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"></AppIcon>
44+
</el-button>
45+
</el-tooltip>
4546

46-
<el-tooltip v-else effect="dark" :content="$t('views.chatLog.editMark')" placement="top">
47-
<el-button text @click="editMark(data)">
48-
<AppIcon iconName="app-document-active" class="primary"></AppIcon>
49-
</el-button>
50-
</el-tooltip>
51-
</template>
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>
52+
</template>
5253

53-
<el-divider direction="vertical" v-if="buttonData?.vote_status !== '-1'" />
54-
<el-button text disabled v-if="buttonData?.vote_status === '0'">
55-
<AppIcon iconName="app-like-color"></AppIcon>
56-
</el-button>
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>
5758

58-
<el-button text disabled v-if="buttonData?.vote_status === '1'">
59-
<AppIcon iconName="app-oppose-color"></AppIcon>
60-
</el-button>
61-
<EditContentDialog ref="EditContentDialogRef" @refresh="refreshContent" />
62-
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refreshMark" />
63-
<!-- 先渲染,不然不能播放 -->
64-
<audio
65-
ref="audioPlayer"
66-
v-for="item in audioList"
67-
:key="item"
68-
controls
69-
hidden="hidden"
70-
></audio>
59+
<el-button text disabled v-if="buttonData?.vote_status === '1'">
60+
<AppIcon iconName="app-oppose-color"></AppIcon>
61+
</el-button>
62+
<EditContentDialog ref="EditContentDialogRef" @refresh="refreshContent" />
63+
<EditMarkDialog ref="EditMarkDialogRef" @refresh="refreshMark" />
64+
<!-- 先渲染,不然不能播放 -->
65+
<audio
66+
ref="audioPlayer"
67+
v-for="item in audioList"
68+
:key="item"
69+
controls
70+
hidden="hidden"
71+
></audio>
72+
</div>
7173
</div>
72-
</div>
73-
<div>
74-
<el-card
75-
class="mt-16"
76-
shadow="always"
77-
v-if="buttonData?.vote_status !== '-1' && data.vote_reason"
78-
>
79-
<VoteReasonContent
80-
:vote-type="buttonData?.vote_status"
81-
:chat-id="buttonData?.chat_id"
82-
:record-id="buttonData?.id"
83-
readonly
84-
:default-reason="data.vote_reason"
85-
:default-other-content="data.vote_other_content"
74+
<div>
75+
<el-card
76+
class="mt-16"
77+
shadow="always"
78+
v-if="buttonData?.vote_status !== '-1' && data.vote_reason"
8679
>
87-
</VoteReasonContent>
88-
</el-card>
80+
<VoteReasonContent
81+
v-if="buttonData?.id"
82+
:vote-type="buttonData?.vote_status"
83+
:chat-id="buttonData?.chat_id"
84+
:record-id="buttonData?.id"
85+
readonly
86+
:default-reason="data.vote_reason"
87+
:default-other-content="data.vote_other_content"
88+
>
89+
</VoteReasonContent>
90+
</el-card>
91+
</div>
8992
</div>
9093
</template>
9194
<script setup lang="ts">

ui/src/components/ai-chat/component/question-content/index.vue

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,11 @@
102102
<el-button class="flex mr-8" text @click="cancelReQuestion"
103103
><el-icon><Close /></el-icon
104104
></el-button>
105-
<el-button :disabled="!editText.trim()" text @click="sendReQuestionMessage(chatRecord)">
105+
<el-button
106+
:disabled="!editText.trim() || editText.trim() === chatRecord.problem_text.trim()"
107+
text
108+
@click="sendReQuestionMessage(chatRecord)"
109+
>
106110
<el-icon><Comment /></el-icon>
107111
</el-button>
108112
</el-button-group>
@@ -130,7 +134,12 @@
130134
v-if="!isReQuestion"
131135
>
132136
<div class="text-right">
133-
<el-tooltip effect="dark" :content="$t('common.edit')" placement="top" v-if="props.isLast">
137+
<el-tooltip
138+
effect="dark"
139+
:content="$t('common.edit')"
140+
placement="top"
141+
v-if="props.isLast && props.type !== 'log'"
142+
>
134143
<el-button text @click="handleEdit(chatRecord)">
135144
<AppIcon iconName="app-edit"></AppIcon>
136145
</el-button>

ui/src/components/ai-chat/component/user-form/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ watch(
107107
function handleInputFieldList() {
108108
dynamicsFormRefresh.value++
109109
const default_value: any = {}
110-
props.application.work_flow?.nodes
110+
props.application?.work_flow?.nodes
111111
?.filter((v: any) => v.id === 'base-node')
112112
.map((v: any) => {
113113
inputFieldList.value = v.properties.user_input_field_list

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ const initialApiFormData = ref({})
197197
198198
const isUserInput = computed(
199199
() =>
200-
props.applicationDetails.work_flow?.nodes?.filter((v: any) => v.id === 'base-node')[0]
200+
props.applicationDetails?.work_flow?.nodes?.filter((v: any) => v.id === 'base-node')[0]
201201
?.properties.user_input_field_list.length > 0,
202202
)
203203

ui/src/stores/modules/chat-user.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const useChatUserStore = defineStore('chat-user', {
4545
},
4646
applicationProfile() {
4747
return ChatAPI.applicationProfile().then((ok) => {
48-
console.log('applicationProfile', ok.data)
4948
this.application = ok.data
5049
localStorage.setItem(`${this.accessToken}-locale`, ok.data?.language || this.getLanguage())
5150
})

0 commit comments

Comments
 (0)