feat: 知识库递归导入(从指定父节点,不需要空间权限)

- feishu_service.py: import_space_nodes 改为 import_nodes_from_parent
  从指定父节点递归获取子节点,不需要空间级别权限
- admin_knowledge.py: import API 增加 parent_node_token 参数
- api.ts/App.vue: 前端增加父节点 NodeToken 输入框
This commit is contained in:
2026-07-08 18:50:46 +08:00
parent f4196612d4
commit 3598e34819
4 changed files with 129 additions and 0 deletions

View File

@@ -37,6 +37,9 @@ const chatDetailOpen = ref(false);
const recordTab = ref("chats");
const editingModelId = ref<number | null>(null);
const editingKnowledgeId = ref<number | null>(null);
const batchSpaceId = ref("");
const batchParentToken = ref("");
const batchImporting = ref(false);
const agentDebugging = ref(false);
const agentPreviewMessages = ref<{ role: "user" | "assistant" | "system"; content: string }[]>([
{ role: "assistant", content: "选择模型和知识库后,可以在这里调试 Agent 的真实问答效果。" },
@@ -589,6 +592,27 @@ function resetKnowledgeForm() {
Object.assign(knowledgeForm, { name: "", feishuSpaceId: "", feishuNodeId: "", status: 1, remark: "" });
}
async function batchImportKnowledge() {
const spaceId = batchSpaceId.value.trim();
const parentToken = batchParentToken.value.trim();
if (!spaceId || !parentToken) {
ElMessage.warning("请输入 SpaceID 和父节点 NodeToken");
return;
}
batchImporting.value = true;
try {
const result = await api.importKnowledgeFromSpace(JSON.stringify({ spaceId, parent_node_token: parentToken }));
ElMessage.success(`导入完成:新增 ${result.imported} 个,跳过 ${result.skipped}`);
batchSpaceId.value = "";
batchParentToken.value = "";
await loadCurrentMenu();
} catch (e: any) {
ElMessage.error(e.message || "导入失败");
} finally {
batchImporting.value = false;
}
}
async function savePrompt() {
const result = await api.savePrompt(promptContent.value);
promptContent.value = result.promptContent;
@@ -1101,6 +1125,13 @@ function buildChatQuery() {
<el-button @click="resetKnowledgeForm">清空</el-button>
</div>
</el-form>
<el-divider />
<div class="batch-import-row">
<el-input v-model="batchSpaceId" placeholder="SpaceID" style="width: 220px" />
<el-input v-model="batchParentToken" placeholder="父节点 NodeToken如 wikcnXXX" style="width: 260px" />
<el-button type="primary" @click="batchImportKnowledge" :loading="batchImporting">递归导入子节点</el-button>
</div>
<el-table :data="knowledge" stripe>
<el-table-column prop="id" label="ID" width="80" />
<el-table-column prop="name" label="名称" min-width="160" />