🎨 重构用户端前端为vue开发,完善基础类和角色相关接口

This commit is contained in:
2026-02-10 21:55:45 +08:00
parent db934ebed7
commit 56e821b222
92 changed files with 18377 additions and 21 deletions

View File

@@ -35,6 +35,10 @@ 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 {
@@ -58,6 +62,24 @@ func Routers() *gin.Engine {
systemRouter := router.RouterGroupApp.System
exampleRouter := router.RouterGroupApp.Example
appRouter := router.RouterGroupApp.App // 前台应用路由
// 前台用户端静态文件服务web-app
// 开发环境:直接使用 web-app/public 目录
// 生产环境:使用打包后的 web-app/dist 目录
webAppPath := "../web-app/public"
if _, err := os.Stat(webAppPath); err == nil {
Router.Static("/css", webAppPath+"/css")
Router.Static("/scripts", webAppPath+"/scripts")
Router.Static("/img", webAppPath+"/img")
Router.Static("/fonts", webAppPath+"/fonts")
Router.Static("/webfonts", webAppPath+"/webfonts")
Router.StaticFile("/auth.html", webAppPath+"/auth.html")
Router.StaticFile("/dashboard-example.html", webAppPath+"/dashboard-example.html")
Router.StaticFile("/favicon.ico", webAppPath+"/favicon.ico")
global.GVA_LOG.Info("前台静态文件服务已启动: " + webAppPath)
}
// 管理后台前端静态文件web
// 如果想要不使用nginx代理前端网页可以修改 web/.env.production 下的
// VUE_APP_BASE_API = /
// VUE_APP_BASE_PATH = http://localhost
@@ -67,10 +89,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")
// 跨域配置(前台应用需要)
Router.Use(middleware.Cors()) // 直接放行全部跨域请求
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")
@@ -121,8 +143,9 @@ func Routers() *gin.Engine {
// 前台应用路由(新增)
{
appGroup := PublicGroup.Group("app") // 统一使用 /app 前缀
appRouter.InitAuthRouter(appGroup) // 认证路由:/app/auth/* 和 /app/user/*
appGroup := PublicGroup.Group("app") // 统一使用 /app 前缀
appRouter.InitAuthRouter(appGroup) // 认证路由:/app/auth/* 和 /app/user/*
appRouter.InitCharacterRouter(appGroup) // 角色卡路由:/app/character/*
}
//插件路由安装