优化对话体验

This commit is contained in:
Wenjie Zhang 2025-03-30 11:36:03 +08:00
parent 87525721e2
commit c8facdaffb
3 changed files with 21 additions and 10 deletions

View File

@ -41,7 +41,7 @@ def select_model(model_provider=None, model_name=None):
return OpenModel(model_name) return OpenModel(model_name)
elif model_provider == "custom": elif model_provider == "custom":
model_info = next((x for x in conf.custom_models if x["custom_id"] == model_name), None) model_info = next((x for x in config.custom_models if x["custom_id"] == model_name), None)
if model_info is None: if model_info is None:
raise ValueError(f"Model {model_name} not found in custom models") raise ValueError(f"Model {model_name} not found in custom models")

View File

@ -545,6 +545,18 @@ onMounted(() => {
chatContainer.value.addEventListener('scroll', handleUserScroll); chatContainer.value.addEventListener('scroll', handleUserScroll);
//
if (conv.value.messages && conv.value.messages.length > 0) {
conv.value.messages.forEach(msg => {
if (msg.role === 'received' && (!msg.text || msg.text.trim() === '')) {
msg.status = 'error';
msg.message = '内容加载失败';
}
});
}
console.log(conv.value.messages)
// //
const storedMeta = localStorage.getItem('meta'); const storedMeta = localStorage.getItem('meta');
if (storedMeta) { if (storedMeta) {

View File

@ -34,6 +34,10 @@
<i>正在生成</i> <i>正在生成</i>
</div> </div>
<div v-else-if="status === 'error'" class="err-msg" @click="$emit('retry')">
请求错误请重试{{ errorMessage }}
</div>
<!-- 消息内容 --> <!-- 消息内容 -->
<div v-else-if="contentHtml" v-html="contentHtml" class="message-md"></div> <div v-else-if="contentHtml" v-html="contentHtml" class="message-md"></div>
@ -42,11 +46,7 @@
<!-- 引用组件 (ChatComponent特有) --> <!-- 引用组件 (ChatComponent特有) -->
<slot name="refs"></slot> <slot name="refs"></slot>
</div> <!-- 错误消息 -->
<!-- 错误消息 -->
<div v-else-if="status === 'error'" class="err-msg" @click="$emit('retry')">
请求错误请重试{{ errorMessage }}
</div> </div>
<!-- 自定义内容 --> <!-- 自定义内容 -->
@ -161,7 +161,6 @@ const isEmptyAndLoading = computed(() => {
text-align: left; text-align: left;
margin: 0 0 16px 0; margin: 0 0 16px 0;
padding: 0px; padding: 0px;
text-align: justify;
background-color: transparent; background-color: transparent;
border-radius: 0; border-radius: 0;
} }
@ -195,12 +194,12 @@ const isEmptyAndLoading = computed(() => {
} }
.err-msg { .err-msg {
color: #eb8080; color: #d15252;
border: 1px solid #eb8080; border: 1px solid #f19999;
padding: 0.5rem 1rem; padding: 0.5rem 1rem;
border-radius: 8px; border-radius: 8px;
text-align: left; text-align: left;
background: #FFF5F5; background: #fffbfb;
margin-bottom: 10px; margin-bottom: 10px;
cursor: pointer; cursor: pointer;
} }