优化代码提取公共头

pull/30/head
陶士涵 5 years ago
parent 4f7d80241a
commit 47fe88969c

@ -54,15 +54,8 @@ func index(w http.ResponseWriter, r *http.Request) {
//输出列表
func list(w http.ResponseWriter, r *http.Request) {
values := r.URL.Query()
fid := ""
currentPage := 0
if len(values["fid"]) != 0 {
fid = values["fid"][0]
}
if len(values["page"]) != 0 {
currentPage, _ = strconv.Atoi(values["page"][0])
}
fid:=tools.GetUrlArg(r,"fid")
currentPage, _ :=strconv.Atoi(tools.GetUrlArg(r,"page"))
if fid == "" {
fid = "INBOX"
}
@ -77,26 +70,14 @@ func list(w http.ResponseWriter, r *http.Request) {
//详情界面
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"
}
var id uint32
if len(values["id"]) != 0 {
i, _ := strconv.Atoi(values["id"][0])
id = uint32(i)
} else {
id = 0
}
fid:=tools.GetUrlArg(r,"fid")
id, _ :=strconv.Atoi(tools.GetUrlArg(r,"id"))
//
//mailServer:=tools.GetMailServerFromCookie(r)
//var wg sync.WaitGroup
var render = new(tools.ViewData)
render.Fid = fid
render.Id = id
render.Id = uint32(id)
//wg.Add(1)
//go func() {
// defer wg.Done()

@ -1,52 +1,4 @@
<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="陶士涵">
<title>GO-IMAP网页版邮箱imap工具</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/theme-chalk/index.css">
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.13.1/lib/index.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js"></script>
<style>
html,
body {
height: 100%;
padding: 0;
margin: 0;
}
body {
overflow: hidden;
background-color: #f5f5f5;
}
.el-container{
margin-top:10px;
height: 100%;
}
.el-aside{
height: 100%;
background: #fff;
border: solid 1px #e6e6e6;
}
.el-aside .el-menu{
border-right: none;
}
.mainLogo{
font-size: 20px;
font-weight: bold;
}
.mainMain{
background: #fff;
margin-left: 10px;
margin-bottom: 60px;
}
.el-card__body{
cursor: pointer;
}
</style>
</head>
{{.Header}}
<body class="text-center">
<div id="app" style="width:100%">
<template>

@ -7,7 +7,9 @@ import (
)
func RenderList(w http.ResponseWriter, render interface{}) {
header := tools.FileGetContent("html/header.html")
html := tools.FileGetContent("html/list.html")
t, _ := template.New("list").Parse(html)
render.(*tools.IndexData).Header=template.HTML(header)
t.Execute(w, render)
}

@ -6,6 +6,7 @@ type MailServer struct {
Server, Email, Password string
}
type IndexData struct {
Header template.HTML
Folders map[string]int
Mails interface{}
MailPagelist []*MailItem

Loading…
Cancel
Save