feat(api): 将万川平台配置迁移至后端存储

- 移除前端localStorage依赖,改用后端SQLite作为唯一数据源
- 新增getWanchuanConfig和saveWanchuanConfig函数用于配置读写
- 添加getBoundKnowledgeBase函数统一获取绑定知识库信息
- 支持桌面应用端口变化时正确读取配置

refactor(settings): 重构万川平台配置管理逻辑

- 移除localStorage配置存储,改为后端API调用
- 实现配置自动恢复和防抖保存机制
- 添加token过期自动重登功能
- 优化知识库选择和连接状态管理

fix(knowledge): 修复知识库上传异步问题

- 将getBoundKnowledgeBase调用改为await异步处理
- 统一各页面的知识库信息获取方式
- 修正上传接口datasetId使用逻辑

feat(electron): 添加chatlog.exe存在性检查

- 新增ensureChatlogExe函数验证执行文件存在
- 防止杀毒软件误删导致的ENONENT错误
- 提供用户友好的错误提示和解决方案
This commit is contained in:
2026-06-24 10:13:20 +08:00
parent f9f8a7b13d
commit eecbe4172e
8 changed files with 13596 additions and 13278 deletions

View File

@@ -22,7 +22,7 @@ import {
import MessageBubble from '../components/MessageBubble'
import ReportDocumentView from '../components/ReportDocumentView'
import { exportWordDoc } from '../utils/wordExport'
import { uploadToKnowledgeBase, getWanchuanKnowledgeBases } from '../api/wanchuan'
import { uploadToKnowledgeBase, getWanchuanKnowledgeBases, getBoundKnowledgeBase } from '../api/wanchuan'
const TYPE_MAP = {
1: 0,
@@ -648,19 +648,13 @@ export default function TopicsPage({ sessions = [], onToast }) {
if (uploadingToKb) return
setUploadingToKb(true)
try {
const raw = localStorage.getItem('chatlab_wanchuan_config')
if (!raw) return
const bound = JSON.parse(raw)
const kbInfo = bound?.selectedKbInfo
// 上传接口必须使用 datasetId。selectedKbId 现已统一存为 datasetId
// selectedKbInfo.kbDatasetId 为冗余备份,两者任一可用。
const datasetId = kbInfo?.kbDatasetId || bound?.selectedKbId
if (!bound?.platformUrl || !datasetId) return
const bound = await getBoundKnowledgeBase()
if (!bound) return
// 上传接口必须使用 datasetId
const datasetId = bound.kbDatasetId || bound.id
if (!bound.platformUrl || !datasetId) return
const safeTitle = (reportTitle || 'report').replace(/[^a-zA-Z0-9\u4e00-\u9fa5_-]/g, '_').slice(0, 50)
// 上传接口必须使用 datasetId而不是知识库对象的 id
console.log('[上传KB] datasetId:', datasetId, 'kbName:', kbInfo?.kbName || 'N/A')
const blob = new Blob([content], { type: 'text/markdown;charset=utf-8' })
const file = new File([blob], `${safeTitle}.md`, { type: 'text/markdown' })
// 上传接口使用 datasetId