fit chat stop (#117)

This commit is contained in:
HCode authored and GitHub committed 2024-08-17 23:07:34 +08:00
1 parent d3d46b5f2f
commit 31cd8921ef
7 files changed
+65 -7

No files matched your search

+29 -1
View File
@@ -23,6 +23,7 @@
</el-tooltip>
</el-upload>
<span
v-show="!disabled"
:class="{
btn: true,
'btn-send': true,
@@ -32,6 +33,17 @@
>
<font-awesome-icon icon="fa-solid fa-location-arrow" class="icon icon-send" />
</span>
<span
v-show="disabled"
:class="{
btn: true,
'btn-stop': true,
disabled: !disabled
}"
@click="onStop"
>
<font-awesome-icon icon="fa-solid fa-stop-circle" class="icon icon-stop" />
</span>
<!-- add this textarea -->
<textarea
ref="textarea"
@@ -80,7 +92,7 @@ export default defineComponent({
required: true
}
},
emits: ['update:question', 'update:references', 'submit'],
emits: ['update:question', 'update:references', 'submit', 'stop'],
data() {
return {
inputHeight: '35px', //add inputHeight
@@ -143,6 +155,9 @@ export default defineComponent({
}
this.$emit('submit');
},
onStop() {
this.$emit('stop');
},
onExceed() {
ElMessage.warning(this.$t('chat.message.uploadReferencesExceed'));
},
@@ -246,6 +261,19 @@ textarea.input:focus {
color: var(--el-text-color-primary);
}
}
&.btn-stop {
right: 15px; // Adjust position if needed
&.disabled {
.icon-stop {
color: var(--el-text-color-disabled);
}
cursor: not-allowed;
}
.icon-stop {
font-size: 16px;
color: var(--el-text-color-primary);
}
}
}
}
+8 -2
View File
@@ -56,14 +56,17 @@
</div>
<div class="operations">
<copy-to-clipboard
v-if="!Array.isArray(message.content) && message.state === messageState.FINISHED"
v-if="
!Array.isArray(message.content) &&
(message.state === messageState.FINISHED || message.state === messageState.FAILED)
"
:content="message.content!"
class="btn-copy"
/>
<restart-to-generate
v-if="
!Array.isArray(message.content) &&
message.state === messageState.FINISHED &&
(message.state === messageState.FINISHED || message.state === messageState.FAILED) &&
message.role === 'assistant' &&
message === messages[messages.length - 1]
"
@@ -99,6 +102,7 @@ import {
ERROR_CODE_TOO_MANY_REQUESTS,
ERROR_CODE_UNKNOWN,
ERROR_CODE_USED_UP,
ERROR_CODE_CANCELED,
ROLE_ASSISTANT
} from '@/constants';
import { ROUTE_CONSOLE_APPLICATION_EXTRA } from '@/router';
@@ -168,6 +172,8 @@ export default defineComponent({
return this.$t('chat.message.errorContentTooLarge');
case ERROR_CODE_NOT_APPLIED:
return this.$t('chat.message.errorNotApplied');
case ERROR_CODE_CANCELED:
return undefined; // 不显示错误框
case ERROR_CODE_UNKNOWN:
default:
return this.$t('chat.message.errorUnknown');