From 821c7c7eaa310cf39b55234e606a6f34008fff64 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 11:26:09 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=86=99=E4=BF=A1=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
controller/folder.go | 6 ++++++
server.go | 8 +-------
static/html/mail_left.html | 11 +++++++++++
static/html/write.html | 8 +-------
tmpl/common.go | 3 +++
tmpl/write.go | 8 --------
6 files changed, 22 insertions(+), 22 deletions(-)
create mode 100644 static/html/mail_left.html
diff --git a/controller/folder.go b/controller/folder.go
index 7657c73..0cf08e7 100644
--- a/controller/folder.go
+++ b/controller/folder.go
@@ -25,6 +25,12 @@ func ActionFolder(w http.ResponseWriter, r *http.Request){
render.Fid = fid
tmpl.RenderList(w, render)
}
+//写信界面
+func ActionWrite(w http.ResponseWriter, r *http.Request){
+ render:=tmpl.NewRender(w)
+ render.SetLeft("mail_left")
+ render.Display("write",nil)
+}
//获取邮件夹接口
func FolderDir(w http.ResponseWriter, r *http.Request){
fid:=tools.GetUrlArg(r,"fid")
diff --git a/server.go b/server.go
index 76e291f..1cb3fc4 100644
--- a/server.go
+++ b/server.go
@@ -30,7 +30,7 @@ func main() {
//详情界面
http.HandleFunc("/view", view)
//写信界面
- http.HandleFunc("/write", write)
+ http.HandleFunc("/write", controller.ActionWrite)
//框架界面
http.HandleFunc("/main", controller.ActionMain)
//设置界面
@@ -74,12 +74,6 @@ func view(w http.ResponseWriter, r *http.Request) {
tmpl.RenderView(w, render)
}
-//写信界面
-func write(w http.ResponseWriter, r *http.Request) {
- render:=new(tmpl.CommonHtml)
- tmpl.RenderWrite(w, render)
-}
-
//邮件接口
func mail(w http.ResponseWriter, r *http.Request) {
diff --git a/static/html/mail_left.html b/static/html/mail_left.html
new file mode 100644
index 0000000..7e44a7f
--- /dev/null
+++ b/static/html/mail_left.html
@@ -0,0 +1,11 @@
+
+
+
+ 写信
+
+
+
+ <{v}>
+
+
\ No newline at end of file
diff --git a/static/html/write.html b/static/html/write.html
index 1d1c456..5624354 100644
--- a/static/html/write.html
+++ b/static/html/write.html
@@ -4,13 +4,7 @@
-
-
-
- <{v}>
-
-
+ {{.Left}}
diff --git a/tmpl/common.go b/tmpl/common.go
index c887509..1d2342b 100644
--- a/tmpl/common.go
+++ b/tmpl/common.go
@@ -31,6 +31,9 @@ func (obj *CommonHtml)SetBottom(file string){
obj.Bottom=template.HTML(str)
}
func (obj *CommonHtml)Display(file string,data interface{}){
+ if data==nil{
+ data=obj
+ }
main := tools.FileGetContent("html/"+file+".html")
t, _ := template.New(file).Parse(main)
t.Execute(obj.Rw, data)
diff --git a/tmpl/write.go b/tmpl/write.go
index cce2bb4..e693b3d 100644
--- a/tmpl/write.go
+++ b/tmpl/write.go
@@ -1,9 +1 @@
package tmpl
-
-import (
- "net/http"
-)
-func RenderWrite(w http.ResponseWriter, data interface{}) {
- render:=NewRender(w)
- render.Display("write",render)
-}