diff --git a/server.go b/server.go index bc42a97..d7c8b5f 100644 --- a/server.go +++ b/server.go @@ -29,6 +29,8 @@ func main() { http.HandleFunc("/mail", mail) //详情界面 http.HandleFunc("/view", view) + //写信界面 + http.HandleFunc("/write", write) //监听端口 http.ListenAndServe(":8080", nil) } @@ -103,7 +105,11 @@ func view(w http.ResponseWriter, r *http.Request) { func login(w http.ResponseWriter, r *http.Request) { tmpl.RenderLogin(w, nil) } - +//写信界面 +func write(w http.ResponseWriter, r *http.Request) { + render:=new(tools.ViewHtml) + tmpl.RenderWrite(w, render) +} //验证接口 func check(w http.ResponseWriter, r *http.Request) { email := r.PostFormValue("email") diff --git a/static/html/header.html b/static/html/header.html new file mode 100644 index 0000000..8b8854d --- /dev/null +++ b/static/html/header.html @@ -0,0 +1,49 @@ + + + + + + + GO-IMAP网页版邮箱imap工具 + + + + + + + diff --git a/static/html/list.html b/static/html/list.html index 219ed35..ffcca5b 100644 --- a/static/html/list.html +++ b/static/html/list.html @@ -8,10 +8,8 @@ 收信 - 写信 - - 退出 - + 写信 + 退出 diff --git a/static/html/write.html b/static/html/write.html new file mode 100644 index 0000000..16ae1a6 --- /dev/null +++ b/static/html/write.html @@ -0,0 +1,89 @@ +{{.Header}} + +
+ + +
+ + + diff --git a/tmpl/index.go b/tmpl/index.go index 4c3e987..381ff62 100644 --- a/tmpl/index.go +++ b/tmpl/index.go @@ -13,3 +13,10 @@ func RenderList(w http.ResponseWriter, render interface{}) { render.(*tools.IndexData).Header=template.HTML(header) t.Execute(w, render) } +func RenderWrite(w http.ResponseWriter, render interface{}){ + header := tools.FileGetContent("html/header.html") + html := tools.FileGetContent("html/write.html") + t, _ := template.New("write").Parse(html) + render.(*tools.ViewHtml).Header=template.HTML(header) + t.Execute(w, render) +} diff --git a/tools/types.go b/tools/types.go index 216a3a4..be3a23d 100644 --- a/tools/types.go +++ b/tools/types.go @@ -5,8 +5,11 @@ import "html/template" type MailServer struct { Server, Email, Password string } -type IndexData struct { +type ViewHtml struct{ Header template.HTML +} +type IndexData struct { + ViewHtml Folders map[string]int Mails interface{} MailPagelist []*MailItem