新增详情页面

pull/30/head
unknown 5 years ago
parent d829d0db60
commit c58b956a3c

@ -20,6 +20,8 @@ func main() {
http.HandleFunc("/list", list)
//登陆界面
http.HandleFunc("/login", login)
//详情界面
http.HandleFunc("/view", view)
//监听端口
http.ListenAndServe(":8080", nil)
}
@ -115,6 +117,30 @@ func list(w http.ResponseWriter, r *http.Request) {
tmpl.RenderList(w,render)
}
//详情界面
func view(w http.ResponseWriter, r *http.Request) {
values:=r.URL.Query()
fid:=""
if len(values["fid"])!=0{
fid=values["fid"][0]
}else{
fid="INBOX"
}
auth := getCookie(r, "auth")
authStrings := strings.Split(auth, "|")
var wg sync.WaitGroup
var render=new(tools.ViewData)
wg.Add(1)
go func() {
defer wg.Done()
folders :=tools.GetFolders(authStrings[0], authStrings[1], authStrings[2],fid)
render.Folders = folders
render.Fid = fid
}()
wg.Wait()
tmpl.RenderView(w,render)
}
//登陆界面
func login(w http.ResponseWriter, r *http.Request) {
email := r.PostFormValue("email")
@ -139,7 +165,6 @@ func login(w http.ResponseWriter, r *http.Request) {
tmpl.RenderLogin(w,errStr)
}
}
//加密cookie
//func authCookie(){
//

@ -0,0 +1,66 @@
package tmpl
import (
"html/template"
"net/http"
)
func RenderView(w http.ResponseWriter,render interface{}){
const html = `
<!doctype html>
<html lang="cn">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Jekyll v3.8.6">
<title>IMAP-</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<style>
body{
padding: 10px;
}
</style>
</head>
<body>
<div class="row">
<div class="col-md-3">
<ul class="list-group">
<li class="list-group-item active"></li>
{{ range $key, $value := .Folders}}
<li class="list-group-item d-flex justify-content-between align-items-center">
<a href="/list?fid={{$key}}">{{$key}}</a>
{{if ne $value 0 }}<span class="badge badge-primary badge-pill">{{$value}}</span>{{end}}
</li>
{{end}}
</ul>
</div>
<div class="col-md-9">
<table class="table table-hover">
<tbody>
<tr>
<th scope="row">:</th>
<td>Mark</td>
</tr>
<tr>
<th scope="row">:</th>
<td>Mark</td>
</tr>
<tr>
<th scope="row">:</th>
<td>Jacob</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
`
t, _ := template.New("view").Parse(html)
t.Execute(w, render)
}

@ -12,6 +12,10 @@ type IndexData struct {
NumPages template.HTML
}
type ViewData struct {
Folders map[string]int
Fid string
}
type MailItem struct{
Subject string
Id uint32

Loading…
Cancel
Save