diff --git a/FrontEnd/assignment.html b/FrontEnd/assignment.html index 59106a9..be9a314 100644 --- a/FrontEnd/assignment.html +++ b/FrontEnd/assignment.html @@ -5,7 +5,7 @@

今日值班表

-
+
diff --git a/main.go b/main.go index 2fe62f8..f1c662c 100644 --- a/main.go +++ b/main.go @@ -3,9 +3,11 @@ package main import ( "fmt" "github.com/labstack/echo/v4" + "html/template" "zsxyww.com/scheduler/config" "zsxyww.com/scheduler/database" "zsxyww.com/scheduler/route" + "zsxyww.com/scheduler/tl" ) func main() { @@ -23,4 +25,9 @@ func main() { func register(app *echo.Echo) { route.Route(app) route.Middleware(app) + renderer := tl.tlw{ + Tl: template.Must(template.ParseGlob("templates/*.html")), + } + app.Renderer = renderer + } diff --git a/route/route.go b/route/route.go index 30f88c1..4ba4a27 100644 --- a/route/route.go +++ b/route/route.go @@ -12,5 +12,5 @@ func Route(app *echo.Echo) { staticFiles.Use(middleware.Static("./FrontEnd")) api := app.Group("/api/") - api.GET("/getAssignment", handler.GetAssignment) + api.GET("getAssignment", handler.GetAssignment) } diff --git a/templates/renderer.go b/templates/renderer.go new file mode 100644 index 0000000..200723d --- /dev/null +++ b/templates/renderer.go @@ -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) +}