From 44c81c72a9304d864589bb2cc6dd1c61a1cdca8b Mon Sep 17 00:00:00 2001 From: taoshihan1991 <630892807@qq.com> Date: Wed, 20 May 2020 19:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F=E5=92=8C=E5=BC=82=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.go | 8 +++- static/html/list.html | 103 ++++++++++++++++++++++++++++++++++++++++++ tmpl/index.go | 64 ++------------------------ 3 files changed, 113 insertions(+), 62 deletions(-) create mode 100644 static/html/list.html diff --git a/server.go b/server.go index 7a3afcc..087b06a 100644 --- a/server.go +++ b/server.go @@ -227,6 +227,13 @@ func folders(w http.ResponseWriter, r *http.Request) { } mailServer:=tools.GetMailServerFromCookie(r) + w.Header().Set("content-type","text/json;charset=utf-8;") + + if mailServer==nil{ + msg, _ := json.Marshal(tools.JsonResult{Code: 400, Msg: "验证失败"}) + w.Write(msg) + return + } var wg sync.WaitGroup wg.Add(2) result :=make(map[string]interface{}) @@ -243,7 +250,6 @@ func folders(w http.ResponseWriter, r *http.Request) { }() wg.Wait() - w.Header().Set("content-type","text/json;charset=utf-8;") msg, _ := json.Marshal(tools.JsonFolders{ JsonResult: tools.JsonResult{Code: 200, Msg: "获取成功"}, Result: result, diff --git a/static/html/list.html b/static/html/list.html new file mode 100644 index 0000000..ca7e843 --- /dev/null +++ b/static/html/list.html @@ -0,0 +1,103 @@ + + + + + + + GO-IMAP网页版邮箱imap工具 + + + + + + + + +
+ +
+ + + diff --git a/tmpl/index.go b/tmpl/index.go index f17d99d..915b399 100644 --- a/tmpl/index.go +++ b/tmpl/index.go @@ -1,71 +1,13 @@ package tmpl import ( + "github.com/taoshihan1991/imaptool/tools" "html/template" "net/http" ) func RenderList(w http.ResponseWriter, render interface{}) { - const html = ` - - - - - - - - - 邮箱IMAP-首页 - - - - - - - -
-
- -
-
- - -
-
- - -` + html:=tools.FileGetContent("html/list.html") t, _ := template.New("list").Parse(html) - t.Execute(w, render) + t.Execute(w,nil) }