完善了值班表模板,现在基本上是可以最基本的使用了,另外增加了Makefile,可以一键构建,和部署

This commit is contained in:
2024-12-29 12:40:00 +08:00
parent ecf4a1db8a
commit de13e64f49
8 changed files with 35 additions and 26 deletions

View File

@@ -1,11 +1,11 @@
<html> <html>
<head>
<script src="htmx.min.js"></script>
</head>
<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" align=center></div> <div align=center>
<button hx-get="/api/getAssignment" align=center hx-swap="outerHTML"> 点我!</button>
</div>
</div> </div>
</body> </body>
<script src="/htmx.min.js"></script>
</html> </html>

View File

@@ -2,17 +2,17 @@
<body > <body >
<div align=center> <div align=center>
<h1>网维排班系统</h1> <h1>网维排班系统</h1>
<a href=assignment.html>查看今日值班表</br></a> <a href=/assignment.html>查看今日值班表</br></a>
<br> <br>
<a href=switch.html>发起换班</br></a> <a href=/switch.html>发起换班</br></a>
<a href=repay.html>发起补班</br></a> <a href=/repay.html>发起补班</br></a>
<a href=volunteering.html>发起蹭班</br></a> <a href=/volunteering.html>发起蹭班</br></a>
</div> </div>
<br> <br>
</br> </br>
<div align=center> <div align=center>
<footer> <footer>
<a href=admin.html>管理</br></a> <a href=/admin.html>管理</br></a>
<i>有任何问题和建议,都可以联系开发组组长:)</i> <i>有任何问题和建议,都可以联系开发组组长:)</i>
</footer> </footer>
</div> </div>

9
Makefile Normal file
View File

@@ -0,0 +1,9 @@
build:
go build
deploy:
go build -o scheduler
cp scheduler /opt/zscww_scheduler/scheduler
cp -r FrontEnd /opt/zscww_scheduler/FrontEnd
chmod +x /opt/zscww_scheduler/scheduler

View File

@@ -86,6 +86,9 @@ func generateTable() (*[7][]string, error) {
} }
fmt.Printf("today:%v\n", today) fmt.Printf("today:%v\n", today)
fmt.Printf("table:%v\n", table) fmt.Printf("table:%v\n", table)
//测试的时候先注释掉这里
//signals.Table.LastUpdated = carbon.Now()
return &table, nil return &table, nil
} }
func readTableData(m *[]*model.Member) error { func readTableData(m *[]*model.Member) error {

View File

@@ -7,7 +7,7 @@ import (
"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" "zsxyww.com/scheduler/templates"
) )
func main() { func main() {
@@ -25,7 +25,7 @@ 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{ renderer := tl.Tlw{
Tl: template.Must(template.ParseGlob("templates/*.html")), Tl: template.Must(template.ParseGlob("templates/*.html")),
} }
app.Renderer = renderer app.Renderer = renderer

View File

@@ -8,7 +8,7 @@ import (
func Route(app *echo.Echo) { func Route(app *echo.Echo) {
// here is the route for our site // here is the route for our site
staticFiles := app.Group("/") staticFiles := app.Group("/*")
staticFiles.Use(middleware.Static("./FrontEnd")) staticFiles.Use(middleware.Static("./FrontEnd"))
api := app.Group("/api/") api := app.Group("/api/")

View File

@@ -7,10 +7,10 @@ import (
) )
// template wrapper // template wrapper
type tlw struct { type Tlw struct {
Tl *template.Template Tl *template.Template
} }
func (t tlw) Render(w io.Writer, name string, data interface{}, c echo.Context) error { func (t Tlw) Render(w io.Writer, name string, data interface{}, c echo.Context) error {
return t.Tl.ExecuteTemplate(w, name, data) return t.Tl.ExecuteTemplate(w, name, data)
} }

View File

@@ -1,12 +1,9 @@
<!DOCTYPE html> <table>
<html lang="zh-CN"> {{range .}} <!-- 遍历外层切片 -->
<head> <tr>
<meta charset="utf-8"> {{range .}} <!-- 遍历内层切片 -->
<title></title> <td>{{.}}</td>
</head> {{end}}
<body> </tr>
<header></header> {{end}}
<main></main> </table>
<footer></footer>
</body>
</html>