🎉 更新系统版本
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"git.echol.cn/loser/st/server/model/example"
|
||||
sysModel "git.echol.cn/loser/st/server/model/system"
|
||||
"git.echol.cn/loser/st/server/plugin/announcement/model"
|
||||
"git.echol.cn/loser/st/server/service/system"
|
||||
adapter "github.com/casbin/gorm-adapter/v3"
|
||||
"gorm.io/gorm"
|
||||
@@ -64,6 +65,8 @@ func (e *ensureTables) MigrateTable(ctx context.Context) (context.Context, error
|
||||
example.ExaFileChunk{},
|
||||
example.ExaFileUploadAndDownload{},
|
||||
example.ExaAttachmentCategory{},
|
||||
|
||||
model.Info{},
|
||||
}
|
||||
for _, t := range tables {
|
||||
_ = db.AutoMigrate(&t)
|
||||
@@ -103,6 +106,8 @@ func (e *ensureTables) TableCreated(ctx context.Context) bool {
|
||||
example.ExaFileChunk{},
|
||||
example.ExaFileUploadAndDownload{},
|
||||
example.ExaAttachmentCategory{},
|
||||
|
||||
model.Info{},
|
||||
}
|
||||
yes := true
|
||||
for _, t := range tables {
|
||||
|
||||
@@ -35,21 +35,12 @@ func (fs justFilesFilesystem) Open(name string) (http.File, error) {
|
||||
|
||||
func Routers() *gin.Engine {
|
||||
Router := gin.New()
|
||||
|
||||
// 设置文件上传大小限制(10MB)
|
||||
Router.MaxMultipartMemory = 10 << 20 // 10 MB
|
||||
|
||||
// 使用自定义的 Recovery 中间件,记录 panic 并入库
|
||||
Router.Use(middleware.GinRecovery(true))
|
||||
if gin.Mode() == gin.DebugMode {
|
||||
Router.Use(gin.Logger())
|
||||
}
|
||||
|
||||
// 跨域配置(前台应用需要)
|
||||
// 必须在静态文件路由之前注册,否则静态文件跨域会失败
|
||||
Router.Use(middleware.Cors())
|
||||
global.GVA_LOG.Info("use middleware cors")
|
||||
|
||||
if !global.GVA_CONFIG.MCP.Separate {
|
||||
|
||||
sseServer := McpRun()
|
||||
@@ -66,26 +57,6 @@ func Routers() *gin.Engine {
|
||||
|
||||
systemRouter := router.RouterGroupApp.System
|
||||
exampleRouter := router.RouterGroupApp.Example
|
||||
appRouter := router.RouterGroupApp.App // 前台应用路由
|
||||
|
||||
// SillyTavern 核心脚本静态文件服务
|
||||
// 所有核心文件存储在 data/st-core-scripts/ 下,完全独立于 web-app/ 目录
|
||||
stCorePath := "data/st-core-scripts"
|
||||
if _, err := os.Stat(stCorePath); err == nil {
|
||||
Router.Static("/scripts", stCorePath+"/scripts")
|
||||
Router.Static("/css", stCorePath+"/css")
|
||||
Router.Static("/img", stCorePath+"/img")
|
||||
Router.Static("/webfonts", stCorePath+"/webfonts")
|
||||
Router.Static("/lib", stCorePath+"/lib") // SillyTavern 依赖的第三方库
|
||||
Router.Static("/locales", stCorePath+"/locales") // 国际化文件
|
||||
Router.StaticFile("/script.js", stCorePath+"/script.js") // SillyTavern 主入口
|
||||
Router.StaticFile("/lib.js", stCorePath+"/lib.js") // Webpack 编译后的 lib.js
|
||||
global.GVA_LOG.Info("SillyTavern 核心脚本服务已启动: " + stCorePath)
|
||||
} else {
|
||||
global.GVA_LOG.Warn("SillyTavern 核心脚本目录不存在: " + stCorePath)
|
||||
}
|
||||
|
||||
// 管理后台前端静态文件(web)
|
||||
// 如果想要不使用nginx代理前端网页,可以修改 web/.env.production 下的
|
||||
// VUE_APP_BASE_API = /
|
||||
// VUE_APP_BASE_PATH = http://localhost
|
||||
@@ -95,7 +66,10 @@ func Routers() *gin.Engine {
|
||||
// Router.StaticFile("/", "./dist/index.html") // 前端网页入口页面
|
||||
|
||||
Router.StaticFS(global.GVA_CONFIG.Local.StorePath, justFilesFilesystem{http.Dir(global.GVA_CONFIG.Local.StorePath)}) // Router.Use(middleware.LoadTls()) // 如果需要使用https 请打开此中间件 然后前往 core/server.go 将启动模式 更变为 Router.RunTLS("端口","你的cre/pem文件","你的key文件")
|
||||
|
||||
// 跨域,如需跨域可以打开下面的注释
|
||||
// Router.Use(middleware.Cors()) // 直接放行全部跨域请求
|
||||
// Router.Use(middleware.CorsByRules()) // 按照配置的规则放行跨域请求
|
||||
// global.GVA_LOG.Info("use middleware cors")
|
||||
docs.SwaggerInfo.BasePath = global.GVA_CONFIG.System.RouterPrefix
|
||||
Router.GET(global.GVA_CONFIG.System.RouterPrefix+"/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
global.GVA_LOG.Info("register swagger handler")
|
||||
@@ -137,26 +111,13 @@ func Routers() *gin.Engine {
|
||||
systemRouter.InitSysErrorRouter(PrivateGroup, PublicGroup) // 错误日志
|
||||
systemRouter.InitLoginLogRouter(PrivateGroup) // 登录日志
|
||||
systemRouter.InitApiTokenRouter(PrivateGroup) // apiToken签发
|
||||
systemRouter.InitSkillsRouter(PrivateGroup) // Skills 定义器
|
||||
systemRouter.InitSkillsRouter(PrivateGroup, PublicGroup) // Skills 定义器
|
||||
exampleRouter.InitCustomerRouter(PrivateGroup) // 客户路由
|
||||
exampleRouter.InitFileUploadAndDownloadRouter(PrivateGroup) // 文件上传下载功能路由
|
||||
exampleRouter.InitAttachmentCategoryRouterRouter(PrivateGroup) // 文件上传下载分类
|
||||
|
||||
}
|
||||
|
||||
// 前台应用路由(新增)
|
||||
{
|
||||
appGroup := PublicGroup.Group("app") // 统一使用 /app 前缀
|
||||
appRouter.InitAuthRouter(appGroup) // 认证路由:/app/auth/* 和 /app/user/*
|
||||
appRouter.InitCharacterRouter(appGroup) // 角色卡路由:/app/character/*
|
||||
appRouter.InitConversationRouter(appGroup) // 对话路由:/app/conversation/*
|
||||
appRouter.InitAIConfigRouter(appGroup) // AI配置路由:/app/ai-config/*
|
||||
appRouter.InitPresetRouter(appGroup) // 预设路由:/app/preset/*
|
||||
appRouter.InitUploadRouter(appGroup) // 上传路由:/app/upload/*
|
||||
appRouter.InitWorldbookRouter(appGroup) // 世界书路由:/app/worldbook/*
|
||||
appRouter.InitRegexScriptRouter(appGroup) // 正则脚本路由:/app/regex/*
|
||||
}
|
||||
|
||||
//插件路由安装
|
||||
InstallPlugin(PrivateGroup, PublicGroup, Router)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user