Compare commits

..

8 Commits

Author SHA1 Message Date
e18e34b065 feat: 优化前端导航和后端服务
- 更新侧边栏导航
- 优化 MCP 页面
- 调整 model service

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:56:29 +08:00
dd4d4d54b8 feat: 新增 Knowledge 知识库后端服务
- 添加 Knowledge 实体定义
- 添加 Knowledge 仓储层
- 添加 Knowledge 服务层

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:56:24 +08:00
4d2297d964 refactor: 重构 Settings 页面
- 移除独立的 Settings.vue 主文件
- 合并到 knowledge 模块统一管理

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:56:12 +08:00
58d263de06 docs: 添加知识库相关截图
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:56:05 +08:00
d31b278f21 chore: 清理过期数据库配置并添加新需求文档
- 删除旧的数据库连接配置文件
- 添加上传 API 需求文档
- 添加知识库 API 需求文档

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:55:59 +08:00
6693fcaf38 feat: 优化 MCP 页面
- 改进 MCP 页面展示和交互
- 优化样式

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:55:50 +08:00
3cc1461be2 feat: 增强 Knowledge 页面功能
- 优化知识库创建流程
- 添加更多知识库配置选项
- 改进样式和交互

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:55:44 +08:00
4d4a756f4f feat: 新增文件上传服务
- 添加 UploadHandler 处理文件上传
- 添加 UploadService 实现文件存储
- 配置上传文件大小限制和存储路径

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:54:41 +08:00
40 changed files with 2088 additions and 1060 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 300 KiB

View File

@@ -82,6 +82,10 @@ func main() {
subTableService := service.NewSubTableService(subTableRepo, dbRepo)
neo4jService := service.NewNeo4jService(dbRepo)
modelService := service.NewModelService(modelRepo)
uploadService, err := service.NewUploadService(cfg)
if err != nil {
log.Printf("Warning: Failed to initialize upload service: %v (files will not be available)", err)
}
// 6. 初始化 Handler
dbHandler := handler.NewDatabaseHandler(dbService)
@@ -89,6 +93,10 @@ func main() {
neo4jHandler := handler.NewNeo4jHandler(neo4jService)
modelHandler := handler.NewModelHandler(modelService)
systemHandler := handler.NewSystemHandler()
var uploadHandler *handler.UploadHandler
if uploadService != nil {
uploadHandler = handler.NewUploadHandler(uploadService)
}
// 7. 设置路由
r := gin.New()
@@ -180,6 +188,17 @@ func main() {
// 系统信息模块
r.GET("/system/info", systemHandler.GetSystemInfo)
// 文件上传模块
if uploadHandler != nil {
// 本地文件静态服务
if cfg.UploadMode == "local" {
r.Static("/files", cfg.UploadLocalPath)
}
// 上传路由
r.POST("/upload", uploadHandler.Upload)
r.DELETE("/upload/:filename", uploadHandler.Delete)
}
// 8. 启动服务
log.Printf("Server starting on :%s", cfg.Port)
if err := r.Run(":" + cfg.Port); err != nil {

View File

@@ -4,3 +4,15 @@ jwt_secret: "dev-secret-key"
# Docker 内访问用 db:3306本地访问用 localhost:6036
database_url: "root:root@tcp(localhost:6036)/x_agents?charset=utf8mb4&parseTime=True&loc=Local"
python_service_url: "http://localhost:8081"
# 文件上传配置 (local 或 minio)
upload_mode: "local"
upload_local_path: "resource/files"
server_base_url: "http://localhost:8082"
# MinIO 配置
minio_endpoint: "localhost:9000"
minio_access_key: ""
minio_secret_key: ""
minio_bucket: "x-agents"
minio_use_ssl: false

View File

@@ -1,15 +1,15 @@
module x-agents/server
go 1.21
go 1.25
require (
github.com/gin-gonic/gin v1.9.1
github.com/go-sql-driver/mysql v1.7.0
github.com/golang-jwt/jwt/v5 v5.2.0
github.com/google/uuid v1.5.0
github.com/google/uuid v1.6.0
github.com/lib/pq v1.10.9
github.com/spf13/viper v1.18.2
golang.org/x/crypto v0.16.0
golang.org/x/crypto v0.46.0
gorm.io/driver/mysql v1.5.2
gorm.io/gorm v1.25.5
)
@@ -17,9 +17,11 @@ require (
require (
github.com/bytedance/sonic v1.9.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ini/ini v1.67.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
@@ -29,16 +31,23 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/klauspost/compress v1.18.2 // indirect
github.com/klauspost/cpuid/v2 v2.2.11 // indirect
github.com/klauspost/crc32 v1.3.0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/minio/crc64nvme v1.1.1 // indirect
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.99 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/philhofer/fwd v1.2.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rs/xid v1.6.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
@@ -47,6 +56,7 @@ require (
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tinylib/msgp v1.6.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
@@ -54,11 +64,12 @@ require (
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.48.0 // indirect
golang.org/x/sys v0.39.0 // indirect
golang.org/x/text v0.32.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect

View File

@@ -8,6 +8,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
@@ -18,6 +20,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.9.1 h1:4idEAncQnU5cB7BeOkPtxjfCSye0AAm1R0RVIqJ+Jmg=
github.com/gin-gonic/gin v1.9.1/go.mod h1:hPrL7YrpYKXt5YId3A/Tnip5kqbEAP+KLuI3SUcPTeU=
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
@@ -43,6 +47,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU=
github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
@@ -51,9 +57,16 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/klauspost/cpuid/v2 v2.2.11 h1:0OwqZRYI2rFrjS4kvkDnqJkKHdHaRnCm68/DY4OxRzU=
github.com/klauspost/cpuid/v2 v2.2.11/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
github.com/klauspost/crc32 v1.3.0 h1:sSmTt3gUt81RP655XGZPElI0PelVTZ6YwCRnPSupoFM=
github.com/klauspost/crc32 v1.3.0/go.mod h1:D7kQaZhnkX/Y0tstFGf8VUzv2UofNGqCjnC3zdHB0Hw=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
@@ -68,6 +81,12 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/minio/crc64nvme v1.1.1 h1:8dwx/Pz49suywbO+auHCBpCtlW1OfpcLN7wYgVR6wAI=
github.com/minio/crc64nvme v1.1.1/go.mod h1:eVfm2fAzLlxMdUGc0EEBGSMmPwmXD5XiNRpnu9J3bvg=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.99 h1:2vH/byrwUkIpFQFOilvTfaUpvAX3fEFhEzO+DR3DlCE=
github.com/minio/minio-go/v7 v7.0.99/go.mod h1:EtGNKtlX20iL2yaYnxEigaIvj0G0GwSDnifnG8ClIdw=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
@@ -77,6 +96,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4=
github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc=
github.com/philhofer/fwd v1.2.0 h1:e6DnBTl7vGY+Gz322/ASL4Gyp1FspeMvx1RNDoToZuM=
github.com/philhofer/fwd v1.2.0/go.mod h1:RqIHx9QI14HlwKwm98g9Re5prTQ6LdeRQn+gXJFxsJM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -84,6 +105,8 @@ github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
@@ -114,6 +137,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/tinylib/msgp v1.6.1 h1:ESRv8eL3u+DNHUoSAAQRE50Hm162zqAnBoGv9PzScPY=
github.com/tinylib/msgp v1.6.1/go.mod h1:RSp0LW9oSxFut3KzESt5Voq4GVWyS+PSulT77roAqEA=
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
@@ -128,15 +153,21 @@ go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU=
golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU=
golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -147,8 +178,12 @@ golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk=
golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU=
golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=

View File

@@ -15,7 +15,17 @@ type Config struct {
Port string
JWTSecret string
DatabaseURL string
PythonServiceURL string
PythonServiceURL string
// 文件上传配置
UploadMode string // "local" 或 "minio"
UploadLocalPath string // 本地存储路径,如 "resource/files"
ServerBaseURL string // 服务器基础 URL用于生成本地文件 URL
// MinIO 配置
MinIOEndpoint string
MinIOAccessKey string
MinIOSecretKey string
MinIOBucket string
MinIOUseSSL bool
}
func Load() *Config {
@@ -30,16 +40,35 @@ func Load() *Config {
viper.SetDefault("jwt_secret", "your-secret-key-change-in-production")
viper.SetDefault("python_service_url", "http://localhost:8081")
viper.SetDefault("database_url", "root:root@tcp(localhost:3306)/x_agents?charset=utf8mb4&parseTime=True&loc=Local")
// 文件上传默认配置
viper.SetDefault("upload_mode", "local")
viper.SetDefault("upload_local_path", "resource/files")
viper.SetDefault("server_base_url", "http://localhost:8080")
viper.SetDefault("minio_endpoint", "localhost:9000")
viper.SetDefault("minio_access_key", "")
viper.SetDefault("minio_secret_key", "")
viper.SetDefault("minio_bucket", "x-agents")
viper.SetDefault("minio_use_ssl", false)
if err := viper.ReadInConfig(); err != nil {
log.Printf("Using default config: %v", err)
}
return &Config{
Port: viper.GetString("port"),
JWTSecret: viper.GetString("jwt_secret"),
DatabaseURL: viper.GetString("database_url"),
Port: viper.GetString("port"),
JWTSecret: viper.GetString("jwt_secret"),
DatabaseURL: viper.GetString("database_url"),
PythonServiceURL: viper.GetString("python_service_url"),
// 文件上传配置
UploadMode: viper.GetString("upload_mode"),
UploadLocalPath: viper.GetString("upload_local_path"),
ServerBaseURL: viper.GetString("server_base_url"),
// MinIO 配置
MinIOEndpoint: viper.GetString("minio_endpoint"),
MinIOAccessKey: viper.GetString("minio_access_key"),
MinIOSecretKey: viper.GetString("minio_secret_key"),
MinIOBucket: viper.GetString("minio_bucket"),
MinIOUseSSL: viper.GetBool("minio_use_ssl"),
}
}

View File

@@ -0,0 +1,60 @@
package handler
import (
"net/http"
"github.com/gin-gonic/gin"
"x-agents/server/internal/service"
)
type UploadHandler struct {
uploadService *service.UploadService
}
func NewUploadHandler(uploadService *service.UploadService) *UploadHandler {
return &UploadHandler{uploadService: uploadService}
}
// Upload 上传文件
func (h *UploadHandler) Upload(c *gin.Context) {
file, err := c.FormFile("file")
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "No file uploaded"})
return
}
// 检查文件大小(最大 100MB
if file.Size > 100*1024*1024 {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "File too large (max 100MB)"})
return
}
result, err := h.uploadService.Upload(file)
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "message": err.Error()})
return
}
if !result.Success {
c.JSON(http.StatusInternalServerError, result)
return
}
c.JSON(http.StatusOK, result)
}
// Delete 删除文件
func (h *UploadHandler) Delete(c *gin.Context) {
filename := c.Param("filename")
if filename == "" {
c.JSON(http.StatusBadRequest, gin.H{"success": false, "message": "Filename is required"})
return
}
if err := h.uploadService.DeleteFile(filename); err != nil {
c.JSON(http.StatusInternalServerError, gin.H{"success": false, "message": err.Error()})
return
}
c.JSON(http.StatusOK, gin.H{"success": true, "message": "File deleted"})
}

View File

@@ -0,0 +1,119 @@
package model
import (
"database/sql/driver"
"encoding/json"
"errors"
"time"
)
// ParsingConfig 解析配置
type ParsingConfig struct {
Engine string `json:"engine"` // markitdown / docling
DoclingURL string `json:"docling_url"` // Docling 服务 URL
EnablePDF bool `json:"enable_pdf"` // 是否启用 PDF 解析
Pandoc bool `json:"pandoc"` // 是否启用 Pandoc
}
// Scan 实现 sql.Scanner 接口
func (p *ParsingConfig) Scan(value interface{}) error {
if value == nil {
return nil
}
bytes, ok := value.([]byte)
if !ok {
return errors.New("type assertion to []byte failed")
}
return json.Unmarshal(bytes, p)
}
// Value 实现 driver.Valuer 接口
func (p ParsingConfig) Value() (driver.Value, error) {
return json.Marshal(p)
}
// KnowledgeBase 知识库
type KnowledgeBase struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36)"`
Name string `json:"name" gorm:"type:varchar(255);not null"`
Description string `json:"description" gorm:"type:text"`
LLMModelID string `json:"llm_model_id" gorm:"type:varchar(36);not null"`
EmbeddingModelID string `json:"embedding_model_id" gorm:"type:varchar(36);not null"`
ParsingConfig ParsingConfig `json:"parsing_config" gorm:"type:json"`
Status string `json:"status" gorm:"type:varchar(20);default:active"` // active / inactive
DocumentCount int `json:"document_count" gorm:"default:0"`
ChunkCount int `json:"chunk_count" gorm:"default:0"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func (KnowledgeBase) TableName() string {
return "knowledge_base"
}
// KnowledgeDocument 知识库文档
type KnowledgeDocument struct {
ID string `json:"id" gorm:"primaryKey;type:varchar(36)"`
KnowledgeBaseID string `json:"knowledge_base_id" gorm:"type:varchar(36);not null;index"`
Name string `json:"name" gorm:"type:varchar(255);not null"`
FileKey string `json:"file_key" gorm:"type:varchar(500)"`
FileSize int64 `json:"file_size" gorm:"type:bigint;default:0"`
Status string `json:"status" gorm:"type:varchar(20);default:parsing"` // parsing / parsed / failed
ChunkCount int `json:"chunk_count" gorm:"default:0"`
UploadedAt time.Time `json:"uploaded_at"`
}
func (KnowledgeDocument) TableName() string {
return "knowledge_document"
}
// ========== Request/Response ==========
// CreateKnowledgeRequest 创建知识库请求
type CreateKnowledgeRequest struct {
Name string `json:"name" binding:"required"`
Description string `json:"description"`
LLMModelID string `json:"llm_model_id" binding:"required"`
EmbeddingModelID string `json:"embedding_model_id" binding:"required"`
ParsingConfig ParsingConfig `json:"parsing_config" binding:"required"`
}
// UpdateKnowledgeRequest 更新知识库请求
type UpdateKnowledgeRequest struct {
Name string `json:"name"`
Description string `json:"description"`
LLMModelID string `json:"llm_model_id"`
EmbeddingModelID string `json:"embedding_model_id"`
ParsingConfig ParsingConfig `json:"parsing_config"`
Status string `json:"status"`
}
// KnowledgeListResponse 知识库列表响应
type KnowledgeListResponse struct {
List []KnowledgeBase `json:"data"`
}
// KnowledgeDetailResponse 知识库详情响应
type KnowledgeDetailResponse struct {
KnowledgeBase KnowledgeBase `json:"data"`
}
// DocumentListResponse 文档列表响应
type DocumentListResponse struct {
List []KnowledgeDocument `json:"data"`
}
// UploadDocumentResponse 上传文档响应
type UploadDocumentResponse struct {
Success bool `json:"success"`
ID string `json:"id"`
Document KnowledgeDocument `json:"document"`
Message string `json:"message"`
}
// DocumentPreviewResponse 文档预览响应
type DocumentPreviewResponse struct {
TotalPages int `json:"total_pages"`
CurrentPage int `json:"current_page"`
Content string `json:"content"`
}

View File

@@ -0,0 +1,97 @@
package repository
import (
"x-agents/server/internal/model"
"gorm.io/gorm"
)
type KnowledgeRepository struct {
db *gorm.DB
}
func NewKnowledgeRepository(db *gorm.DB) *KnowledgeRepository {
return &KnowledgeRepository{db: db}
}
// Create 创建知识库
func (r *KnowledgeRepository) Create(kb *model.KnowledgeBase) error {
return r.db.Create(kb).Error
}
// FindByID 根据ID查询
func (r *KnowledgeRepository) FindByID(id string) (*model.KnowledgeBase, error) {
var kb model.KnowledgeBase
err := r.db.First(&kb, "id = ?", id).Error
if err != nil {
return nil, err
}
return &kb, nil
}
// FindAll 查询所有
func (r *KnowledgeRepository) FindAll() ([]model.KnowledgeBase, error) {
var list []model.KnowledgeBase
err := r.db.Order("created_at DESC").Find(&list).Error
return list, err
}
// Update 更新知识库
func (r *KnowledgeRepository) Update(id string, updates map[string]interface{}) error {
return r.db.Model(&model.KnowledgeBase{}).Where("id = ?", id).Updates(updates).Error
}
// Delete 删除知识库
func (r *KnowledgeRepository) Delete(id string) error {
return r.db.Delete(&model.KnowledgeBase{}, "id = ?", id).Error
}
// ========== Document ==========
// CreateDocument 创建文档
func (r *KnowledgeRepository) CreateDocument(doc *model.KnowledgeDocument) error {
return r.db.Create(doc).Error
}
// FindDocumentByID 根据ID查询文档
func (r *KnowledgeRepository) FindDocumentByID(id string) (*model.KnowledgeDocument, error) {
var doc model.KnowledgeDocument
err := r.db.First(&doc, "id = ?", id).Error
if err != nil {
return nil, err
}
return &doc, nil
}
// FindDocumentsByKBID 根据知识库ID查询文档
func (r *KnowledgeRepository) FindDocumentsByKBID(kbID string, status string) ([]model.KnowledgeDocument, error) {
var list []model.KnowledgeDocument
query := r.db.Where("knowledge_base_id = ?", kbID).Order("uploaded_at DESC")
if status != "" && status != "all" {
query = query.Where("status = ?", status)
}
err := query.Find(&list).Error
return list, err
}
// UpdateDocument 更新文档
func (r *KnowledgeRepository) UpdateDocument(id string, updates map[string]interface{}) error {
return r.db.Model(&model.KnowledgeDocument{}).Where("id = ?", id).Updates(updates).Error
}
// DeleteDocument 删除文档
func (r *KnowledgeRepository) DeleteDocument(id string) error {
return r.db.Delete(&model.KnowledgeDocument{}, "id = ?", id).Error
}
// DeleteDocumentsByKBID 删除知识库下所有文档
func (r *KnowledgeRepository) DeleteDocumentsByKBID(kbID string) error {
return r.db.Delete(&model.KnowledgeDocument{}, "knowledge_base_id = ?", kbID).Error
}
// CountDocumentsByKBID 统计知识库下文档数
func (r *KnowledgeRepository) CountDocumentsByKBID(kbID string) (int64, error) {
var count int64
err := r.db.Model(&model.KnowledgeDocument{}).Where("knowledge_base_id = ?", kbID).Count(&count).Error
return count, err
}

View File

@@ -0,0 +1,235 @@
package service
import (
"mime/multipart"
"time"
"github.com/google/uuid"
"x-agents/server/internal/model"
"x-agents/server/internal/repository"
)
type KnowledgeService struct {
repo *repository.KnowledgeRepository
modelRepo *repository.ModelRepository
uploadService *UploadService
}
func NewKnowledgeService(repo *repository.KnowledgeRepository, modelRepo *repository.ModelRepository, uploadService *UploadService) *KnowledgeService {
return &KnowledgeService{
repo: repo,
modelRepo: modelRepo,
uploadService: uploadService,
}
}
// Create 创建知识库
func (s *KnowledgeService) Create(req model.CreateKnowledgeRequest) (*model.KnowledgeBase, error) {
// 验证 LLM 模型存在
if _, err := s.modelRepo.FindByID(req.LLMModelID); err != nil {
return nil, err
}
// 验证 Embedding 模型存在
if _, err := s.modelRepo.FindByID(req.EmbeddingModelID); err != nil {
return nil, err
}
kb := &model.KnowledgeBase{
ID: uuid.New().String(),
Name: req.Name,
Description: req.Description,
LLMModelID: req.LLMModelID,
EmbeddingModelID: req.EmbeddingModelID,
ParsingConfig: req.ParsingConfig,
Status: "active",
DocumentCount: 0,
ChunkCount: 0,
}
// 设置默认值
if kb.ParsingConfig.EnablePDF == false && kb.ParsingConfig.EnablePDF != true {
kb.ParsingConfig.EnablePDF = true
}
if kb.ParsingConfig.Pandoc == false && kb.ParsingConfig.Pandoc != true {
kb.ParsingConfig.Pandoc = true
}
if err := s.repo.Create(kb); err != nil {
return nil, err
}
return kb, nil
}
// List 获取知识库列表
func (s *KnowledgeService) List() ([]model.KnowledgeBase, error) {
return s.repo.FindAll()
}
// GetByID 获取知识库详情
func (s *KnowledgeService) GetByID(id string) (*model.KnowledgeBase, error) {
return s.repo.FindByID(id)
}
// Update 更新知识库
func (s *KnowledgeService) Update(id string, req model.UpdateKnowledgeRequest) error {
updates := make(map[string]interface{})
if req.Name != "" {
updates["name"] = req.Name
}
if req.Description != "" {
updates["description"] = req.Description
}
if req.LLMModelID != "" {
// 验证模型存在
if _, err := s.modelRepo.FindByID(req.LLMModelID); err != nil {
return err
}
updates["llm_model_id"] = req.LLMModelID
}
if req.EmbeddingModelID != "" {
// 验证模型存在
if _, err := s.modelRepo.FindByID(req.EmbeddingModelID); err != nil {
return err
}
updates["embedding_model_id"] = req.EmbeddingModelID
}
if req.ParsingConfig.Engine != "" {
updates["parsing_config"] = req.ParsingConfig
}
if req.Status != "" {
updates["status"] = req.Status
}
return s.repo.Update(id, updates)
}
// Delete 删除知识库
func (s *KnowledgeService) Delete(id string) error {
// 先删除关联的文档
if err := s.repo.DeleteDocumentsByKBID(id); err != nil {
return err
}
return s.repo.Delete(id)
}
// ListDocuments 获取知识库下的文档列表
func (s *KnowledgeService) ListDocuments(kbID string, status string) ([]model.KnowledgeDocument, error) {
return s.repo.FindDocumentsByKBID(kbID, status)
}
// UploadDocument 上传文档到知识库
func (s *KnowledgeService) UploadDocument(kbID string, file *multipart.FileHeader) (*model.KnowledgeDocument, error) {
// 验证知识库存在
_, err := s.repo.FindByID(kbID)
if err != nil {
return nil, err
}
// 上传文件
result, err := s.uploadService.Upload(file)
if err != nil {
return nil, err
}
if !result.Success {
return nil, nil
}
// 创建文档记录
doc := &model.KnowledgeDocument{
ID: uuid.New().String(),
KnowledgeBaseID: kbID,
Name: file.Filename,
FileKey: result.FileKey,
FileSize: file.Size,
Status: "parsing",
UploadedAt: time.Now(),
}
if err := s.repo.CreateDocument(doc); err != nil {
return nil, err
}
// 更新知识库文档数
s.updateDocumentCount(kbID)
return doc, nil
}
// DeleteDocument 删除文档
func (s *KnowledgeService) DeleteDocument(kbID, docID string) error {
// 验证文档存在
doc, err := s.repo.FindDocumentByID(docID)
if err != nil {
return err
}
if doc.KnowledgeBaseID != kbID {
return nil
}
// 删除文件
if doc.FileKey != "" {
s.uploadService.DeleteFile(doc.FileKey + getFileExt(doc.Name))
}
// 删除文档记录
if err := s.repo.DeleteDocument(docID); err != nil {
return err
}
// 更新知识库文档数
s.updateDocumentCount(kbID)
return nil
}
// ReparseDocument 重新解析文档
func (s *KnowledgeService) ReparseDocument(kbID, docID string) error {
// 验证文档存在
doc, err := s.repo.FindDocumentByID(docID)
if err != nil {
return err
}
if doc.KnowledgeBaseID != kbID {
return nil
}
// 重置状态为 parsing
return s.repo.UpdateDocument(docID, map[string]interface{}{"status": "parsing"})
}
// GetDocumentPreview 获取文档预览
func (s *KnowledgeService) GetDocumentPreview(kbID, docID string, page int) (*model.DocumentPreviewResponse, error) {
// 验证文档存在
doc, err := s.repo.FindDocumentByID(docID)
if err != nil {
return nil, err
}
if doc.KnowledgeBaseID != kbID {
return nil, nil
}
// 简单实现:返回文件 URL实际应由 Python 服务处理)
fileURL, err := s.uploadService.GetFileURL(doc.FileKey + getFileExt(doc.Name))
if err != nil {
return nil, err
}
return &model.DocumentPreviewResponse{
TotalPages: 1,
CurrentPage: page,
Content: fileURL,
}, nil
}
// updateDocumentCount 更新知识库文档数
func (s *KnowledgeService) updateDocumentCount(kbID string) {
count, _ := s.repo.CountDocumentsByKBID(kbID)
s.repo.Update(kbID, map[string]interface{}{"document_count": int(count)})
}
func getFileExt(filename string) string {
if len(filename) > 4 {
return filename[len(filename)-4:]
}
return ""
}

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"strings"
"time"

View File

@@ -0,0 +1,166 @@
package service
import (
"context"
"fmt"
"io"
"mime/multipart"
"net/url"
"os"
"path/filepath"
"strings"
"time"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/google/uuid"
"x-agents/server/internal/config"
)
type UploadService struct {
cfg *config.Config
minioClient *minio.Client
}
// UploadResponse 上传响应
type UploadResponse struct {
Success bool `json:"success"`
URL string `json:"url"`
FileKey string `json:"fileKey"` // 文件标识,用于删除等操作
Message string `json:"message"`
}
func NewUploadService(cfg *config.Config) (*UploadService, error) {
s := &UploadService{cfg: cfg}
// 如果是 MinIO 模式,初始化 MinIO 客户端
if cfg.UploadMode == "minio" {
if cfg.MinIOEndpoint == "" || cfg.MinIOAccessKey == "" || cfg.MinIOSecretKey == "" {
return nil, fmt.Errorf("MinIO configuration is incomplete")
}
client, err := minio.New(cfg.MinIOEndpoint, &minio.Options{
Creds: credentials.NewStaticV4(cfg.MinIOAccessKey, cfg.MinIOSecretKey, ""),
Secure: cfg.MinIOUseSSL,
})
if err != nil {
return nil, fmt.Errorf("failed to create MinIO client: %w", err)
}
// 检查 bucket 是否存在,不存在则创建
exists, err := client.BucketExists(context.Background(), cfg.MinIOBucket)
if err != nil {
return nil, fmt.Errorf("failed to check MinIO bucket: %w", err)
}
if !exists {
if err := client.MakeBucket(context.Background(), cfg.MinIOBucket, minio.MakeBucketOptions{}); err != nil {
return nil, fmt.Errorf("failed to create MinIO bucket: %w", err)
}
}
s.minioClient = client
}
return s, nil
}
// Upload 上传文件
func (s *UploadService) Upload(file *multipart.FileHeader) (*UploadResponse, error) {
// 打开文件
f, err := file.Open()
if err != nil {
return &UploadResponse{Success: false, Message: err.Error()}, nil
}
defer f.Close()
// 生成唯一文件名
ext := filepath.Ext(file.Filename)
filename := fmt.Sprintf("%s%s", uuid.New().String(), ext)
fileKey := strings.TrimSuffix(filename, ext)
// 根据模式选择存储方式
if s.cfg.UploadMode == "minio" {
return s.uploadToMinIO(f, filename, fileKey, file.Size)
}
return s.uploadToLocal(f, filename, fileKey)
}
// uploadToMinIO 上传到 MinIO
func (s *UploadService) uploadToMinIO(f multipart.File, filename, fileKey string, size int64) (*UploadResponse, error) {
_, err := s.minioClient.PutObject(context.Background(), s.cfg.MinIOBucket, filename, f, size, minio.PutObjectOptions{
ContentType: "application/octet-stream",
})
if err != nil {
return &UploadResponse{Success: false, Message: fmt.Sprintf("MinIO upload failed: %v", err)}, nil
}
// 生成预签名 URL有效期 24 小时)
presignedURL, err := s.minioClient.PresignedGetObject(context.Background(), s.cfg.MinIOBucket, filename, 24*time.Hour, nil)
if err != nil {
return &UploadResponse{Success: false, Message: fmt.Sprintf("failed to generate URL: %v", err)}, nil
}
return &UploadResponse{
Success: true,
URL: presignedURL.String(),
FileKey: fileKey,
Message: "Upload successful",
}, nil
}
// uploadToLocal 上传到本地
func (s *UploadService) uploadToLocal(f multipart.File, filename, fileKey string) (*UploadResponse, error) {
// 确保目录存在
uploadPath := s.cfg.UploadLocalPath
if err := os.MkdirAll(uploadPath, 0755); err != nil {
return &UploadResponse{Success: false, Message: fmt.Sprintf("failed to create directory: %v", err)}, nil
}
// 创建文件
dst, err := os.Create(filepath.Join(uploadPath, filename))
if err != nil {
return &UploadResponse{Success: false, Message: err.Error()}, nil
}
defer dst.Close()
// 复制内容
if _, err := io.Copy(dst, f); err != nil {
return &UploadResponse{Success: false, Message: err.Error()}, nil
}
// 生成 URL
fileURL := fmt.Sprintf("%s/files/%s", s.cfg.ServerBaseURL, filename)
return &UploadResponse{
Success: true,
URL: fileURL,
FileKey: fileKey,
Message: "Upload successful",
}, nil
}
// DeleteFile 删除文件
func (s *UploadService) DeleteFile(filename string) error {
if s.cfg.UploadMode == "minio" {
return s.minioClient.RemoveObject(context.Background(), s.cfg.MinIOBucket, filename, minio.RemoveObjectOptions{})
}
// 本地删除
path := filepath.Join(s.cfg.UploadLocalPath, filename)
return os.Remove(path)
}
// GetFileURL 获取文件 URL用于已存在的文件
func (s *UploadService) GetFileURL(filename string) (string, error) {
if s.cfg.UploadMode == "minio" {
presignedURL, err := s.minioClient.PresignedGetObject(context.Background(), s.cfg.MinIOBucket, filename, 24*time.Hour, nil)
if err != nil {
return "", err
}
return presignedURL.String(), nil
}
// 本地文件
escaped := url.PathEscape(filename)
return fmt.Sprintf("%s/files/%s", s.cfg.ServerBaseURL, escaped), nil
}

View File

@@ -1,7 +0,0 @@
{
"database_id": "053388bf-d0c3-4cd9-b78f-539858705a65",
"database_name": "test-db",
"db_type": "mysql",
"tables": [],
"updated_at": "2026-03-06T15:46:22.8598923+08:00"
}

View File

@@ -1,22 +0,0 @@
{
"database_id": "101fbee1-8400-46ae-b83b-e3898e4888b6",
"database_name": "123",
"db_type": "mysql",
"tables": [
{
"id": "042db4ca-512f-4ee9-aacb-2d7ff1bc2193",
"database_id": "101fbee1-8400-46ae-b83b-e3898e4888b6",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '分数id'\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-06T16:23:31.097+08:00",
"updated_at": "2026-03-06T16:23:31.097+08:00"
}
],
"updated_at": "2026-03-06T16:23:31.1477776+08:00"
}

View File

@@ -1,22 +0,0 @@
{
"database_id": "1ee87735-9ddd-4831-85ce-c1a571ab996b",
"database_name": "1231",
"db_type": "mysql",
"tables": [
{
"id": "4402a7c4-7ff4-4084-a76b-4b7e0a34695c",
"database_id": "1ee87735-9ddd-4831-85ce-c1a571ab996b",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-07T10:33:25.752+08:00",
"updated_at": "2026-03-07T10:33:25.752+08:00"
}
],
"updated_at": "2026-03-07T10:33:25.8031128+08:00"
}

View File

@@ -1,22 +0,0 @@
{
"database_id": "44cf2f22-fccb-4dd0-92fb-02d613ce2624",
"database_name": "1231",
"db_type": "mysql",
"tables": [
{
"id": "042fb35c-9023-40ed-8d3a-cec24f0709a2",
"database_id": "44cf2f22-fccb-4dd0-92fb-02d613ce2624",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-07T09:59:48.436+08:00",
"updated_at": "2026-03-07T09:59:48.436+08:00"
}
],
"updated_at": "2026-03-07T09:59:48.4882963+08:00"
}

View File

@@ -1,20 +0,0 @@
{
"database_id": "456b6a60-c5a5-46e4-8f5e-9c07c4c08510",
"database_name": "123",
"db_type": "mysql",
"tables": [
{
"id": "8b7f6a2f-3788-4499-8d3a-fe9140ccdfe1",
"database_id": "456b6a60-c5a5-46e4-8f5e-9c07c4c08510",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"created_at": "2026-03-06T15:12:45.607+08:00",
"updated_at": "2026-03-06T15:12:45.607+08:00"
}
],
"updated_at": "2026-03-06T15:12:45.6597943+08:00"
}

View File

@@ -1,22 +0,0 @@
{
"database_id": "4e3ce862-5936-45f8-baf2-c9c2895c2303",
"database_name": "1231",
"db_type": "mysql",
"tables": [
{
"id": "f394a250-623b-4da0-81e5-1e5d93bed982",
"database_id": "4e3ce862-5936-45f8-baf2-c9c2895c2303",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-07T10:37:08.868+08:00",
"updated_at": "2026-03-07T10:37:08.868+08:00"
}
],
"updated_at": "2026-03-07T10:37:08.918463+08:00"
}

View File

@@ -1,22 +0,0 @@
{
"database_id": "58f7171d-6906-4f85-b27a-20bb2f982fc4",
"database_name": "123",
"db_type": "mysql",
"tables": [
{
"id": "12298a11-fe00-4e6a-a37e-e4c0b5de6a51",
"database_id": "58f7171d-6906-4f85-b27a-20bb2f982fc4",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'fenshu id'\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-06T16:26:15.44+08:00",
"updated_at": "2026-03-06T16:26:15.44+08:00"
}
],
"updated_at": "2026-03-06T16:26:15.4936638+08:00"
}

View File

@@ -1,21 +0,0 @@
{
"database_id": "5eee8840-c268-4cf1-8f86-a0d13eaf9b16",
"database_name": "test-db-3",
"db_type": "mysql",
"tables": [
{
"id": "2a52c3a0-0019-4634-a4b3-3627a02153ba",
"database_id": "5eee8840-c268-4cf1-8f86-a0d13eaf9b16",
"parent_table": "database_info",
"sub_table_name": "DB<44><42>Ϣ",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"ddl": "CREATE TABLE `database_info` (\n`id` varchar(36) NOT NULL, COMMENT 'ID'\n`name` varchar(100) NOT NULL, COMMENT '<27><><EFBFBD><EFBFBD>'\n `description` varchar(500) DEFAULT NULL,\n `db_type` varchar(20) NOT NULL,\n`host` varchar(255) NOT NULL, COMMENT '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ'\n `port` bigint NOT NULL,\n `username` varchar(100) NOT NULL,\n `password` varchar(255) DEFAULT NULL,\n `database` varchar(100) DEFAULT NULL,\n `table_count` bigint DEFAULT '0',\n `charset` varchar(20) DEFAULT 'utf8mb4',\n `ssl_mode` varchar(20) DEFAULT NULL,\n `created_at` datetime(3) DEFAULT NULL,\n `updated_at` datetime(3) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci",
"created_at": "2026-03-06T15:57:24.011+08:00",
"updated_at": "2026-03-06T15:57:24.011+08:00"
}
],
"updated_at": "2026-03-06T15:57:24.0628515+08:00"
}

View File

@@ -1,21 +0,0 @@
{
"database_id": "68b6fb60-eae2-495b-b248-9c46c8d8d6cb",
"database_name": "test-db-4",
"db_type": "mysql",
"tables": [
{
"id": "5107d64f-9949-4550-9030-e7e14585f080",
"database_id": "68b6fb60-eae2-495b-b248-9c46c8d8d6cb",
"parent_table": "database_info",
"sub_table_name": "DB<44><42>",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"ddl": "CREATE TABLE `database_info` (\n`id` varchar(36) NOT NULL COMMENT '<27><><EFBFBD><EFBFBD>ID'\n`name` varchar(100) NOT NULL COMMENT '<27><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>'\n `description` varchar(500) DEFAULT NULL,\n `db_type` varchar(20) NOT NULL,\n`host` varchar(255) NOT NULL COMMENT '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'\n `port` bigint NOT NULL,\n `username` varchar(100) NOT NULL,\n `password` varchar(255) DEFAULT NULL,\n `database` varchar(100) DEFAULT NULL,\n `table_count` bigint DEFAULT '0',\n `charset` varchar(20) DEFAULT 'utf8mb4',\n `ssl_mode` varchar(20) DEFAULT NULL,\n `created_at` datetime(3) DEFAULT NULL,\n `updated_at` datetime(3) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci",
"created_at": "2026-03-06T16:00:34.065+08:00",
"updated_at": "2026-03-06T16:00:34.065+08:00"
}
],
"updated_at": "2026-03-06T16:00:34.1176551+08:00"
}

View File

@@ -1,44 +0,0 @@
{
"database_id": "7eb66808-db8b-428e-8548-2f754c4fc688",
"database_name": "123",
"db_type": "mysql",
"tables": [
{
"id": "66026752-77b6-4cba-a4d1-1bf3b07e920c",
"database_id": "7eb66808-db8b-428e-8548-2f754c4fc688",
"parent_table": "teachers",
"sub_table_name": "teachers",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"created_at": "2026-03-06T15:12:24.217+08:00",
"updated_at": "2026-03-06T15:12:24.217+08:00"
},
{
"id": "be59cb63-c5cf-46bf-b77a-46ce1fcb374b",
"database_id": "7eb66808-db8b-428e-8548-2f754c4fc688",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"created_at": "2026-03-06T15:12:24.112+08:00",
"updated_at": "2026-03-06T15:12:24.112+08:00"
},
{
"id": "d91e5cd4-09c9-40a8-9c42-8f5ce0f059e1",
"database_id": "7eb66808-db8b-428e-8548-2f754c4fc688",
"parent_table": "students",
"sub_table_name": "students",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"created_at": "2026-03-06T15:12:24.166+08:00",
"updated_at": "2026-03-06T15:12:24.166+08:00"
}
],
"updated_at": "2026-03-06T15:12:24.2696469+08:00"
}

View File

@@ -1,21 +0,0 @@
{
"database_id": "96d39e69-c96b-4d22-9b29-6456de71c6c1",
"database_name": "189数据库",
"db_type": "mysql",
"tables": [
{
"id": "d56ef61e-ac0d-439d-a2e8-133d766cbdd9",
"database_id": "96d39e69-c96b-4d22-9b29-6456de71c6c1",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"ddl": "CREATE TABLE `scores` (\n`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT '分数id'\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-06T16:07:17.146+08:00",
"updated_at": "2026-03-06T16:07:17.146+08:00"
}
],
"updated_at": "2026-03-06T16:07:17.1980788+08:00"
}

View File

@@ -1,21 +0,0 @@
{
"database_id": "a58e6c1e-b39b-4248-8de9-b172f134197b",
"database_name": "test-db-2",
"db_type": "mysql",
"tables": [
{
"id": "613c5bb7-2d42-4b75-8f19-43a2b345de8b",
"database_id": "a58e6c1e-b39b-4248-8de9-b172f134197b",
"parent_table": "database_info",
"sub_table_name": "<22><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>Ϣ<EFBFBD><CFA2>",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"ddl": "CREATE TABLE `database_info` (\n `id` varchar(36) NOT NULL,\n `name` varchar(100) NOT NULL,\n `description` varchar(500) DEFAULT NULL,\n `db_type` varchar(20) NOT NULL,\n `host` varchar(255) NOT NULL,\n `port` bigint NOT NULL,\n `username` varchar(100) NOT NULL,\n `password` varchar(255) DEFAULT NULL,\n `database` varchar(100) DEFAULT NULL,\n `table_count` bigint DEFAULT '0',\n `charset` varchar(20) DEFAULT 'utf8mb4',\n `ssl_mode` varchar(20) DEFAULT NULL,\n `created_at` datetime(3) DEFAULT NULL,\n `updated_at` datetime(3) DEFAULT NULL,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci",
"created_at": "2026-03-06T15:51:28.706+08:00",
"updated_at": "2026-03-06T15:51:28.706+08:00"
}
],
"updated_at": "2026-03-06T15:51:28.762063+08:00"
}

View File

@@ -1,36 +0,0 @@
{
"database_id": "a89dfc3e-5089-4a9e-8f6b-991d5bebd85d",
"database_name": "1231",
"db_type": "mysql",
"tables": [
{
"id": "0fbec3c2-ab05-4288-a797-bdf03eec9f2b",
"database_id": "a89dfc3e-5089-4a9e-8f6b-991d5bebd85d",
"parent_table": "students",
"sub_table_name": "students",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `students` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `name` varchar(50) NOT NULL COMMENT '学生姓名',\n `age` int(11) DEFAULT NULL COMMENT '年龄',\n `gender` varchar(10) DEFAULT NULL COMMENT '性别',\n `class` varchar(50) DEFAULT NULL COMMENT '班级',\n `phone` varchar(20) DEFAULT NULL COMMENT '电话',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=31 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-07T10:44:27.61+08:00",
"updated_at": "2026-03-07T10:44:27.61+08:00"
},
{
"id": "693944e2-d610-4a09-aee9-1af0c8246fb4",
"database_id": "a89dfc3e-5089-4a9e-8f6b-991d5bebd85d",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-07T10:44:27.56+08:00",
"updated_at": "2026-03-07T10:44:27.56+08:00"
}
],
"updated_at": "2026-03-07T10:44:27.6628932+08:00"
}

View File

@@ -1,20 +0,0 @@
{
"database_id": "b5fc80da-b681-4f6f-a35a-73e73dee50d0",
"database_name": "123",
"db_type": "mysql",
"tables": [
{
"id": "49805b02-3204-44b9-9d28-3b5053ca7a1e",
"database_id": "b5fc80da-b681-4f6f-a35a-73e73dee50d0",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"created_at": "2026-03-06T15:12:36.292+08:00",
"updated_at": "2026-03-06T15:12:36.292+08:00"
}
],
"updated_at": "2026-03-06T15:12:36.3469958+08:00"
}

View File

@@ -1,7 +0,0 @@
{
"database_id": "d022a68d-cb75-405b-bee3-e923a8b5a283",
"database_name": "123",
"db_type": "mysql",
"tables": [],
"updated_at": "2026-03-06T15:32:13.1521688+08:00"
}

View File

@@ -1,22 +0,0 @@
{
"database_id": "d44fa121-5964-439f-8c5d-0384ba27b411",
"database_name": "123",
"db_type": "mysql",
"tables": [
{
"id": "694da06f-d6b7-4915-8502-c4c38addf059",
"database_id": "d44fa121-5964-439f-8c5d-0384ba27b411",
"parent_table": "scores",
"sub_table_name": "scores",
"sub_table_comment": "",
"mapping_type": "",
"relation_field": "",
"relation_type": "",
"fields": null,
"ddl": "CREATE TABLE `scores` (\n`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'fenshu id'\n `student_id` int(10) unsigned NOT NULL,\n `subject` varchar(50) NOT NULL COMMENT '科目',\n `score` double DEFAULT NULL COMMENT '分数',\n `teacher_id` int(10) unsigned DEFAULT NULL,\n `exam_date` date DEFAULT NULL COMMENT '考试日期',\n `created_at` datetime DEFAULT CURRENT_TIMESTAMP,\n PRIMARY KEY (`id`)\n) ENGINE=InnoDB AUTO_INCREMENT=48 DEFAULT CHARSET=utf8mb4",
"created_at": "2026-03-06T16:30:41.589+08:00",
"updated_at": "2026-03-06T16:30:41.589+08:00"
}
],
"updated_at": "2026-03-06T16:30:41.639042+08:00"
}

View File

@@ -0,0 +1,96 @@
# 文件上传 API
## 基础信息
| 项目 | 说明 |
|------|------|
| 基础URL | `http://localhost:8082` |
| 上传模式 | local / minio配置决定 |
## 配置说明
```yaml
# config.yaml
upload_mode: "local" # 上传模式local 或 minio
upload_local_path: "resource/files" # 本地存储路径
server_base_url: "http://localhost:8082" # 服务器基础URL
# MinIO 配置upload_mode 为 minio 时需要)
minio_endpoint: "localhost:9000"
minio_access_key: "your-access-key"
minio_secret_key: "your-secret-key"
minio_bucket: "x-agents"
minio_use_ssl: false
```
## 接口列表
### 1. 上传文件
**请求**
```
POST /upload
Content-Type: multipart/form-data
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| file | File | 是 | 要上传的文件 |
**响应**
```json
{
"success": true,
"url": "http://localhost:8082/files/abc123.pdf",
"fileKey": "abc123",
"message": "Upload successful"
}
```
**错误响应**
```json
{
"success": false,
"message": "File too large (max 100MB)"
}
```
---
### 2. 删除文件
**请求**
```
DELETE /upload/:filename
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| filename | String | 是 | 文件名(不含路径) |
**响应**
```json
{
"success": true,
"message": "File deleted"
}
```
---
### 3. 访问文件(仅本地模式)
文件上传后,本地模式下可通过以下 URL 直接访问:
```
GET /files/{filename}
```
例如:`http://localhost:8082/files/abc123.pdf`
> 注意MinIO 模式返回的是预签名 URL有效期 24 小时。

View File

@@ -0,0 +1,354 @@
# 知识库创建 API
## 基础信息
| 项目 | 说明 |
|------|------|
| 基础URL | `http://localhost:8082` |
| 前端页面 | Knowledge Base 创建弹窗 |
## 接口列表
### 1. 创建知识库
**请求**
```
POST /api/knowledge/create
Content-Type: application/json
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| name | String | 是 | 知识库名称 |
| description | String | 否 | 知识库描述 |
| llm_model_id | String | 是 | LLM 模型 ID来自 model 表) |
| embedding_model_id | String | 是 | Embedding 模型 ID来自 model 表) |
| parsing_config | Object | 是 | 解析配置 |
| - engine | String | 是 | 解析引擎markitdown / docling |
| - docling_url | String | 条件必填 | Docling 服务 URLengine=docling 时必填) |
| - enable_pdf | Boolean | 否 | 是否启用 PDF 解析(默认 true |
| - pandoc | Boolean | 否 | 是否启用 Pandoc默认 true |
**请求示例**
```json
{
"name": "产品文档知识库",
"description": "用于存储产品手册和文档",
"llm_model_id": "model_001",
"embedding_model_id": "model_002",
"parsing_config": {
"engine": "markitdown",
"enable_pdf": true,
"pandoc": true
}
}
```
或使用 Docling
```json
{
"name": "产品文档知识库",
"description": "用于存储产品手册和文档",
"llm_model_id": "model_001",
"embedding_model_id": "model_002",
"parsing_config": {
"engine": "docling",
"docling_url": "http://localhost:8501",
"enable_pdf": true,
"pandoc": true
}
}
```
**成功响应**
```json
{
"success": true,
"id": "kb_abc123",
"message": "Knowledge base created successfully"
}
```
**错误响应**
```json
{
"success": false,
"message": "LLM model not found"
}
```
---
### 2. 获取知识库列表
**请求**
```
GET /api/knowledge/list
```
**响应**
```json
{
"success": true,
"data": [
{
"id": "kb_001",
"name": "产品文档知识库",
"description": "用于存储产品手册",
"llm_model_id": "model_001",
"embedding_model_id": "model_002",
"status": "active",
"document_count": 15,
"chunk_count": 156,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
]
}
```
---
### 3. 获取知识库详情
**请求**
```
GET /api/knowledge/:id
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
**响应**
```json
{
"success": true,
"data": {
"id": "kb_001",
"name": "产品文档知识库",
"description": "用于存储产品手册",
"llm_model_id": "model_001",
"embedding_model_id": "model_002",
"parsing_config": {
"engine": "markitdown",
"enable_pdf": true,
"pandoc": true
},
"status": "active",
"document_count": 15,
"chunk_count": 156,
"created_at": "2024-01-15T10:30:00Z",
"updated_at": "2024-01-15T10:30:00Z"
}
}
```
---
### 4. 删除知识库
**请求**
```
DELETE /api/knowledge/:id
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
**响应**
```json
{
"success": true,
"message": "Knowledge base deleted"
}
```
---
### 5. 获取知识库下的文档列表
**请求**
```
GET /api/knowledge/:id/documents
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
**查询参数**
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| status | String | 否 | 过滤状态all / parsed / parsing / failed |
**响应**
```json
{
"success": true,
"data": [
{
"id": "doc_001",
"name": "产品手册_v2.0.pdf",
"file_size": 2516582,
"status": "parsed",
"chunk_count": 156,
"uploaded_at": "2024-01-15T10:30:00Z"
}
]
}
```
---
### 6. 上传文档到知识库
**请求**
```
POST /api/knowledge/:id/documents
Content-Type: multipart/form-data
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
| file | File | 是 | 要上传的文件 |
**响应**
```json
{
"success": true,
"dataid": "doc_001",
": {
" "name": "产品手册_v2.0.pdf",
"status": "parsing"
}
}
```
---
### 7. 删除知识库文档
**请求**
```
DELETE /api/knowledge/:id/documents/:doc_id
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
| doc_id | String | 是 | 文档 ID |
**响应**
```json
{
"success": true,
"message": "Document deleted"
}
```
---
### 8. 重新解析文档
**请求**
```
POST /api/knowledge/:id/documents/:doc_id/reparse
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
| doc_id | String | 是 | 文档 ID |
**响应**
```json
{
"success": true,
"message": "Document reparse started"
}
```
---
### 9. 获取文档预览内容
**请求**
```
GET /api/knowledge/:id/documents/:doc_id/preview
```
| 参数 | 类型 | 必填 | 说明 |
|------|------|------|------|
| id | String | 是 | 知识库 ID |
| doc_id | String | 是 | 文档 ID |
| page | Number | 否 | 页码(默认 1 |
**响应**
```json
{
"success": true,
"data": {
"total_pages": 3,
"current_page": 1,
"content": "第一章 产品介绍\n\n欢迎使用我们的产品手册..."
}
}
```
---
## 数据库表设计(参考)
### knowledge_base 表
| 字段 | 类型 | 说明 |
|------|------|------|
| id | String | 主键 |
| name | String | 知识库名称 |
| description | Text | 描述 |
| llm_model_id | String | LLM 模型 ID |
| embedding_model_id | String | Embedding 模型 ID |
| parsing_config | JSON | 解析配置 |
| status | String | 状态active / inactive |
| document_count | Integer | 文档数量 |
| chunk_count | Integer | 切片数量 |
| created_at | Timestamp | 创建时间 |
| updated_at | Timestamp | 更新时间 |
### knowledge_document 表
| 字段 | 类型 | 说明 |
|------|------|------|
| id | String | 主键 |
| knowledge_base_id | String | 知识库 ID |
| name | String | 文档名称 |
| file_key | String | 文件存储 key |
| file_size | BigInteger | 文件大小 |
| status | String | 状态parsing / parsed / failed |
| chunk_count | Integer | 切片数量 |
| uploaded_at | Timestamp | 上传时间 |

View File

@@ -2,6 +2,16 @@
## 2026年3月
### 2026-03-08
- [ ] **知识库Knowledge BaseAPI** - 后端待实现
- 创建知识库、获取列表、获取详情、删除
- 上传文档、删除文档、重新解析
- 获取文档预览内容
- 详细需求:[knowledge-base-api.md](./knowledge-base-api.md)
---
### 2026-03-07
- [x] **DDL 编辑功能** - 后端已完成 ✔

View File

@@ -27,15 +27,11 @@ const mainMenu: MenuItem[] = [
]
const bottomMenu: MenuItem[] = [
{ name: 'API Keys', icon: 'fa-key', path: '/api-keys' },
{ name: 'Settings', icon: 'fa-gear', path: '/settings' },
{ name: 'Team', icon: 'fa-users', path: '/team' },
{ name: 'Service Accounts', icon: 'fa-user-shield' },
{ name: 'Integrations', icon: 'fa-plug' },
]
const bottomMenu2: MenuItem[] = [
{ name: 'Information', icon: 'fa-circle-info' },
{ name: 'Account', icon: 'fa-user' },
]
@@ -121,7 +117,7 @@ const handleUserCommand = (command: string) => {
<!-- 分隔线 -->
<li class="my-4 border-t border-dark-500"></li>
<!-- API Keys -->
<!-- Settings & Team -->
<li v-for="item in bottomMenu" :key="item.name">
<a
href="#"

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { ElMessage } from 'element-plus'
import { useModelSettings } from './settings/useModelSettings'
import './knowledge/knowledge.css'
@@ -7,10 +7,31 @@ import './knowledge/knowledge.css'
// 获取已配置的模型列表
const { models, fetchModels } = useModelSettings()
// 页面加载时获取模型列表
onMounted(() => {
fetchModels()
})
// 筛选 LLM (chat) 模型
const llmModels = computed(() => {
return models.value.filter((m: any) => m.model_type === 'chat')
})
// 筛选 Embedding 模型
const embeddingModels = computed(() => {
return models.value.filter((m: any) => m.model_type === 'embedding')
})
// 步骤验证
const step1Valid = computed(() => !!newKbForm.value.name.trim())
const step2Valid = computed(() => !!embeddingConfig.value.modelId)
const step3Valid = computed(() => true) // Parsing - 暂时默认通过
const step2Valid = computed(() => !!modelConfig.value.llmModelId && !!modelConfig.value.embeddingModelId)
const step3Valid = computed(() => {
// Parsing - 如果选择 docling则需要填写 URL
if (parsingConfig.value.engine === 'docling') {
return !!parsingConfig.value.doclingUrl.trim()
}
return true
})
const step4Valid = computed(() => true) // Storage - 暂时默认通过
// 获取当前步骤是否有效
@@ -106,17 +127,26 @@ const filteredKnowledgeBases = () => {
// 新建知识库 - 分步骤
const showCreateDialog = ref(false)
const createStep = ref(1)
// 文件上传弹窗
const showFileUploadDialog = ref(false)
const selectedKnowledge = ref<any>(null)
const fileFilter = ref('all') // all, parsed, parsing, failed
const selectedFile = ref<any>(null) // 当前选中的文件
const newKbForm = ref({
name: '',
description: '',
})
const embeddingConfig = ref({
modelId: '',
// 模型配置
const modelConfig = ref({
llmModelId: '',
embeddingModelId: '',
})
const parsingConfig = ref({
enablePdf: true,
engine: 'default',
engine: 'markitdown',
doclingUrl: '',
pandoc: true,
academic: false,
highRes: false,
@@ -126,12 +156,11 @@ const parsingConfig = ref({
const openCreateDialog = () => {
createStep.value = 1
newKbForm.value = { name: '', description: '' }
embeddingConfig.value = { modelId: '' }
// 获取已配置的模型列表
fetchModels()
modelConfig.value = { llmModelId: '', embeddingModelId: '' }
parsingConfig.value = {
enablePdf: true,
engine: 'default',
engine: 'markitdown',
doclingUrl: '',
pandoc: true,
academic: false,
highRes: false,
@@ -142,10 +171,11 @@ const openCreateDialog = () => {
const cancelCreate = () => {
newKbForm.value = { name: '', description: '' }
embeddingConfig.value = { modelId: '' }
modelConfig.value = { llmModelId: '', embeddingModelId: '' }
parsingConfig.value = {
enablePdf: true,
engine: 'default',
engine: 'markitdown',
doclingUrl: '',
pandoc: true,
academic: false,
highRes: false,
@@ -165,7 +195,7 @@ const createKnowledgeBase = () => {
status: 'ready'
})
newKbForm.value = { name: '', description: '' }
embeddingConfig.value = { modelId: '' }
modelConfig.value = { llmModelId: '', embeddingModelId: '' }
showCreateDialog.value = false
ElMessage.success('Knowledge base created successfully')
}
@@ -210,9 +240,10 @@ const deleteKb = (id: string) => {
}
}
// 查看详情
const viewDetail = (kb: any) => {
ElMessage.info(`Viewing ${kb.name}`)
// 进入知识库(上传文档界面)
const enterKnowledge = (kb: any) => {
selectedKnowledge.value = kb
showFileUploadDialog.value = true
}
</script>
@@ -286,11 +317,11 @@ const viewDetail = (kb: any) => {
<td class="px-5 py-4">
<div class="flex items-center justify-center gap-2">
<button
@click="viewDetail(kb)"
@click="enterKnowledge(kb)"
class="p-2 rounded-lg transition-colors hover:bg-dark-600"
title="View"
title="Enter"
>
<i class="fa-solid fa-eye text-gray-400 hover:text-primary-danger"></i>
<i class="fa-solid fa-door-open text-gray-400 hover:text-primary-orange"></i>
</button>
<button
@click="openEdit(kb)"
@@ -325,7 +356,7 @@ const viewDetail = (kb: any) => {
<!-- 新建知识库弹窗 -->
<el-dialog
v-model="showCreateDialog"
title="创建知识库"
title="Create Knowledge Base"
width="1100px"
:close-on-click-modal="false"
:show-close="false"
@@ -413,10 +444,25 @@ const viewDetail = (kb: any) => {
<span class="section-title">Model Config</span>
</div>
<el-form label-position="top" class="kb-form">
<el-form-item label="Embedding Model">
<el-select v-model="embeddingConfig.modelId" placeholder="Select a configured model" class="w-full" popper-class="dark-select-dropdown">
<el-form-item label="LLM Model">
<el-select v-model="modelConfig.llmModelId" placeholder="Select a chat model" class="w-full" popper-class="dark-select-dropdown">
<el-option
v-for="model in models"
v-for="model in llmModels"
:key="model.id"
:label="model.name"
:value="model.id"
>
<div class="model-option">
<span class="model-name">{{ model.name }}</span>
<span class="model-info">{{ model.provider }} - {{ model.model }}</span>
</div>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="Embedding Model">
<el-select v-model="modelConfig.embeddingModelId" placeholder="Select an embedding model" class="w-full" popper-class="dark-select-dropdown">
<el-option
v-for="model in embeddingModels"
:key="model.id"
:label="model.name"
:value="model.id"
@@ -439,60 +485,24 @@ const viewDetail = (kb: any) => {
</div>
<div class="parsing-section">
<div class="parsing-row">
<span class="parsing-label">Enable PDF Parsing</span>
<el-switch v-model="parsingConfig.enablePdf" />
</div>
<div class="parsing-row">
<span class="parsing-label">Parsing Engine</span>
<el-select v-model="parsingConfig.engine" placeholder="Select engine" class="parsing-select">
<el-option label="Default Engine" value="default" />
<el-option label="DeepDoc" value="deepdoc" />
<el-select v-model="parsingConfig.engine" placeholder="Select engine" class="parsing-select" popper-class="dark-select-dropdown">
<el-option label="MarkItDown" value="markitdown" />
<el-option label="Docling" value="docling" />
</el-select>
</div>
<div class="parsing-divider"></div>
<div class="parsing-label">Enabled Post-processing</div>
<div class="postprocess-list">
<div class="postprocess-item" :class="{ active: parsingConfig.pandoc }">
<div class="postprocess-toggle">
<el-switch v-model="parsingConfig.pandoc" />
</div>
<div class="postprocess-info">
<span class="postprocess-title">Use Pandoc Markdown Enrichment</span>
<span class="postprocess-desc">Enable Pandoc conversion for rich formatting</span>
</div>
</div>
<div class="postprocess-item" :class="{ active: parsingConfig.academic }">
<div class="postprocess-toggle">
<el-switch v-model="parsingConfig.academic" />
</div>
<div class="postprocess-info">
<span class="postprocess-title">Use Academic Document Parsing</span>
<span class="postprocess-desc">Parse formulas, tables, and academic structures</span>
</div>
</div>
<div class="postprocess-item" :class="{ active: parsingConfig.highRes }">
<div class="postprocess-toggle">
<el-switch v-model="parsingConfig.highRes" />
</div>
<div class="postprocess-info">
<span class="postprocess-title">Use High Resolution Parsing</span>
<span class="postprocess-desc">High quality mode for complex documents</span>
</div>
</div>
</div>
<div class="parsing-divider"></div>
<div class="parsing-row">
<span class="parsing-label">File Size Limit</span>
<el-input v-model="parsingConfig.fileSizeLimit" class="parsing-input" />
<!-- Docling URL 配置 -->
<div v-if="parsingConfig.engine === 'docling'" class="parsing-row" style="margin-top: 12px; align-items: center;">
<span class="parsing-label" style="flex: 1;">Docling URL</span>
<input
v-model="parsingConfig.doclingUrl"
type="text"
placeholder="http://localhost:8080"
class="input-field"
style="width: 350px;"
>
</div>
</div>
</div>
@@ -566,5 +576,138 @@ const viewDetail = (kb: any) => {
</div>
</template>
</el-dialog>
<!-- 文件上传弹窗 -->
<el-dialog
v-model="showFileUploadDialog"
:title="selectedKnowledge?.name || 'Knowledge Base'"
width="95vw"
top="20px"
:close-on-click-modal="false"
class="kb-dialog file-upload-dialog"
>
<div class="file-upload-layout">
<!-- 顶部导航 -->
<div class="file-header">
<button class="back-btn" @click="showFileUploadDialog = false">
<i class="fa-solid fa-arrow-left"></i>
</button>
<h2 class="file-title">{{ selectedKnowledge?.name || 'Knowledge Base' }}</h2>
<button class="btn-primary">
<i class="fa-solid fa-upload"></i>
上传文档
</button>
</div>
<!-- 标签栏 -->
<div class="file-tabs">
<div
class="file-tab"
:class="{ active: fileFilter === 'all' }"
@click="fileFilter = 'all'"
>
全部
</div>
<div
class="file-tab"
:class="{ active: fileFilter === 'parsed' }"
@click="fileFilter = 'parsed'"
>
已解析
</div>
<div
class="file-tab"
:class="{ active: fileFilter === 'parsing' }"
@click="fileFilter = 'parsing'"
>
解析中
</div>
<div
class="file-tab"
:class="{ active: fileFilter === 'failed' }"
@click="fileFilter = 'failed'"
>
解析失败
</div>
</div>
<!-- 内容区 - 左侧文件列表 + 右侧预览 -->
<div class="file-main">
<!-- 左侧文件列表 -->
<div class="file-list">
<!-- 模拟文件项 -->
<div
class="file-item"
:class="{ selected: selectedFile === i }"
v-for="i in 8"
:key="i"
@click="selectedFile = i"
>
<div class="file-item-icon">
<i class="fa-solid fa-file-pdf"></i>
</div>
<div class="file-item-info">
<div class="file-item-name">产品手册_v2.0.pdf</div>
<div class="file-item-meta">
<span>2.4 MB</span>
<span>2024-01-15</span>
</div>
</div>
<div class="file-item-status success">
<i class="fa-solid fa-check-circle"></i>
</div>
</div>
</div>
<!-- 右侧预览面板 -->
<div class="file-preview">
<div class="preview-header">
<div class="preview-header-left">
<i class="fa-solid fa-file-pdf"></i>
<span class="preview-filename">产品手册_v2.0.pdf</span>
</div>
<div class="preview-header-info">
<span class="info-tag">2.4 MB</span>
<span class="info-tag">2024-01-15 10:30</span>
<span class="info-tag success">解析成功</span>
<span class="info-tag">156 个切片</span>
</div>
</div>
<div class="preview-content">
<!-- PDF文件预览 -->
<div class="pdf-preview">
<iframe
src="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
class="pdf-iframe"
></iframe>
</div>
<div class="preview-pagination">
<button class="page-btn" disabled>
<i class="fa-solid fa-chevron-left"></i>
</button>
<span class="page-info">1 / 3</span>
<button class="page-btn">
<i class="fa-solid fa-chevron-right"></i>
</button>
</div>
</div>
<div class="preview-actions">
<button class="action-btn delete">
<i class="fa-solid fa-trash"></i>
删除
</button>
<button class="action-btn reparse">
<i class="fa-solid fa-rotate"></i>
重新解析
</button>
<button class="action-btn confirm">
<i class="fa-solid fa-check"></i>
确认
</button>
</div>
</div>
</div>
</div>
</el-dialog>
</div>
</template>

View File

@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, nextTick } from 'vue'
import { ref, nextTick, onMounted, computed } from 'vue'
import { useModelSettings } from './settings/useModelSettings'
interface MCPServer {
id: number
@@ -94,13 +95,23 @@ const newSkillForm = ref({
model: 'gpt-4o',
})
const availableModels = [
{ name: 'gpt-4o', provider: 'OpenAI', icon: 'fa-openai' },
{ name: 'gpt-4o-mini', provider: 'OpenAI', icon: 'fa-openai' },
{ name: 'claude-3-5-sonnet', provider: 'Anthropic', icon: 'fa-robot' },
{ name: 'gemini-2.0-flash', provider: 'Google', icon: 'fa-google' },
{ name: 'gpt-5', provider: 'OpenAI', icon: 'fa-openai' },
]
// 从 Model Settings 获取模型
const { models, fetchModels } = useModelSettings()
// 过滤 chat 类型的模型用于下拉框
const availableModels = computed(() => {
return models.value
.filter((m: any) => m.model_type === 'chat')
.map((m: any) => ({
name: m.model,
provider: m.provider,
icon: 'fa-brain'
}))
})
onMounted(() => {
fetchModels()
})
const goToStep2 = () => {
if (!newSkillForm.value.name.trim()) return
@@ -199,8 +210,10 @@ const toggleFolder = (folder: FolderItem) => {
// 新建文件夹
const isCreatingFolder = ref(false)
const newFolderName = ref('')
const showNewFolderInput = () => {
const newFolderParentId = ref<string | null>(null)
const showNewFolderInput = (parentId: string | null = null) => {
newFolderName.value = ''
newFolderParentId.value = parentId
isCreatingFolder.value = true
}
@@ -209,17 +222,41 @@ const createFolder = () => {
isCreatingFolder.value = false
return
}
fileTree.value.push({
const newFolder: FileItem = {
id: 'folder-' + Date.now(),
name: newFolderName.value,
icon: 'fa-folder',
type: 'folder',
expanded: true,
children: []
})
}
if (newFolderParentId.value) {
// 添加到指定文件夹作为子文件夹
const parentFolder = findFolderById(fileTree.value, newFolderParentId.value)
if (parentFolder && parentFolder.children) {
parentFolder.children.push(newFolder)
}
} else {
// 添加到根目录
fileTree.value.push(newFolder)
}
isCreatingFolder.value = false
}
// 递归查找文件夹
const findFolderById = (folders: FileItem[], id: string): FileItem | null => {
for (const folder of folders) {
if (folder.id === id) return folder
if (folder.children) {
const found = findFolderById(folder.children, id)
if (found) return found
}
}
return null
}
// 新建文件
const isCreatingFile = ref(false)
const newFileName = ref('')
@@ -356,6 +393,17 @@ const editingFileType = ref('')
// 选中文件/文件夹状态
// 鼠标悬停状态
const hoveringItem = ref<string | null>(null)
// 当前选中的文件夹(用于创建子文件夹/子文件)
const selectedFolder = ref<string | null>(null)
// 选中文件夹
const selectFolder = (folderId: string) => {
if (selectedFolder.value === folderId) {
selectedFolder.value = null // 再次点击取消选中
} else {
selectedFolder.value = folderId
}
}
// 删除文件
const deleteFile = (file: FileItem, parentId: string | null) => {
@@ -944,25 +992,26 @@ const statusClass = (status: string) => {
<label class="block text-sm font-medium text-gray-300 mb-2">
<i class="fa-solid fa-brain mr-2 text-primary-cyan"></i>Select Model
</label>
<div class="grid grid-cols-2 gap-3">
<div
<el-select
v-model="newSkillForm.model"
placeholder="Select a model"
class="w-full"
size="large"
popper-class="dark-select-dropdown"
>
<el-option
v-for="model in availableModels"
:key="model.name"
@click="newSkillForm.model = model.name"
class="p-3 rounded-xl border-2 cursor-pointer transition-all hover:scale-105"
:class="newSkillForm.model === model.name
? 'border-primary-orange bg-dark-600 shadow-lg shadow-primary-orange/20'
: 'border-dark-500 bg-dark-700 hover:border-gray-500'"
:label="`${model.name} (${model.provider})`"
:value="model.name"
>
<div class="flex items-center gap-2">
<i :class="['fa-solid', model.icon, 'text-lg']"></i>
<div>
<div class="font-medium text-white text-sm">{{ model.name }}</div>
<div class="text-xs text-gray-500">{{ model.provider }}</div>
</div>
<i :class="['fa-solid', model.icon, 'text-primary-cyan']"></i>
<span class="text-white">{{ model.name }}</span>
<span class="text-gray-500 text-sm">({{ model.provider }})</span>
</div>
</div>
</div>
</el-option>
</el-select>
</div>
</div>
@@ -1052,10 +1101,11 @@ const statusClass = (status: string) => {
>
<!-- 文件夹标题 -->
<div
@click.stop="selectFolder(folder.id)"
@mouseenter="hoveringItem = folder.id"
@mouseleave="hoveringItem = null"
class="flex items-center gap-2 px-2 py-1.5 cursor-pointer hover:bg-dark-700 group transition-colors"
:class="{ 'bg-dark-700': hoveringItem === folder.id }"
:class="{ 'bg-dark-700': hoveringItem === folder.id || selectedFolder === folder.id }"
>
<i
@click.stop="toggleFolder(folder)"
@@ -1068,6 +1118,8 @@ const statusClass = (status: string) => {
<span
class="text-sm text-gray-300 group-hover:text-white font-medium flex-1"
>{{ folder.name }}</span>
<!-- 选中状态指示器 -->
<span v-if="selectedFolder === folder.id" class="text-xs text-primary-cyan">Selected</span>
<button
@click.stop="deleteFolder(folder)"
class="text-red-400 hover:text-red-300 p-1 rounded hover:bg-dark-600 transition-colors opacity-0 group-hover:opacity-100"
@@ -1098,8 +1150,16 @@ const statusClass = (status: string) => {
<i class="fa-solid fa-trash text-xs"></i>
</button>
</div>
<!-- 文件夹内新建文件/上传按钮 -->
<!-- 文件夹内新建文件/文件/上传按钮 -->
<div class="flex items-center gap-2 px-2 py-1">
<button
@click.stop="showNewFolderInput(folder.id)"
class="flex items-center gap-1 text-xs text-gray-500 hover:text-white transition-colors opacity-0 group-hover:opacity-100"
title="New Folder"
>
<i class="fa-solid fa-folder-plus"></i>
<span>New Folder</span>
</button>
<button
@click.stop="showNewFileInput(folder.id)"
class="flex items-center gap-1 text-xs text-gray-500 hover:text-white transition-colors opacity-0 group-hover:opacity-100"

View File

@@ -4,7 +4,6 @@ import { ElMessage } from 'element-plus'
import { useModelSettings } from './settings/useModelSettings'
import FormDialog from '@/components/FormDialog.vue'
import './settings/settings.css'
import './settings/settings-parsing.css'
import './settings/modelSettings.css'
// 当前选中的设置菜单
@@ -48,25 +47,8 @@ const menuItems = [
{ key: 'members', label: 'Members', icon: 'fa-users' },
{ key: 'notifications', label: 'Notifications', icon: 'fa-bell' },
{ key: 'modelSettings', label: 'Model Settings', icon: 'fa-brain' },
{ key: 'parsing', label: 'Parsing', icon: 'fa-code' },
{ key: 'storage', label: 'Storage', icon: 'fa-database' },
]
// Model Options by Provider (for Parsing settings)
const modelOptionsByProvider: Record<string, { value: string; label: string }[]> = {
'OpenAI': [
{ value: 'gpt-4o', label: 'GPT-4o' },
{ value: 'gpt-4o-mini', label: 'GPT-4o Mini' },
{ value: 'gpt-4-turbo', label: 'GPT-4 Turbo' },
{ value: 'gpt-3.5-turbo', label: 'GPT-3.5 Turbo' },
],
'Ollama': [
{ value: 'llama3', label: 'Llama 3' },
{ value: 'mistral', label: 'Mistral' },
{ value: 'codellama', label: 'CodeLlama' },
],
}
// General 设置表单
const generalForm = ref({
name: 'Alex Smith',
@@ -100,73 +82,6 @@ const saveChanges = () => {
const showChangePassword = () => {
ElMessage.info('Password change dialog would open here')
}
// Parsing 配置表单
const parsingForm = ref({
// LLM Provider
provider: 'OpenAI',
model: 'gpt-4o',
apiKey: '',
apiEndpoint: '',
// 通用配置
maxWorkers: 5,
maxRetries: 3,
requestTimeout: 60,
enableProxy: false,
httpProxyUrl: '',
// 文本解析
enableMultimodal: true,
visionModel: 'gpt-4o',
imageUnderstandingPrice: 0.00125,
enableJsonMode: false,
jsonModeModel: 'gpt-4o',
// 文件解析
enableFileParsing: true,
enableTableRecognition: true,
enableFormulaRecognition: true,
ocrLanguage: 'en',
})
// Vision Model 选项
const visionModelOptions = [
{ value: 'gpt-4o', label: 'GPT-4o' },
{ value: 'gpt-4o-mini', label: 'GPT-4o Mini' },
{ value: 'claude-3-5-sonnet', label: 'Claude 3.5 Sonnet' },
{ value: 'claude-3-haiku', label: 'Claude 3 Haiku' },
{ value: 'gemini-1.5-pro', label: 'Gemini 1.5 Pro' },
]
// OCR 语言选项
const ocrLanguageOptions = [
{ value: 'en', label: 'English' },
{ value: 'zh', label: 'Chinese' },
{ value: 'ja', label: 'Japanese' },
{ value: 'ko', label: 'Korean' },
{ value: 'auto', label: 'Auto Detect' },
]
// 保存 Parsing 设置
const saveParsingSettings = () => {
ElMessage.success('Parsing settings saved successfully')
}
// Storage 配置表单
const storageForm = ref({
storageType: 'local',
// Local 存储
localPath: './storage',
// MinIO 存储
minioEndpoint: 'localhost:9000',
minioAccessKey: '',
minioSecretKey: '',
minioBucket: 'x-agents',
minioUseSSL: false,
})
// 保存 Storage 设置
const saveStorageSettings = () => {
ElMessage.success('Storage settings saved successfully')
}
</script>
<template>
@@ -244,186 +159,6 @@ const saveStorageSettings = () => {
</div>
<!-- Parsing 设置 -->
<div v-if="activeMenu === 'parsing'" class="settings-section">
<h2 class="section-title">Parsing</h2>
<p class="section-desc">Configure parsing settings</p>
<!-- LLM Provider -->
<div class="config-card">
<h3 class="config-title">LLM Provider</h3>
<el-form label-position="top" class="settings-form">
<div class="form-row">
<el-form-item label="Provider" class="flex-1">
<el-select v-model="parsingForm.provider" placeholder="Select provider">
<el-option v-for="p in providerOptions" :key="p.value" :label="p.label" :value="p.value" />
</el-select>
</el-form-item>
<el-form-item label="Model" class="flex-1">
<el-select v-model="parsingForm.model" placeholder="Select model">
<el-option v-for="m in modelOptionsByProvider[parsingForm.provider]" :key="m.value" :label="m.label" :value="m.value" />
</el-select>
</el-form-item>
</div>
<el-form-item label="API Key">
<el-input v-model="parsingForm.apiKey" type="password" placeholder="Enter API key" show-password />
</el-form-item>
<el-form-item label="API Endpoint">
<el-input v-model="parsingForm.apiEndpoint" placeholder="Enter API endpoint" />
</el-form-item>
</el-form>
</div>
<!-- Parsing Configuration -->
<div class="config-card">
<h3 class="config-title">Parsing Configuration</h3>
<!-- 通用配置 -->
<div class="config-section">
<h4 class="config-subtitle">General</h4>
<el-form label-position="top" class="settings-form">
<div class="form-row">
<el-form-item label="Max Workers" class="flex-1">
<el-input-number v-model="parsingForm.maxWorkers" :min="1" :max="100" controls-position="right" />
</el-form-item>
<el-form-item label="Max Retries" class="flex-1">
<el-input-number v-model="parsingForm.maxRetries" :min="0" :max="10" controls-position="right" />
</el-form-item>
<el-form-item label="Request Timeout (seconds)" class="flex-1">
<el-input-number v-model="parsingForm.requestTimeout" :min="10" :max="600" controls-position="right" />
</el-form-item>
</div>
<div class="form-row">
<el-form-item label="Enable HTTP Proxy" class="flex-1">
<el-switch v-model="parsingForm.enableProxy" class="parsing-switch" />
</el-form-item>
<el-form-item v-if="parsingForm.enableProxy" label="HTTP Proxy URL" class="flex-1">
<el-input v-model="parsingForm.httpProxyUrl" placeholder="http://proxy:8080" />
</el-form-item>
</div>
</el-form>
</div>
<!-- 文本解析 -->
<div class="config-section">
<h4 class="config-subtitle">Text Parsing</h4>
<el-form label-position="top" class="settings-form">
<div class="form-row">
<el-form-item label="Enable Multimodal" class="flex-1">
<el-switch v-model="parsingForm.enableMultimodal" class="parsing-switch" />
</el-form-item>
<el-form-item v-if="parsingForm.enableMultimodal" label="Vision Model" class="flex-1">
<el-select v-model="parsingForm.visionModel" placeholder="Select model">
<el-option v-for="m in visionModelOptions" :key="m.value" :label="m.label" :value="m.value" />
</el-select>
</el-form-item>
<el-form-item v-if="parsingForm.enableMultimodal" label="Image Understanding Price" class="flex-1">
<el-input v-model="parsingForm.imageUnderstandingPrice" placeholder="0.00125">
<template #append>$/1k tokens</template>
</el-input>
</el-form-item>
</div>
<div class="form-row">
<el-form-item label="Enable JSON Mode" class="flex-1">
<el-switch v-model="parsingForm.enableJsonMode" class="parsing-switch" />
</el-form-item>
<el-form-item v-if="parsingForm.enableJsonMode" label="JSON Mode Model" class="flex-1">
<el-select v-model="parsingForm.jsonModeModel" placeholder="Select model">
<el-option v-for="m in visionModelOptions" :key="m.value" :label="m.label" :value="m.value" />
</el-select>
</el-form-item>
</div>
</el-form>
</div>
<!-- 文件解析 -->
<div class="config-section">
<h4 class="config-subtitle">File Parsing</h4>
<el-form label-position="top" class="settings-form">
<div class="form-row">
<el-form-item label="Enable File Parsing" class="flex-1">
<el-switch v-model="parsingForm.enableFileParsing" class="parsing-switch" />
</el-form-item>
<el-form-item label="Enable Table Recognition" class="flex-1">
<el-switch v-model="parsingForm.enableTableRecognition" class="parsing-switch" />
</el-form-item>
<el-form-item label="Enable Formula Recognition" class="flex-1">
<el-switch v-model="parsingForm.enableFormulaRecognition" class="parsing-switch" />
</el-form-item>
</div>
<el-form-item label="OCR Language">
<el-select v-model="parsingForm.ocrLanguage" placeholder="Select language">
<el-option v-for="lang in ocrLanguageOptions" :key="lang.value" :label="lang.label" :value="lang.value" />
</el-select>
</el-form-item>
</el-form>
</div>
</div>
<!-- 保存按钮 -->
<div class="form-actions mt-6">
<el-button type="primary" @click="saveParsingSettings">Save</el-button>
</div>
</div>
<!-- Storage 设置 -->
<div v-if="activeMenu === 'storage'" class="settings-section">
<h2 class="section-title">Storage</h2>
<p class="section-desc">Configure storage settings</p>
<!-- Storage Type -->
<div class="config-card">
<h3 class="config-title">Storage Type</h3>
<el-form label-position="top" class="settings-form">
<el-form-item label="Storage Type">
<el-select v-model="storageForm.storageType" placeholder="Select storage type">
<el-option label="Local" value="local" />
<el-option label="MinIO" value="minio" />
</el-select>
</el-form-item>
</el-form>
</div>
<!-- Local Storage -->
<div v-if="storageForm.storageType === 'local'" class="config-card">
<h3 class="config-title">Local Storage</h3>
<el-form label-position="top" class="settings-form">
<el-form-item label="Storage Path">
<el-input v-model="storageForm.localPath" placeholder="Enter local storage path" />
</el-form-item>
</el-form>
</div>
<!-- MinIO Storage -->
<div v-if="storageForm.storageType === 'minio'" class="config-card">
<h3 class="config-title">MinIO Storage</h3>
<el-form label-position="top" class="settings-form">
<el-form-item label="Endpoint">
<el-input v-model="storageForm.minioEndpoint" placeholder="e.g., localhost:9000" />
</el-form-item>
<div class="form-row">
<el-form-item label="Access Key" class="flex-1">
<el-input v-model="storageForm.minioAccessKey" placeholder="Enter access key" />
</el-form-item>
<el-form-item label="Secret Key" class="flex-1">
<el-input v-model="storageForm.minioSecretKey" type="password" placeholder="Enter secret key" show-password />
</el-form-item>
</div>
<el-form-item label="Bucket">
<el-input v-model="storageForm.minioBucket" placeholder="Enter bucket name" />
</el-form-item>
<el-form-item label="Use SSL">
<el-switch v-model="storageForm.minioUseSSL" class="parsing-switch" />
</el-form-item>
</el-form>
</div>
<!-- 保存按钮 -->
<div class="form-actions mt-6">
<el-button type="primary" @click="saveStorageSettings">Save</el-button>
</div>
</div>
<!-- Members 设置 -->
<div v-if="activeMenu === 'members'" class="settings-section">
<h2 class="section-title">Members</h2>
@@ -700,41 +435,3 @@ const saveStorageSettings = () => {
</div>
</div>
</template>
<style>
/* Model Settings dialog - 最高优先级覆盖 */
/* 输入框 */
.add-model-dialog .el-input__wrapper {
background-color: #171922 !important;
}
.add-model-dialog .el-input__wrapper input {
color: #ffffff !important;
-webkit-text-fill-color: #ffffff !important;
}
.add-model-dialog .el-input__wrapper input::placeholder {
color: #9ca3af !important;
-webkit-text-fill-color: #9ca3af !important;
}
/* 选择框 */
.add-model-dialog .el-select__wrapper {
background-color: #171922 !important;
}
.add-model-dialog .el-select__wrapper .el-select__selected-item {
color: #ffffff !important;
}
.add-model-dialog .el-select__wrapper input::placeholder {
color: #9ca3af !important;
-webkit-text-fill-color: #9ca3af !important;
}
/* 未选中时的占位符文字 */
.add-model-dialog .el-select__placeholder {
color: #9ca3af !important;
}
</style>

View File

@@ -364,25 +364,41 @@
box-shadow: 0 0 0 3px rgba(54, 191, 250, 0.15);
}
.kb-form :deep(.el-input__inner) {
color: #e8eaed;
.kb-form :deep(.el-input__wrapper input) {
color: #e8eaed !important;
-webkit-text-fill-color: #e8eaed !important;
font-size: 14px;
}
.kb-form :deep(.el-input__inner::placeholder) {
color: #5f6368;
.kb-form :deep(.el-input__wrapper input::placeholder) {
color: #6b7280 !important;
-webkit-text-fill-color: #6b7280 !important;
}
.kb-form :deep(.el-input__wrapper) {
background-color: #161b22 !important;
}
.kb-form :deep(.el-input__wrapper input) {
background-color: transparent !important;
}
.kb-form :deep(.el-textarea__inner) {
background-color: #161b22;
border: 1px solid #2d3640;
border-radius: 8px;
color: #e8eaed;
color: #e8eaed !important;
-webkit-text-fill-color: #e8eaed !important;
font-size: 14px;
box-shadow: none;
padding: 12px;
}
.kb-form :deep(.el-textarea__inner::placeholder) {
color: #6b7280 !important;
-webkit-text-fill-color: #6b7280 !important;
}
.kb-form :deep(.el-textarea__inner:hover) {
border-color: #ffffff;
}
@@ -557,6 +573,510 @@
color: #5f6368;
}
/* 文件上传弹窗布局 */
.file-upload-dialog .el-dialog {
position: absolute !important;
top: 8px !important;
left: 50% !important;
transform: translateX(-50%) !important;
margin-bottom: 8px !important;
max-height: calc(100vh - 16px);
}
.file-upload-dialog .el-dialog__body {
padding: 0;
}
.file-upload-layout {
display: flex;
flex-direction: column;
height: 85vh;
background-color: #0f1419;
}
/* 顶部导航 */
.file-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
background-color: #121218;
border-bottom: 1px solid #2a2a3a;
}
.back-btn {
background: none;
border: none;
color: #9ca3af;
font-size: 18px;
cursor: pointer;
padding: 8px;
border-radius: 6px;
}
.back-btn:hover {
background-color: #1e2832;
color: #ffffff;
}
.file-title {
font-size: 16px;
font-weight: 600;
color: #ffffff;
}
/* 标签栏 */
.file-tabs {
display: flex;
gap: 4px;
padding: 12px 20px;
background-color: #121218;
border-bottom: 1px solid #2a2a3a;
}
.file-tab {
padding: 8px 16px;
border-radius: 6px;
font-size: 14px;
color: #9ca3af;
cursor: pointer;
transition: all 0.2s;
}
.file-tab:hover {
background-color: rgba(249, 115, 22, 0.1);
color: #f97316;
}
.file-tab.active {
background-color: rgba(249, 115, 22, 0.15);
color: #f97316;
}
/* 主内容区 */
.file-main {
flex: 1;
display: flex;
overflow: hidden;
}
/* 左侧文件列表 */
.file-list {
width: 420px;
background-color: #0f1419;
border-right: 1px solid #2a2a3a;
overflow-y: auto;
padding: 12px;
}
.file-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px;
border-radius: 8px;
cursor: pointer;
transition: all 0.2s;
margin-bottom: 8px;
border: 2px solid transparent;
}
.file-item:hover {
background-color: rgba(249, 115, 22, 0.08);
}
.file-item.selected {
background-color: rgba(249, 115, 22, 0.12);
border-color: #f97316;
}
.file-item-icon {
width: 40px;
height: 40px;
background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.file-item-icon i {
font-size: 18px;
color: white;
}
.file-item-info {
flex: 1;
min-width: 0;
}
.file-item-name {
font-size: 14px;
color: #e8eaed;
font-weight: 500;
margin-bottom: 4px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.file-item-meta {
font-size: 12px;
color: #6b7280;
display: flex;
gap: 8px;
}
.file-item-status {
flex-shrink: 0;
}
.file-item-status i {
font-size: 14px;
}
.file-item-status.success i {
color: #22c55e;
}
.file-item-status.failed i {
color: #ef4444;
}
.file-item-status.parsing i {
color: #f59e0b;
}
/* 右侧预览面板 */
.file-preview {
flex: 1;
display: flex;
flex-direction: column;
background-color: #121218;
}
.preview-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid #2a2a3a;
flex-wrap: wrap;
gap: 12px;
}
.preview-header-left {
display: flex;
align-items: center;
gap: 12px;
}
.preview-header-left i {
font-size: 28px;
color: #3b82f6;
}
.preview-filename {
font-size: 15px;
color: #e8eaed;
font-weight: 500;
}
.preview-header-info {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
}
.info-tag {
font-size: 12px;
color: #9ca3af;
background-color: #1e2832;
padding: 4px 10px;
border-radius: 4px;
}
.info-tag.success {
background-color: rgba(34, 197, 94, 0.15);
color: #22c55e;
}
.preview-content {
flex: 1;
padding: 0;
overflow-y: auto;
display: flex;
flex-direction: column;
}
.pdf-preview {
flex: 1;
min-height: 0;
background-color: #1a1a1a;
}
.pdf-iframe {
width: 100%;
height: 100%;
border: none;
}
.preview-info {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 16px;
margin-bottom: 24px;
}
.info-row {
display: flex;
flex-direction: column;
gap: 4px;
}
.info-label {
font-size: 12px;
color: #6b7280;
}
.info-value {
font-size: 14px;
color: #e8eaed;
}
.info-value.success {
color: #22c55e;
}
.preview-text {
border: 1px solid #2a2a3a;
border-radius: 8px;
overflow: hidden;
}
.preview-section-title {
font-size: 13px;
font-weight: 500;
color: #e8eaed;
padding: 12px 16px;
background-color: #1a1c25;
border-bottom: 1px solid #2a2a3a;
}
.preview-text-content {
padding: 16px;
background-color: #0f1419;
max-height: 320px;
overflow-y: auto;
}
.preview-text-content p {
font-size: 13px;
color: #9ca3af;
line-height: 1.7;
margin: 0 0 8px 0;
}
.preview-pagination {
display: flex;
align-items: center;
justify-content: center;
gap: 16px;
margin-top: 16px;
}
.page-btn {
width: 32px;
height: 32px;
border-radius: 6px;
border: 1px solid #2a2a3a;
background-color: #1a1c25;
color: #9ca3af;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s;
}
.page-btn:hover:not(:disabled) {
border-color: #f97316;
color: #f97316;
}
.page-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.page-info {
font-size: 13px;
color: #9ca3af;
}
.preview-actions {
display: flex;
justify-content: flex-end;
gap: 12px;
padding: 16px 20px;
border-top: 1px solid #2a2a3a;
background-color: #0f1419;
}
.action-btn {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 16px;
border-radius: 6px;
font-size: 13px;
cursor: pointer;
transition: all 0.2s;
border: none;
}
.action-btn.delete {
background-color: rgba(239, 68, 68, 0.15);
color: #ef4444;
}
.action-btn.delete:hover {
background-color: rgba(239, 68, 68, 0.25);
}
.action-btn.reparse {
background-color: rgba(249, 115, 22, 0.15);
color: #f97316;
}
.action-btn.reparse:hover {
background-color: rgba(249, 115, 22, 0.25);
}
.action-btn.confirm {
background-color: #f97316;
color: white;
}
.action-btn.confirm:hover {
background-color: #ea580c;
}
.file-menu-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 20px;
color: #9ca3af;
cursor: pointer;
transition: all 0.2s;
font-size: 14px;
}
.file-menu-item:hover {
background-color: rgba(249, 115, 22, 0.1);
color: #f97316;
}
.file-menu-item.active {
background-color: rgba(249, 115, 22, 0.15);
color: #f97316;
border-right: 3px solid #f97316;
}
.file-menu-item i {
font-size: 16px;
width: 20px;
text-align: center;
}
.file-content {
flex: 1;
padding: 24px;
overflow-y: auto;
}
.content-title {
font-size: 18px;
font-weight: 600;
color: #e8eaed;
margin-bottom: 20px;
}
/* 上传区域 */
.upload-area {
height: 100%;
display: flex;
flex-direction: column;
}
.upload-box {
flex: 1;
border: 2px dashed #3a3a4a;
border-radius: 12px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16px;
cursor: pointer;
transition: all 0.2s;
position: relative;
}
.upload-box:hover {
border-color: #f97316;
background-color: rgba(249, 115, 22, 0.05);
}
.upload-btn {
position: absolute;
bottom: 20px;
left: 20px;
}
.upload-icon {
font-size: 48px;
color: #5f6368;
margin-bottom: 16px;
}
.upload-text {
font-size: 16px;
color: #e8eaed;
margin-bottom: 8px;
}
.upload-hint {
font-size: 13px;
color: #6b7280;
}
.upload-btn {
margin-top: 8px;
}
.file-count {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 0;
color: #9ca3af;
font-size: 14px;
}
.doc-list,
.doc-chunks,
.parsing-config,
.storage-config {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.footer-right {
display: flex;
gap: 10px;
@@ -588,7 +1108,7 @@
font-weight: 500;
display: flex;
align-items: center;
gap: 8px;
gap: 10px;
}
.prev-btn:hover {
@@ -597,7 +1117,7 @@
}
.next-btn {
background: linear-gradient(135deg, #ffffff 0%, #0ea5e9 100%);
background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
border: none;
color: white;
padding: 10px 20px;
@@ -606,13 +1126,13 @@
font-weight: 600;
display: flex;
align-items: center;
gap: 8px;
box-shadow: 0 4px 12px rgba(54, 191, 250, 0.25);
gap: 10px;
box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}
.next-btn:hover {
background: linear-gradient(135deg, #4dc3ff 0%, #ffffff 100%);
box-shadow: 0 6px 16px rgba(54, 191, 250, 0.35);
background: linear-gradient(135deg, #fb923c 0%, #f97316 100%);
box-shadow: 0 6px 16px rgba(249, 115, 22, 0.35);
}
.confirm-btn {

View File

@@ -1,280 +0,0 @@
/* Parsing 和 Storage 配置样式 */
/* 配置卡片 */
.config-card {
background-color: #0d0d12;
border: 1px solid #252530;
border-radius: 12px;
padding: 24px;
margin-bottom: 24px;
transition: all 0.25s ease;
}
.config-card:hover {
border-color: #353545;
}
.config-title {
font-size: 16px;
font-weight: 600;
color: white;
margin-bottom: 20px;
padding-bottom: 12px;
border-bottom: 1px solid #252530;
}
.config-section {
margin-bottom: 24px;
}
.config-section:last-child {
margin-bottom: 0;
}
.config-subtitle {
font-size: 14px;
font-weight: 500;
color: #9ca3af;
margin-bottom: 16px;
}
/* 添加模型按钮 */
.add-model-btn {
background-color: #f97316;
border-color: #f97316;
color: white;
padding: 8px 16px;
border-radius: 6px;
font-size: 14px;
cursor: pointer;
transition: all 0.25s ease;
display: flex;
align-items: center;
gap: 8px;
}
.add-model-btn:hover {
background-color: #ea580c;
border-color: #ea580c;
}
/* 操作按钮 */
.btn-icon {
padding: 6px;
border-radius: 6px;
transition: all 0.25s ease;
background: transparent;
border: none;
cursor: pointer;
}
.btn-icon:hover {
background-color: #1e1e28;
}
.btn-icon i {
color: #9ca3af;
font-size: 14px;
}
.btn-icon:hover i {
color: #f97316 !important;
}
/* 弹窗样式 */
.add-model-dialog :deep(.el-dialog) {
background-color: #16161e;
border-radius: 12px;
border: 1px solid #252530;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
animation: dialogFadeIn 0.25s ease;
}
@keyframes dialogFadeIn {
from {
opacity: 0;
transform: scale(0.95);
}
to {
opacity: 1;
transform: scale(1);
}
}
.add-model-dialog :deep(.el-dialog__header) {
padding: 20px 24px;
border-bottom: 1px solid #252530;
}
.add-model-dialog :deep(.el-dialog__title) {
color: white;
font-size: 18px;
font-weight: 600;
}
.add-model-dialog :deep(.el-dialog__headerbtn) {
top: 20px;
right: 20px;
}
.add-model-dialog :deep(.el-dialog__headerbtn .el-dialog__close) {
color: #9ca3af;
}
.add-model-dialog :deep(.el-dialog__headerbtn:hover .el-dialog__close) {
color: #f97316;
}
.add-model-dialog :deep(.el-dialog__body) {
padding: 24px;
}
.add-model-dialog :deep(.el-dialog__footer) {
padding: 16px 24px;
border-top: 1px solid #252530;
}
/* 弹窗描述 */
.dialog-desc {
font-size: 14px;
color: #9ca3af;
margin-bottom: 20px;
}
/* 弹窗底部按钮 */
.dialog-footer {
display: flex;
justify-content: flex-end;
align-items: center;
gap: 12px;
}
/* 测试连接按钮 */
.test-btn {
background-color: #1e1e28;
border: 1px solid #3a3a4a;
color: #d1d5db;
transition: all 0.25s ease;
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
}
.test-btn:hover {
background-color: #2a2a3a;
border-color: #4a4a5a;
color: white;
}
/* 连接状态 */
.connection-status {
display: flex;
align-items: center;
gap: 6px;
font-size: 13px;
margin-top: 8px;
}
.connection-status.success {
color: #10b981;
}
.connection-status.error {
color: #ef4444;
}
/* 弹窗表单 */
.add-model-dialog :deep(.el-form-item__label) {
color: #d1d5db;
font-size: 14px;
}
.add-model-dialog :deep(.el-input__wrapper) {
background-color: #171922;
border: 1px solid #4b5563;
box-shadow: none;
}
.add-model-dialog :deep(.el-input__inner) {
color: white;
}
.add-model-dialog :deep(.el-input__inner::placeholder) {
color: #6b7280;
}
.add-model-dialog :deep(.el-select) {
width: 100%;
}
.add-model-dialog :deep(.el-select .el-input__wrapper) {
background-color: #171922;
border: 1px solid #4b5563;
}
.add-model-dialog :deep(.el-select .el-input__inner) {
color: white;
}
.add-model-dialog :deep(.el-select .el-input__inner::placeholder) {
color: #6b7280;
}
.add-model-dialog :deep(.el-select-dropdown) {
background-color: #1a1a24;
border: 1px solid #2a2a3a;
}
.add-model-dialog :deep(.el-select-dropdown__item) {
color: #d1d5db;
}
.add-model-dialog :deep(.el-select-dropdown__item.hover),
.add-model-dialog :deep(.el-select-dropdown__item:hover) {
background-color: #4b5563;
}
.add-model-dialog :deep(.el-select-dropdown__item.selected) {
color: #f97316;
}
.add-model-dialog :deep(.el-button--primary) {
background-color: #f97316;
border-color: #f97316;
}
.add-model-dialog :deep(.el-button--primary:hover) {
background-color: #ea580c;
border-color: #ea580c;
}
/* API Endpoint 字段 */
.api-endpoint-field {
display: flex;
gap: 12px;
}
.api-endpoint-field .el-input {
flex: 1;
}
/* 加载状态 */
.loading-spinner {
text-align: center;
padding: 32px;
color: #9ca3af;
}
.loading-spinner i {
font-size: 24px;
animation: spin 1s linear infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}