优化读信页

pull/30/head
陶士涵 5 years ago
parent 821c7c7eaa
commit df525ce44a

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

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

@ -4,13 +4,7 @@
<template>
<el-container v-loading.fullscreen.lock="fullscreenLoading">
<el-aside>
<el-menu
:default-active="fid">
<el-menu-item :index="v" v-for="(f,v) in folderlist.folders" v-bind:key="v" v-on:click="openUrl('/list?fid='+v)">
<i class="el-icon-menu"></i>
<span slot="title"><{v}></span>
</el-menu-item>
</el-menu>
{{.Left}}
</el-aside>
<el-main class="mainMain">
@ -65,7 +59,7 @@
delimiters:["<{","}>"],
data: {
fullscreenLoading:true,
folderlist:[],
folders:[],
mailTotal:0,
fid:"INBOX",
from:"",
@ -88,7 +82,7 @@
}
let _this = this;
$.get('/mail',data, function (rs) {
_this.folderlist=rs.result;
_this.folders=rs.result.folders;
_this.fid=rs.result.fid;
_this.mailTotal=rs.result.total;
_this.from=rs.result.from;

@ -5,5 +5,5 @@
<el-menu-item index="2" v-on:click="openIframeUrl('/list')">邮箱<el-badge class="mark" :value="mailTotal" style="margin-bottom: 20px;"/>
</el-menu-item>
<el-menu-item index="4" v-on:click="openIframeUrl('/setting')">设置</el-menu-item>
<el-menu-item index="10" v-on:click="openIframeUrl('/logout')">退出</el-menu-item>
<el-menu-item index="10" v-on:click="openIframeUrl('/login')">退出</el-menu-item>
</el-menu>

@ -0,0 +1,15 @@
package tmpl
import "net/http"
type DetailHtml struct {
*CommonHtml
Fid string
Id uint32
}
func NewDetailHtml(w http.ResponseWriter)*DetailHtml{
obj:=new(DetailHtml)
parent:=NewRender(w)
obj.CommonHtml=parent
return obj
}

@ -1,16 +0,0 @@
package tmpl
import (
"net/http"
)
type ViewHtml struct{
CommonHtml
Fid string
Id uint32
}
func RenderView(w http.ResponseWriter, data interface{}) {
render:=NewRender(w)
data.(*ViewHtml).Nav=render.Nav
data.(*ViewHtml).Header=render.Header
render.Display("view",data)
}

@ -1 +0,0 @@
package tmpl
Loading…
Cancel
Save