From df525ce44a0c95ba4a66523b6028dc09dc36b00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Sun, 31 May 2020 12:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=BB=E4=BF=A1=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller/folder.go | 11 +++++++ server.go | 35 +-------------------- static/html/{view.html => mail_detail.html} | 12 ++----- static/html/nav.html | 2 +- tmpl/detail.go | 15 +++++++++ tmpl/view.go | 16 ---------- tmpl/write.go | 1 - 7 files changed, 31 insertions(+), 61 deletions(-) rename static/html/{view.html => mail_detail.html} (87%) create mode 100644 tmpl/detail.go delete mode 100644 tmpl/view.go delete mode 100644 tmpl/write.go diff --git a/controller/folder.go b/controller/folder.go index 0cf08e7..8acfc4c 100644 --- a/controller/folder.go +++ b/controller/folder.go @@ -31,6 +31,17 @@ func ActionWrite(w http.ResponseWriter, r *http.Request){ render.SetLeft("mail_left") render.Display("write",nil) } +//读信界面 +func ActionDetail(w http.ResponseWriter, r *http.Request){ + fid:=tools.GetUrlArg(r,"fid") + id, _ :=strconv.Atoi(tools.GetUrlArg(r,"id")) + + render:=tmpl.NewDetailHtml(w) + render.SetLeft("mail_left") + render.Fid=fid + render.Id=uint32(id) + render.Display("mail_detail",render) +} //获取邮件夹接口 func FolderDir(w http.ResponseWriter, r *http.Request){ fid:=tools.GetUrlArg(r,"fid") diff --git a/server.go b/server.go index 1cb3fc4..68740ee 100644 --- a/server.go +++ b/server.go @@ -3,7 +3,6 @@ package main import ( "encoding/json" "github.com/taoshihan1991/imaptool/controller" - "github.com/taoshihan1991/imaptool/tmpl" "github.com/taoshihan1991/imaptool/tools" "log" "net/http" @@ -28,7 +27,7 @@ func main() { //邮件接口 http.HandleFunc("/mail", mail) //详情界面 - http.HandleFunc("/view", view) + http.HandleFunc("/view", controller.ActionDetail) //写信界面 http.HandleFunc("/write", controller.ActionWrite) //框架界面 @@ -43,38 +42,6 @@ func main() { http.ListenAndServe(":8080", nil) } -//详情界面 -func view(w http.ResponseWriter, r *http.Request) { - fid:=tools.GetUrlArg(r,"fid") - id, _ :=strconv.Atoi(tools.GetUrlArg(r,"id")) - // - //mailServer:=tools.GetMailServerFromCookie(r) - //var wg sync.WaitGroup - var render = new(tmpl.ViewHtml) - render.Fid = fid - render.Id = uint32(id) - //wg.Add(1) - //go func() { - // defer wg.Done() - // folders := tools.GetFolders(mailServer.Server, mailServer.Email, mailServer.Password, fid) - // render.Folders = folders - // render.Fid = fid - //}() - //wg.Add(1) - //go func() { - // defer wg.Done() - // mail := tools.GetMessage(mailServer.Server, mailServer.Email, mailServer.Password, fid, id) - // render.From = mail.From - // render.To = mail.To - // render.Subject = mail.Subject - // render.Date = mail.Date - // render.HtmlBody = template.HTML(mail.Body) - //}() - //wg.Wait() - tmpl.RenderView(w, render) -} - - //邮件接口 func mail(w http.ResponseWriter, r *http.Request) { fid:=tools.GetUrlArg(r,"fid") diff --git a/static/html/view.html b/static/html/mail_detail.html similarity index 87% rename from static/html/view.html rename to static/html/mail_detail.html index 260a2ea..c4b7535 100644 --- a/static/html/view.html +++ b/static/html/mail_detail.html @@ -4,13 +4,7 @@