feat: Enhance agent settings navigation and error handling in UI components

- Introduced a new method to handle navigation to agent settings, improving code organization and reusability.
- Updated tooltip content in the agent mode button to include a link for quick access to agent settings.
- Enhanced error handling in the KnowledgeBase component to provide actionable links for VLM configuration errors.
- Added initial section handling in the KnowledgeBaseEditorModal for improved user experience during knowledge base editing.
This commit is contained in:
wizardchen
2025-11-07 16:40:53 +08:00
parent d387fd672f
commit f30720f99b
10 changed files with 133 additions and 48 deletions
+28 -7
View File
@@ -100,6 +100,15 @@ const onKeydown = (val: string, event: { e: { preventDefault(): unknown; keyCode
}
}
const handleGoToAgentSettings = () => {
// 使用 uiStore 打开设置并跳转到 agent 部分
uiStore.openSettings('agent');
// 如果当前不在设置页面,导航到设置页面
if (route.path !== '/platform/settings') {
router.push('/platform/settings');
}
}
const toggleAgentMode = () => {
// 如果要启用 Agent,先检查是否就绪
// 注意:isAgentReady 是从 store 中计算的,需要确保 store 中的配置是最新的
@@ -114,12 +123,7 @@ const toggleAgentMode = () => {
href: '#',
onClick: (e: Event) => {
e.preventDefault();
// 使用 uiStore 打开设置并跳转到 agent 部分
uiStore.openSettings('agent');
// 如果当前不在设置页面,导航到设置页面
if (route.path !== '/platform/settings') {
router.push('/platform/settings');
}
handleGoToAgentSettings();
},
style: 'color: #07C05F; text-decoration: none; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0;',
onMouseenter: (e: Event) => {
@@ -169,9 +173,26 @@ onBeforeRouteUpdate((to, from, next) => {
<div class="control-left">
<!-- Agent 模式按钮 -->
<t-tooltip
:content="isAgentEnabled ? 'Agent 模式(已启用)' : (settingsStore.isAgentReady ? 'Agent 模式(已禁用,点击启用)' : 'Agent 未就绪,请先完成配置')"
placement="top"
:show-arrow="true"
:duration="0"
>
<template #content>
<div style="display: flex; flex-direction: column; gap: 4px; align-items: flex-start;">
<span>
{{ isAgentEnabled ? 'Agent 模式(已启用)' : (settingsStore.isAgentReady ? 'Agent 模式(已禁用,点击启用)' : 'Agent 未就绪,请先完成配置') }}
</span>
<a
href="#"
@click.prevent="handleGoToAgentSettings"
style="color: #07C05F; text-decoration: none; font-size: 12px; cursor: pointer;"
@mouseenter="(e) => e.target.style.textDecoration = 'underline'"
@mouseleave="(e) => e.target.style.textDecoration = 'none'"
>
去设置 Agent →
</a>
</div>
</template>
<div
class="control-btn agent-btn"
:class="{
+11 -11
View File
@@ -159,9 +159,9 @@
<t-input
v-model.number="formData.dimension"
type="number"
:min="128"
:max="4096"
placeholder="如:1536"
:min="128"
:max="4096"
placeholder="如:1536"
:disabled="formData.source === 'local' && checking"
/>
<!-- Ollama 本地模型:自动检测维度按钮 -->
@@ -642,14 +642,14 @@ watch(() => formData.value.modelName, async (newValue, oldValue) => {
// 处理下载逻辑
if (newValue.startsWith('__download__')) {
// 提取模型名称
const modelName = newValue.replace('__download__', '')
// 重置选择(避免显示 __download__ 前缀)
formData.value.modelName = ''
// 开始下载
await startDownload(modelName)
// 提取模型名称
const modelName = newValue.replace('__download__', '')
// 重置选择(避免显示 __download__ 前缀)
formData.value.modelName = ''
// 开始下载
await startDownload(modelName)
return
}
-4
View File
@@ -24,10 +24,6 @@
<t-icon name="server" class="menu-icon" />
<span>Ollama</span>
</div>
<div class="menu-item" @click="handleQuickNav('knowledge')">
<t-icon name="folder-open" class="menu-icon" />
<span>知识库</span>
</div>
<div class="menu-divider"></div>
<div class="menu-item" @click="handleSettings">
<t-icon name="setting" class="menu-icon" />
+31 -2
View File
@@ -88,7 +88,7 @@
<script setup lang="ts">
import { storeToRefs } from 'pinia';
import { onMounted, watch, computed, ref, reactive, nextTick } from 'vue';
import { onMounted, watch, computed, ref, reactive, nextTick, h } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { getSessionsList, delSession } from "@/api/chat/index";
import { getKnowledgeBaseById, listKnowledgeBases, uploadKnowledgeFile } from '@/api/knowledge-base';
@@ -342,7 +342,36 @@ const upload = async (e: any) => {
} else if (err.message) {
errorMessage = err.message;
}
MessagePlugin.error(errorMessage);
// 如果是 VLM 配置错误,添加跳转链接
if (errorMessage.includes('VLM配置') || errorMessage.includes('多模态') || errorMessage.includes('对象存储')) {
const messageContent = h('div', { style: 'display: flex; align-items: center; gap: 8px; flex-wrap: wrap;' }, [
h('span', { style: 'flex: 1; min-width: 0;' }, errorMessage),
h('a', {
href: '#',
onClick: (e: Event) => {
e.preventDefault();
// 打开知识库设置弹框,并导航到高级设置部分
console.log('Opening KB editor for:', currentKbId, 'section: advanced');
uiStore.openEditKB(currentKbId, 'advanced');
},
style: 'color: #07C05F; text-decoration: none; font-weight: 500; cursor: pointer; white-space: nowrap; flex-shrink: 0;',
onMouseenter: (e: Event) => {
(e.target as HTMLElement).style.textDecoration = 'underline';
},
onMouseleave: (e: Event) => {
(e.target as HTMLElement).style.textDecoration = 'none';
}
}, '去设置 →')
]);
MessagePlugin.error({
content: messageContent,
duration: 5000
});
} else {
MessagePlugin.error(errorMessage);
}
} finally {
uploadInput.value.value = "";
}