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 @@