提交 cfead23e 编写于 作者: J Jason

代码整理

上级 0842107e
call env.bat
@echo off
set GOOS=linux
:: 编译前端(编译结束后会退出中止批处理,待解)
::cd portal
::ng build --prod
::cd ..
:: 把前端转化成go
:: go get -u github.com/UnnoTed/fileb0x
fileb0x b0x.yaml
:: 整体编译
go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOPRIVATE=*.gitlab.com,*.gitee.com
go env -w GOSUMDB=off
set GOOS=linux
go build -o dtu-admin main.go
set GOOS=windows
go build -o dtu-admin.exe main.go
......@@ -37,5 +37,6 @@ func main() {
return
}
//启动Web服务
web.Serve()
}
......@@ -22,29 +22,24 @@ func Serve() {
//GIN初始化
app := gin.Default()
//前端静态文件
//app.Use(static.Serve("/", static.LocalFile("./www/", false)))
api.RegisterRoutes(app.Group("/api"))
open.RegisterRoutes(app.Group("/open"))
//Swagger文档,需要先执行swag init生成文档
app.GET("/docs/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
//app.Use( ginSwagger.WrapHandler(wwwFiles.Handler))
//支持前端框架Angular的无“#”路由
//前端静态文件
//app.GET("/*any", func(c *gin.Context) {
app.Use(func(c *gin.Context) {
if c.Request.Method == http.MethodGet {
//支持前端框架Angular的无“#”路由
if c.Request.RequestURI == "/" {
c.Request.URL.Path = "index.html"
} else if _, err := wwwFiles.FS.Stat(wwwFiles.CTX, c.Request.RequestURI) ; err != nil {
c.Request.URL.Path = "index.html"
}
//文件失效期已经在Handler中处理
wwwFiles.Handler.ServeHTTP(c.Writer, c.Request)
//http.ServeFile(c.Writer, c.Request, "./www/index.html")
}
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册