完善了值班表模板,现在基本上是可以最基本的使用了,另外增加了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>
<head>
<script src="htmx.min.js"></script>
</head>
<body>
<div>
<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>
</body>
<script src="/htmx.min.js"></script>
</html>

View File

@@ -2,17 +2,17 @@
<body >
<div align=center>
<h1>网维排班系统</h1>
<a href=assignment.html>查看今日值班表</br></a>
<a href=/assignment.html>查看今日值班表</br></a>
<br>
<a href=switch.html>发起换班</br></a>
<a href=repay.html>发起补班</br></a>
<a href=volunteering.html>发起蹭班</br></a>
<a href=/switch.html>发起换班</br></a>
<a href=/repay.html>发起补班</br></a>
<a href=/volunteering.html>发起蹭班</br></a>
</div>
<br>
</br>
<div align=center>
<footer>
<a href=admin.html>管理</br></a>
<a href=/admin.html>管理</br></a>
<i>有任何问题和建议,都可以联系开发组组长:)</i>
</footer>
</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("table:%v\n", table)
//测试的时候先注释掉这里
//signals.Table.LastUpdated = carbon.Now()
return &table, nil
}
func readTableData(m *[]*model.Member) error {

View File

@@ -7,7 +7,7 @@ import (
"zsxyww.com/scheduler/config"
"zsxyww.com/scheduler/database"
"zsxyww.com/scheduler/route"
"zsxyww.com/scheduler/tl"
"zsxyww.com/scheduler/templates"
)
func main() {
@@ -25,7 +25,7 @@ func main() {
func register(app *echo.Echo) {
route.Route(app)
route.Middleware(app)
renderer := tl.tlw{
renderer := tl.Tlw{
Tl: template.Must(template.ParseGlob("templates/*.html")),
}
app.Renderer = renderer

View File

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

View File

@@ -7,10 +7,10 @@ import (
)
// template wrapper
type tlw struct {
type Tlw struct {
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)
}

View File

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