mirror of
https://github.com/ZSCNetSupportDept/scheduler.git
synced 2025-10-28 20:45:05 +08:00
编写了模板注册部分
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div>
|
<div>
|
||||||
<h1 align=center>今日值班表</h1>
|
<h1 align=center>今日值班表</h1>
|
||||||
<div id="table" hx-get="/api/getAssignment" hx-target="table" hx-swap="innerHTML"></div>
|
<div id="table" hx-get="/api/getAssignment" hx-target="table" hx-swap="innerHTML" align=center></div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
7
main.go
7
main.go
@@ -3,9 +3,11 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
|
"html/template"
|
||||||
"zsxyww.com/scheduler/config"
|
"zsxyww.com/scheduler/config"
|
||||||
"zsxyww.com/scheduler/database"
|
"zsxyww.com/scheduler/database"
|
||||||
"zsxyww.com/scheduler/route"
|
"zsxyww.com/scheduler/route"
|
||||||
|
"zsxyww.com/scheduler/tl"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -23,4 +25,9 @@ func main() {
|
|||||||
func register(app *echo.Echo) {
|
func register(app *echo.Echo) {
|
||||||
route.Route(app)
|
route.Route(app)
|
||||||
route.Middleware(app)
|
route.Middleware(app)
|
||||||
|
renderer := tl.tlw{
|
||||||
|
Tl: template.Must(template.ParseGlob("templates/*.html")),
|
||||||
|
}
|
||||||
|
app.Renderer = renderer
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ func Route(app *echo.Echo) {
|
|||||||
staticFiles.Use(middleware.Static("./FrontEnd"))
|
staticFiles.Use(middleware.Static("./FrontEnd"))
|
||||||
|
|
||||||
api := app.Group("/api/")
|
api := app.Group("/api/")
|
||||||
api.GET("/getAssignment", handler.GetAssignment)
|
api.GET("getAssignment", handler.GetAssignment)
|
||||||
}
|
}
|
||||||
|
|||||||
16
templates/renderer.go
Normal file
16
templates/renderer.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package tl
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"html/template"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// template wrapper
|
||||||
|
type tlw struct {
|
||||||
|
Tl *template.Template
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t tlw) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
|
||||||
|
return t.Tl.ExecuteTemplate(w, name, data)
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user