feat: 兼容前后端不分离的情况。
This commit is contained in:
parent
db8b5faf0e
commit
65b8090ad0
15
apis/tpl/tpl.go
Normal file
15
apis/tpl/tpl.go
Normal file
@ -0,0 +1,15 @@
|
||||
package tpl
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
/*
|
||||
@Author : lanyulei
|
||||
*/
|
||||
|
||||
func Tpl(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "index.html", gin.H{})
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"ferry/apis/tpl"
|
||||
"ferry/pkg/jwtauth"
|
||||
"ferry/router/dashboard"
|
||||
"ferry/router/process"
|
||||
@ -19,7 +20,7 @@ func InitSysRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) *gin
|
||||
systemRouter.SysBaseRouter(g)
|
||||
|
||||
// 静态文件
|
||||
sysStaticFileRouter(g)
|
||||
sysStaticFileRouter(g, r)
|
||||
|
||||
// swagger;注意:生产环境可以注释掉
|
||||
sysSwaggerRouter(g)
|
||||
@ -33,8 +34,9 @@ func InitSysRouter(r *gin.Engine, authMiddleware *jwtauth.GinJWTMiddleware) *gin
|
||||
return g
|
||||
}
|
||||
|
||||
func sysStaticFileRouter(r *gin.RouterGroup) {
|
||||
func sysStaticFileRouter(r *gin.RouterGroup, g *gin.Engine) {
|
||||
r.Static("/static", "./static")
|
||||
g.LoadHTMLGlob("template/web/index.html")
|
||||
}
|
||||
|
||||
func sysSwaggerRouter(r *gin.RouterGroup) {
|
||||
@ -48,6 +50,9 @@ func sysCheckRoleRouterInit(r *gin.RouterGroup, authMiddleware *jwtauth.GinJWTMi
|
||||
|
||||
v1 := r.Group("/api/v1")
|
||||
|
||||
// 兼容前后端不分离的情
|
||||
r.GET("/", tpl.Tpl)
|
||||
|
||||
// 首页
|
||||
dashboard.RegisterDashboardRouter(v1, authMiddleware)
|
||||
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
)
|
||||
|
||||
func SysBaseRouter(r *gin.RouterGroup) {
|
||||
r.GET("/", system.HelloWorld)
|
||||
//r.GET("/", system.HelloWorld)
|
||||
r.GET("/info", handler.Ping)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user