优化主界面的样式和异步

pull/30/head
taoshihan1991 5 years ago
parent 774f567511
commit 44c81c72a9

@ -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,

@ -0,0 +1,103 @@
<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 {
padding-bottom: 40px;
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;
}
</style>
</head>
<body class="text-center">
<div id="app" style="width:100%">
<template>
<el-menu
default-active="2"
mode="horizontal">
<el-menu-item index="1" class="mainLogo">GO-IMAP</el-menu-item>
<el-menu-item index="2">收信</el-menu-item>
<el-menu-item index="3">写信</el-menu-item>
<el-header style="text-align: right; font-size: 12px" class="logout">
<a href="/logout">退出</a>
</el-header>
</el-menu>
<el-container v-loading.fullscreen.lock="fullscreenLoading">
<el-aside>
<el-menu
default-active="1">
<el-menu-item index="1" v-on:click="" v-for="(f,v) in folderlist.folders" v-bind:key="v">
<i class="el-icon-menu"></i>
<span slot="title"><{v}></span>
</el-menu-item>
</el-menu>
</el-aside>
<el-main class="mainMain">
<div class="block">
<el-timeline>
<el-timeline-item v-for="item in folderlist.mails" v-bind:key="item.Id" timestamp="2018/4/12" placement="top">
<el-card>
<h4><{item.Subject}></h4>
<p>王小虎 提交于 2018/4/12 20:46</p>
</el-card>
</el-timeline-item>
</el-timeline>
</div>
</el-main>
</el-container>
</template>
</div>
</body>
<script>
new Vue({
el: '#app',
delimiters:["<{","}>"],
data: {
fullscreenLoading:true,
folderlist:[],
},
methods: {
//提交表单
getFolders: function () {
let _this = this;
$.get('/folders', function (rs) {
_this.folderlist=rs.result;
}).then(()=>{
_this.fullscreenLoading=false;
});
},
},
created: function () {
this.getFolders();
}
})
</script>
</html>

@ -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 = `
<!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">
<ul class="list-group">
<li class="list-group-item active">[{{.Fid}}]</li>
{{ range .MailPagelist}}
<li class="list-group-item d-flex justify-content-between align-items-center">
<a href="/view?fid={{.Fid}}&id={{.Id}}">
{{.Subject}}{{if eq .Subject "" }}{{end}}
</a>
</li>
{{end}}
</ul>
<nav aria-label="..." style="margin:20px 0;">
<ul class="pagination">
<li class="page-item">
<a class="page-link" href="{{.PrePage}}">Previous</a>
</li>
{{.NumPages}}
<li class="page-item">
<a class="page-link" href="{{.NextPage}}">Next</a>
</li>
</ul>
</nav>
</div>
</div>
</body>
</html>
`
html:=tools.FileGetContent("html/list.html")
t, _ := template.New("list").Parse(html)
t.Execute(w, render)
t.Execute(w,nil)
}

Loading…
Cancel
Save