Skip to content

Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.

fix(frontend): close editor on save and guide post-create setup

wizardchen23ae5e179ccf
diff --git a/frontend/src/i18n/locales/en-US.ts b/frontend/src/i18n/locales/en-US.ts
index 77f824a93..3253440ee 100755
--- a/frontend/src/i18n/locales/en-US.ts
+++ b/frontend/src/i18n/locales/en-US.ts
@@ -867,6 +867,15 @@ export default {
editor: {
createTitle: 'Create Agent',
editTitle: 'Edit Agent',
+ buttons: {
+ create: 'Create Agent',
+ saveAndClose: 'Save and Close',
+ },
+ postCreateHint: {
+ title: 'Created successfully',
+ footer: 'Keep adjusting settings, configure sharing and publishing, then click "Save and Close".',
+ integrationDesc: 'Go to Integrations to configure IM, web embed, and other publishing channels',
+ },
basicInfo: 'Basic Info',
basicInfoDesc: 'Configure agent name, description, and run mode',
promptsConfig: 'Prompts',
@@ -2229,7 +2238,13 @@ export default {
},
buttons: {
create: 'Create Knowledge Base',
- save: 'Save Configuration'
+ save: 'Save Configuration',
+ saveAndClose: 'Save and Close',
+ },
+ postCreateHint: {
+ title: 'Created successfully',
+ footer: 'Keep adjusting settings, configure sharing and data sources, then click "Save and Close".',
+ followUpDesc: 'Configure data sources on the left, or use Share Management to publish to spaces',
},
share: {
description: 'Share the knowledge base with spaces so members can access and use it',
diff --git a/frontend/src/i18n/locales/ko-KR.ts b/frontend/src/i18n/locales/ko-KR.ts
index a78b26114..5c212c617 100755
--- a/frontend/src/i18n/locales/ko-KR.ts
+++ b/frontend/src/i18n/locales/ko-KR.ts
@@ -3455,7 +3455,13 @@ export default {
},
buttons: {
create: '지식베이스 생성',
- save: '설정 저장'
+ save: '설정 저장',
+ saveAndClose: '저장 후 닫기',
+ },
+ postCreateHint: {
+ title: '생성 완료',
+ footer: '설정을 계속 조정하고 공유·데이터 소스를 구성한 뒤 "저장 후 닫기"를 클릭하세요.',
+ followUpDesc: '왼쪽에서 데이터 소스를 구성하거나 "공유 관리"에서 스페이스에 게시할 수 있습니다',
},
wikiBrowser: {
editBtn: '편집',
@@ -4760,6 +4766,15 @@ export default {
editor: {
createTitle: '에이전트 만들기',
editTitle: '에이전트 편집',
+ buttons: {
+ create: '에이전트 만들기',
+ saveAndClose: '저장 후 닫기',
+ },
+ postCreateHint: {
+ title: '생성 완료',
+ footer: '설정을 계속 조정하고 공유·배포 채널을 구성한 뒤 "저장 후 닫기"를 클릭하세요.',
+ integrationDesc: '통합 센터에서 IM, 웹 임베드 등 배포 채널을 설정하세요',
+ },
basicInfo: '기본정보',
basicInfoDesc: '에이전트 이름, 설명 및 실행 모드 구성',
promptsConfig: '프롬프트',
diff --git a/frontend/src/i18n/locales/ru-RU.ts b/frontend/src/i18n/locales/ru-RU.ts
index 424de6311..b56557682 100755
--- a/frontend/src/i18n/locales/ru-RU.ts
+++ b/frontend/src/i18n/locales/ru-RU.ts
@@ -3455,7 +3455,13 @@ export default {
},
buttons: {
create: 'Создать базу знаний',
- save: 'Сохранить настройки'
+ save: 'Сохранить настройки',
+ saveAndClose: 'Сохранить и закрыть',
+ },
+ postCreateHint: {
+ title: 'База знаний создана',
+ footer: 'Продолжите настройку, настройте совместное использование и источники данных, затем нажмите «Сохранить и закрыть».',
+ followUpDesc: 'Настройте источники данных слева или опубликуйте базу в пространствах через «Управление общим доступом»',
},
wikiBrowser: {
editBtn: 'Редактировать',
@@ -4760,6 +4766,15 @@ export default {
editor: {
createTitle: 'Create Agent',
editTitle: 'Edit Agent',
+ buttons: {
+ create: 'Создать агента',
+ saveAndClose: 'Сохранить и закрыть',
+ },
+ postCreateHint: {
+ title: 'Агент создан',
+ footer: 'Продолжите настройку, настройте совместное использование и публикацию, затем нажмите «Сохранить и закрыть».',
+ integrationDesc: 'Перейдите в раздел интеграций, чтобы настроить каналы IM, веб-встраивания и другие каналы публикации',
+ },
basicInfo: 'Basic Info',
basicInfoDesc: 'Настройка имени, описания и режима работы агента',
promptsConfig: 'Промпты',
diff --git a/frontend/src/i18n/locales/zh-CN.ts b/frontend/src/i18n/locales/zh-CN.ts
index a7c5618ed..e19489104 100755
--- a/frontend/src/i18n/locales/zh-CN.ts
+++ b/frontend/src/i18n/locales/zh-CN.ts
@@ -3455,7 +3455,13 @@ export default {
},
buttons: {
create: '创建知识库',
- save: '保存配置'
+ save: '保存配置',
+ saveAndClose: '保存并关闭',
+ },
+ postCreateHint: {
+ title: '创建成功',
+ footer: '可继续调整配置,设置共享与数据源,完成后点击「保存并关闭」。',
+ followUpDesc: '可在左侧配置数据源,或在「共享管理」中发布到空间',
},
wikiBrowser: {
editBtn: '编辑',
@@ -4760,6 +4766,15 @@ export default {
editor: {
createTitle: '创建智能体',
editTitle: '编辑智能体',
+ buttons: {
+ create: '创建智能体',
+ saveAndClose: '保存并关闭',
+ },
+ postCreateHint: {
+ title: '创建成功',
+ footer: '可继续调整配置,设置共享与发布渠道,完成后点击「保存并关闭」。',
+ integrationDesc: '前往集成中心配置 IM、网页嵌入等发布渠道',
+ },
basicInfo: '基本信息',
basicInfoDesc: '配置智能体的名称、描述与运行模式',
promptsConfig: '提示词',
diff --git a/frontend/src/views/agent/AgentEditorModal.test.mjs b/frontend/src/views/agent/AgentEditorModal.test.mjs
new file mode 100644
index 000000000..834c402dd
--- /dev/null
+++ b/frontend/src/views/agent/AgentEditorModal.test.mjs
@@ -0,0 +1,36 @@
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import test from 'node:test'
+
+const source = readFileSync(new URL('./AgentEditorModal.vue', import.meta.url), 'utf8')
+
+test('editing an agent closes the editor after a successful save', () => {
+ assert.match(
+ source,
+ /await updateAgent\(formData\.value\.id, formData\.value\);\s*MessagePlugin\.success\(t\('agent\.messages\.updated'\)\);\s*emit\('success'\);\s*handleClose\(\);/
+ )
+})
+
+test('the first successful create stays open for integration setup', () => {
+ const createBranch = source.match(
+ /if \(editorMode\.value === 'create'\) \{([\s\S]*?)^\s{4}\} else \{/m
+ )?.[1]
+
+ assert.ok(createBranch, 'expected to find the create branch')
+ assert.doesNotMatch(createBranch, /handleClose\(\)/)
+ assert.match(createBranch, /savedAgent\.value = created;/)
+})
+
+test('save button labels distinguish create from save-and-close', () => {
+ assert.match(
+ source,
+ /const saveButtonLabel = computed\(\(\) =>\s*editorMode\.value === 'create'\s*\? t\('agent\.editor\.buttons\.create'\)\s*: t\('agent\.editor\.buttons\.saveAndClose'\)\s*\)/
+ )
+ assert.match(source, /saveButtonLabel/)
+})
+
+test('shows a post-create hint after the first successful save', () => {
+ assert.match(source, /const isPostCreateSession = computed\(\(\) => !!savedAgent\.value\)/)
+ assert.match(source, /settings-footer-note/)
+ assert.match(source, /agent\.editor\.postCreateHint\.title/)
+})
diff --git a/frontend/src/views/agent/AgentEditorModal.vue b/frontend/src/views/agent/AgentEditorModal.vue
index 0ebb06e5f..2561e9c89 100644
--- a/frontend/src/views/agent/AgentEditorModal.vue
+++ b/frontend/src/views/agent/AgentEditorModal.vue
@@ -75,7 +75,7 @@
<div v-if="editorMode === 'edit' && editorAgent?.id" class="setting-row">
<div class="setting-info">
<label>{{ $t('integrations.agentEditor.label') }}</label>
- <p class="desc">{{ $t('integrations.agentEditor.desc') }}</p>
+ <p class="desc">{{ isPostCreateSession ? $t('agent.editor.postCreateHint.integrationDesc') : $t('integrations.agentEditor.desc') }}</p>
</div>
<div class="setting-control">
<div class="integration-inline">
@@ -1612,13 +1612,22 @@
<!-- 底部操作栏 -->
<div class="settings-footer">
- <t-button variant="outline" @click="handleClose">{{ props.readOnly ? $t('common.close') :
- $t('common.cancel')
- }}</t-button>
- <t-button v-if="!props.readOnly" theme="primary" data-guide="agent-create-submit" :loading="saving"
- @click="handleSave">{{
- $t('common.save')
- }}</t-button>
+ <p v-if="isPostCreateSession" class="settings-footer-note">
+ <t-icon name="check-circle-filled" class="settings-footer-note__icon" />
+ <span>
+ <strong>{{ $t('agent.editor.postCreateHint.title') }}</strong>
+ {{ $t('agent.editor.postCreateHint.footer') }}
+ </span>
+ </p>
+ <div class="settings-footer-actions">
+ <t-button variant="outline" @click="handleClose">{{ props.readOnly ? $t('common.close') :
+ $t('common.cancel')
+ }}</t-button>
+ <t-button v-if="!props.readOnly" theme="primary" data-guide="agent-create-submit" :loading="saving"
+ @click="handleSave">{{
+ saveButtonLabel
+ }}</t-button>
+ </div>
</div>
</div>
</div>
@@ -1714,6 +1723,12 @@ const emit = defineEmits<{
const savedAgent = ref<CustomAgent | null>(null);
const editorMode = computed(() => (savedAgent.value ? 'edit' : props.mode));
const editorAgent = computed(() => savedAgent.value ?? props.agent ?? null);
+const isPostCreateSession = computed(() => !!savedAgent.value);
+const saveButtonLabel = computed(() =>
+ editorMode.value === 'create'
+ ? t('agent.editor.buttons.create')
+ : t('agent.editor.buttons.saveAndClose')
+);
const copyAgentId = async () => {
const id = editorAgent.value?.id;
@@ -4267,12 +4282,15 @@ const handleSave = async () => {
savedAgent.value = created;
formData.value.id = created.id;
markContextualGuideDone('agentCreate')
+ currentSection.value = 'basic';
+ void loadAgentIntegrationCounts(created.id);
MessagePlugin.success(t('agent.messages.created'));
emit('success', created);
} else {
await updateAgent(formData.value.id, formData.value);
MessagePlugin.success(t('agent.messages.updated'));
emit('success');
+ handleClose();
}
} catch (e: any) {
MessagePlugin.error(e?.message || t('agent.messages.saveFailed'));
@@ -4928,12 +4946,45 @@ const handleSave = async () => {
padding: 12px 40px;
border-top: 1px solid var(--td-component-stroke);
display: flex;
+ align-items: center;
justify-content: flex-end;
- gap: 12px;
+ gap: 16px;
flex-shrink: 0;
background-color: var(--td-bg-color-container);
}
+.settings-footer-note {
+ margin: 0;
+ margin-right: auto;
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ align-items: flex-start;
+ gap: 6px;
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--td-text-color-secondary);
+
+ strong {
+ margin-right: 4px;
+ color: var(--td-text-color-primary);
+ font-weight: 500;
+ }
+
+ &__icon {
+ flex-shrink: 0;
+ margin-top: 2px;
+ font-size: 14px;
+ color: var(--td-success-color);
+ }
+}
+
+.settings-footer-actions {
+ display: flex;
+ gap: 12px;
+ flex-shrink: 0;
+}
+
/* 滚动条:与设置弹窗一致 */
.settings-nav::-webkit-scrollbar,
.content-wrapper::-webkit-scrollbar {
diff --git a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.test.mjs b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.test.mjs
new file mode 100644
index 000000000..0e75df7bf
--- /dev/null
+++ b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.test.mjs
@@ -0,0 +1,32 @@
+import assert from 'node:assert/strict'
+import { readFileSync } from 'node:fs'
+import test from 'node:test'
+
+const source = readFileSync(new URL('./KnowledgeBaseEditorModal.vue', import.meta.url), 'utf8')
+
+test('editing a knowledge base closes the editor after a successful save', () => {
+ assert.match(source, /emit\('success', kbId\)\s*handleClose\(\)/)
+})
+
+test('the first successful create stays open for follow-up configuration', () => {
+ const createBranch = source.match(
+ /if \(editorMode\.value === 'create'\) \{([\s\S]*?)^\s{4}\} else \{/m
+ )?.[1]
+
+ assert.ok(createBranch, 'expected to find the create branch')
+ assert.doesNotMatch(createBranch, /handleClose\(\)/)
+ assert.match(createBranch, /savedKbId\.value = result\.data\.id/)
+})
+
+test('save button labels distinguish create from save-and-close', () => {
+ assert.match(
+ source,
+ /const saveButtonLabel = computed\(\(\) =>\s*editorMode\.value === 'create'\s*\? t\('knowledgeEditor\.buttons\.create'\)\s*: t\('knowledgeEditor\.buttons\.saveAndClose'\)\s*\)/
+ )
+})
+
+test('shows a post-create hint after the first successful save', () => {
+ assert.match(source, /const isPostCreateSession = computed\(\(\) => !!savedKbId\.value\)/)
+ assert.match(source, /settings-footer-note/)
+ assert.match(source, /knowledgeEditor\.postCreateHint\.followUpDesc/)
+})
diff --git a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue
index 2eedad70d..0b640e931 100644
--- a/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue
+++ b/frontend/src/views/knowledge/KnowledgeBaseEditorModal.vue
@@ -14,7 +14,7 @@
<!-- 左侧导航 -->
<div class="settings-sidebar">
<div class="sidebar-header">
- <h2 class="sidebar-title">{{ mode === 'create' ? $t('knowledgeEditor.titleCreate') : $t('knowledgeEditor.titleEdit') }}</h2>
+ <h2 class="sidebar-title">{{ editorMode === 'create' ? $t('knowledgeEditor.titleCreate') : $t('knowledgeEditor.titleEdit') }}</h2>
</div>
<div class="settings-nav" data-guide="kb-editor-sidebar">
<template v-for="group in navGroups" :key="group.key">
@@ -45,11 +45,11 @@
<p class="section-desc">{{ $t('knowledgeEditor.basic.description') }}</p>
</div>
<div class="section-body">
- <div v-if="mode === 'edit' && props.kbId" class="form-item">
+ <div v-if="editorMode === 'edit' && activeKbId" class="form-item">
<label class="form-label">{{ $t('knowledgeEditor.basic.kbId') }}</label>
- <p class="form-tip">{{ $t('knowledgeEditor.basic.kbIdDesc') }}</p>
+ <p class="form-tip">{{ isPostCreateSession ? $t('knowledgeEditor.postCreateHint.followUpDesc') : $t('knowledgeEditor.basic.kbIdDesc') }}</p>
<div class="kb-id-field">
- <code class="kb-id-value" :title="props.kbId">{{ props.kbId }}</code>
+ <code class="kb-id-value" :title="activeKbId">{{ activeKbId }}</code>
<t-tooltip :content="$t('common.copy')" placement="top">
<t-button theme="default" size="small" variant="text" class="kb-id-copy"
@click="copyKbId">
@@ -63,7 +63,7 @@
<label class="form-label required">{{ $t('knowledgeEditor.basic.typeLabel') }}</label>
<t-radio-group
v-model="formData.type"
- :disabled="mode === 'edit'"
+ :disabled="editorMode === 'edit'"
data-guide="kb-create-type"
>
<t-radio-button value="document">{{ $t('knowledgeEditor.basic.typeDocument') }}</t-radio-button>
@@ -198,7 +198,7 @@
<div v-show="currentSection === 'vectorStore'" class="section">
<KBVectorStoreSettings
v-if="formData"
- :mode="mode"
+ :mode="editorMode"
:vector-store-id="formData.vectorStoreId"
:bound-source="formData.vectorStoreInfo?.source"
:bound-name="formData.vectorStoreInfo?.name"
@@ -256,7 +256,7 @@
<KBStorageSettings
:storage-backend-id="formData.storageBackendId"
:storage-provider="formData.storageProvider"
- :has-files="mode === 'edit' && hasFiles"
+ :has-files="editorMode === 'edit' && hasFiles"
@update:storage-backend-id="handleStorageBackendUpdate"
@update:storage-provider="handleStorageProviderUpdate"
/>
@@ -415,29 +415,38 @@
</div>
<!-- 数据源管理(仅编辑模式) -->
- <div v-if="mode === 'edit' && kbId && currentSection === 'datasource'" class="section">
- <DataSourceSettings :kb-id="kbId" @count="dsCount = $event" />
+ <div v-if="editorMode === 'edit' && activeKbId && currentSection === 'datasource'" class="section">
+ <DataSourceSettings :kb-id="activeKbId" @count="dsCount = $event" />
</div>
<!-- 共享设置(仅编辑模式) -->
- <div v-if="mode === 'edit' && kbId && currentSection === 'share'" class="section">
- <KBShareSettings :kb-id="kbId" :can-share="canShareKB" />
+ <div v-if="editorMode === 'edit' && activeKbId && currentSection === 'share'" class="section">
+ <KBShareSettings :kb-id="activeKbId" :can-share="canShareKB" />
</div>
<!-- 活动记录(仅编辑模式,KB 所属租户内 Owner/Admin) -->
- <div v-if="mode === 'edit' && kbId && canViewActivity && currentSection === 'activity'" class="section">
- <KnowledgeBaseActivitySettings :kb-id="kbId" :active="currentSection === 'activity'" />
+ <div v-if="editorMode === 'edit' && activeKbId && canViewActivity && currentSection === 'activity'" class="section">
+ <KnowledgeBaseActivitySettings :kb-id="activeKbId" :active="currentSection === 'activity'" />
</div>
</div>
<!-- 保存按钮 -->
<div class="settings-footer">
- <t-button theme="default" variant="outline" @click="handleClose">
- {{ $t('common.cancel') }}
- </t-button>
- <t-button theme="primary" data-guide="kb-create-submit" @click="handleSubmit" :loading="saving">
- {{ mode === 'create' ? $t('knowledgeEditor.buttons.create') : $t('knowledgeEditor.buttons.save') }}
- </t-button>
+ <p v-if="isPostCreateSession" class="settings-footer-note">
+ <t-icon name="check-circle-filled" class="settings-footer-note__icon" />
+ <span>
+ <strong>{{ $t('knowledgeEditor.postCreateHint.title') }}</strong>
+ {{ $t('knowledgeEditor.postCreateHint.footer') }}
+ </span>
+ </p>
+ <div class="settings-footer-actions">
+ <t-button theme="default" variant="outline" @click="handleClose">
+ {{ $t('common.cancel') }}
+ </t-button>
+ <t-button theme="primary" data-guide="kb-create-submit" @click="handleSubmit" :loading="saving">
+ {{ saveButtonLabel }}
+ </t-button>
+ </div>
</div>
</div>
</div>
@@ -446,7 +455,7 @@
</Transition>
</Teleport>
- <KbCreateContextualGuide :when="visible && mode === 'create'" :is-faq="isFAQ"
+ <KbCreateContextualGuide :when="visible && editorMode === 'create'" :is-faq="isFAQ"
:needs-embedding="kbCreateNeedsEmbedding" />
</template>
@@ -495,8 +504,19 @@ const emit = defineEmits<{
(e: 'success', kbId: string): void
}>()
+/** 首次保存创建成功后留在弹窗内,继续配置共享等设置 */
+const savedKbId = ref<string | null>(null)
+const editorMode = computed(() => (savedKbId.value ? 'edit' : props.mode))
+const activeKbId = computed(() => savedKbId.value ?? props.kbId)
+const isPostCreateSession = computed(() => !!savedKbId.value)
+const saveButtonLabel = computed(() =>
+ editorMode.value === 'create'
+ ? t('knowledgeEditor.buttons.create')
+ : t('knowledgeEditor.buttons.saveAndClose')
+)
+
const copyKbId = async () => {
- const id = props.kbId
+ const id = activeKbId.value
if (!id) return
try {
@@ -556,7 +576,7 @@ const kbTenantId = ref<number>(0)
// would only see 403s if we let them try. Mirror the matrix here so
// the buttons disappear instead of failing.
const canShareKB = computed(() => {
- if (!props.kbId) return false
+ if (!activeKbId.value) return false
const userId = authStore.user?.id || ''
if (kbCreatorId.value && userId && kbCreatorId.value === userId) return true
return authStore.hasRole('admin')
@@ -568,7 +588,7 @@ const isKbOwner = computed(() => {
})
const canViewActivity = computed(() => {
- if (props.mode !== 'edit' || !props.kbId) return false
+ if (editorMode.value !== 'edit' || !activeKbId.value) return false
if (Number(kbTenantId.value || 0) !== Number(authStore.currentTenantId || 0)) return false
return isKbOwner.value || authStore.hasRole('admin')
})
@@ -614,11 +634,11 @@ const navItems = computed(() => {
{ key: 'graph', icon: 'chart-bubble', label: t('knowledgeEditor.sidebar.graph') },
{ key: 'advanced', icon: 'setting', label: t('knowledgeEditor.sidebar.advanced') }
)
- if (props.mode === 'edit' && props.kbId) {
+ if (editorMode.value === 'edit' && activeKbId.value) {
items.push({ key: 'datasource', icon: 'cloud-download', label: t('knowledgeEditor.sidebar.datasource'), badge: dsCount.value || undefined })
}
}
- if (props.mode === 'edit' && props.kbId && !authStore.isLiteMode) {
+ if (editorMode.value === 'edit' && activeKbId.value && !authStore.isLiteMode) {
items.push({ key: 'share', icon: 'share', label: t('knowledgeEditor.sidebar.share') })
}
if (canViewActivity.value) {
@@ -676,7 +696,7 @@ const kbCreateNeedsEmbedding = computed(() => {
})
const applyDefaultModelsIfEmpty = () => {
- if (!formData.value || props.mode !== 'create') return
+ if (!formData.value || editorMode.value !== 'create') return
const pick = (type: ModelConfig['type']) => {
const list = allModels.value.filter((m) => m.type === type)
return list.find((m) => m.is_default) || list[0]
@@ -811,14 +831,15 @@ const loadAllModels = async (force = false) => {
}
// 加载知识库数据(编辑模式)
-const loadKBData = async () => {
- if (props.mode !== 'edit' || !props.kbId) return
+const loadKBData = async (kbIdOverride?: string) => {
+ const kbId = kbIdOverride ?? activeKbId.value
+ if (editorMode.value !== 'edit' || !kbId) return
loading.value = true
try {
const [kbInfo, filesResult] = await Promise.all([
- getKnowledgeBaseById(props.kbId),
- listKnowledgeFiles(props.kbId, { page: 1, page_size: 1 })
+ getKnowledgeBaseById(kbId),
+ listKnowledgeFiles(kbId, { page: 1, page_size: 1 })
])
if (!kbInfo || !kbInfo.data) {
@@ -974,7 +995,7 @@ const handleGranularityChange = (value: string | number | boolean) => {
}
}
-const isIndexingLocked = computed(() => props.mode === 'edit' && hasFiles.value)
+const isIndexingLocked = computed(() => editorMode.value === 'edit' && hasFiles.value)
const toggleVectorIndexing = () => {
if (!formData.value) return
@@ -1008,7 +1029,7 @@ const isWikiOnlyStrategy = computed(() => {
// 仅在创建模式、用户未改过分块设置时,随索引策略自动应用/撤销 Wiki-only 预设。
// 编辑模式严格保持后端已有配置不变,避免误改。
watch(isWikiOnlyStrategy, (wikiOnly) => {
- if (props.mode !== 'create') return
+ if (editorMode.value !== 'create') return
if (!formData.value) return
if (chunkingDirty.value) return
const preset = wikiOnly ? WIKI_ONLY_CHUNKING_PRESET : DEFAULT_CHUNKING_PRESET
@@ -1050,7 +1071,7 @@ const handleAddWikiModel = () => {
const handleStorageProviderUpdate = (value: string) => {
if (formData.value) {
- formData.value.storageProvider = props.mode === 'create'
+ formData.value.storageProvider = editorMode.value === 'create'
? editorResources.resolveUsableStorageProvider(value || tenantDefaultStorageProvider.value)
: (value || tenantDefaultStorageProvider.value || 'local')
}
@@ -1076,7 +1097,7 @@ async function loadTenantDefaultStorageProvider(force = false) {
/** Resolved storage provider for create payload (never silently default to local before tenant config loads). */
function resolvedStorageProvider(): string {
const explicit = formData.value?.storageProvider?.trim()
- if (props.mode === 'create') {
+ if (editorMode.value === 'create') {
return editorResources.resolveUsableStorageProvider(explicit || tenantDefaultStorageProvider.value)
}
if (explicit) return explicit
@@ -1298,7 +1319,7 @@ const handleSubmit = async () => {
// 编辑模式下,若已有文件且存储引擎发生了变化,弹窗确认
if (
- props.mode === 'edit' &&
+ editorMode.value === 'edit' &&
hasFiles.value &&
formData.value &&
initialStorageProvider.value &&
@@ -1331,18 +1352,22 @@ const doSubmit = async () => {
throw new Error(t('knowledgeEditor.messages.buildDataFailed'))
}
- if (props.mode === 'create') {
+ if (editorMode.value === 'create') {
// 创建模式:一次性创建知识库及所有配置
const result: any = await createKnowledgeBase(data)
if (!result.success || !result.data?.id) {
throw new Error(result.message || t('knowledgeEditor.messages.createFailed'))
}
+ savedKbId.value = result.data.id
+ currentSection.value = 'basic'
+ await loadKBData(savedKbId.value)
MessagePlugin.success(t('knowledgeEditor.messages.createSuccess'))
markContextualGuideDone('kbCreate')
- emit('success', result.data.id)
+ emit('success', savedKbId.value)
} else {
// 编辑模式:分别更新基本信息和配置
- if (!props.kbId) {
+ const kbId = activeKbId.value
+ if (!kbId) {
throw new Error(t('knowledgeEditor.messages.missingId'))
}
@@ -1371,7 +1396,7 @@ const doSubmit = async () => {
graph_enabled: formData.value.indexingStrategy?.graphEnabled ?? false,
}
}
- await updateKnowledgeBase(props.kbId, {
+ await updateKnowledgeBase(kbId, {
name: data.name,
description: data.description,
config: updateConfig
@@ -1419,7 +1444,7 @@ const doSubmit = async () => {
}
}
- await updateKBConfig(props.kbId, config)
+ await updateKBConfig(kbId, config)
MessagePlugin.success(t('knowledgeEditor.messages.updateSuccess'))
// Check if indexing strategy changed and offer rebuild
@@ -1441,7 +1466,7 @@ const doSubmit = async () => {
onConfirm: async () => {
dialog.destroy()
try {
- const result: any = await rebuildKBIndex(props.kbId!)
+ const result: any = await rebuildKBIndex(kbId)
const count = result?.data?.document_count ?? 0
MessagePlugin.success(t('knowledgeEditor.indexing.rebuildSuccess', { count }))
} catch (e) {
@@ -1456,10 +1481,9 @@ const doSubmit = async () => {
}
}
- emit('success', props.kbId)
+ emit('success', kbId)
+ handleClose()
}
-
- handleClose()
} catch (error: any) {
console.error('Knowledge base operation failed:', error)
// Vector-store-binding error codes from the server. Both indicate
@@ -1486,6 +1510,7 @@ const doSubmit = async () => {
// 重置所有状态
const resetState = () => {
+ savedKbId.value = null
currentSection.value = 'basic'
formData.value = null
hasFiles.value = false
@@ -1931,10 +1956,43 @@ watch(
}
.settings-footer {
- padding: 16px 32px;
+ padding: 12px 40px;
border-top: 1px solid var(--td-component-stroke);
display: flex;
+ align-items: center;
justify-content: flex-end;
+ gap: 16px;
+ flex-shrink: 0;
+}
+
+.settings-footer-note {
+ margin: 0;
+ margin-right: auto;
+ flex: 1;
+ min-width: 0;
+ display: flex;
+ align-items: flex-start;
+ gap: 6px;
+ font-size: 13px;
+ line-height: 20px;
+ color: var(--td-text-color-secondary);
+
+ strong {
+ margin-right: 4px;
+ color: var(--td-text-color-primary);
+ font-weight: 500;
+ }
+
+ &__icon {
+ flex-shrink: 0;
+ margin-top: 2px;
+ font-size: 14px;
+ color: var(--td-success-color);
+ }
+}
+
+.settings-footer-actions {
+ display: flex;
gap: 12px;
flex-shrink: 0;
}
diff --git a/frontend/src/views/knowledge/KnowledgeBaseList.vue b/frontend/src/views/knowledge/KnowledgeBaseList.vue
index 25a3578ca..0da588be9 100644
--- a/frontend/src/views/knowledge/KnowledgeBaseList.vue
+++ b/frontend/src/views/knowledge/KnowledgeBaseList.vue
@@ -1707,7 +1707,7 @@ const handleKBEditorSuccess = (kbId: string) => {
// 列表页编辑同样要让单 KB 详情缓存失效,否则侧栏 / 详情页 60s 内仍显示旧信息
chatResources.invalidateKnowledgeBaseDetail(kbId)
fetchList(true).then(() => {
- if (shouldOpenDetailForUploadGuide && kbId) {
+ if (shouldOpenDetailForUploadGuide && kbId && !uiStore.showKBEditorModal) {
goDetail(kbId)
}
// 如果是从路由参数中获取的高亮ID,触发闪烁效果