Pārlūkot izejas kodu

个人主页

layui
yirenyishi pirms 6 gadiem
vecāks
revīzija
7a87d53999
  1. 26
      controllers/UserController.go
  2. 1
      routers/UserRouter.go
  3. 20
      static/css/u.css
  4. 4
      views/T.me.tpl
  5. 2
      views/uinfo.html
  6. 41
      views/user.html

26
controllers/UserController.go

@ -22,6 +22,28 @@ func (u *UserController) RegistPage() {
u.TplName = "regist.html"
}
func (this *UserController) UserInfo() {
idStr := this.Ctx.Input.Param(":id")
id, _ := strconv.ParseInt(idStr, 10, 64)
user, err := service.GetUser(id)
if err != nil {
this.Redirect("/500", 302)
return
}
size := 15
num, _ := this.GetInt("num")
if num <= 0 {
num = 1
}
flag, _ := this.GetInt("flag")
if page, err := service.MeBlogs(num, size, flag, id); err == nil {
this.Data["Page"] = page
}
this.Data["User"] = user
this.TplName = "user.html"
return
}
func (this *UserController) PersonBlog() {
uid := this.GetSession("userid")
if uid == nil {
@ -164,9 +186,9 @@ func (this *UserController) Edit() {
user.QQ = this.GetString("qqnum")
user.Sex, _ = this.GetInt("catory")
user.DescInfo = this.GetString("mdesc")
if _,err :=service.EditUser(user); err !=nil{
if _, err := service.EditUser(user); err != nil {
this.Data["json"] = models.ReurnError(500, "")
}else{
} else {
this.Data["json"] = models.ReurnSuccess("")
}
this.ServeJSON()

1
routers/UserRouter.go

@ -12,6 +12,7 @@ func init() {
beego.Router("/regist", &controllers.UserController{}, "post:Regist")
beego.Router("/regist", &controllers.UserController{}, "get:RegistPage")
beego.Router("/user/edit", &controllers.UserController{}, "post:Edit")
beego.Router("/u/:id([0-9]+)", &controllers.UserController{}, "get:UserInfo")

20
static/css/u.css

@ -0,0 +1,20 @@
.uinfo {
color: #515a6e;
margin: 5px;
}
.udesc span {
margin-right: 8px;
}
.blog-list {
display: flex;
font-size: 16px;
min-height: 35px;
line-height: 35px;
}
a{
color: #515a6e;
text-decoration: none !important;
}

4
views/T.me.tpl

@ -1,8 +1,8 @@
{{define "memenu"}}
<div class="me-menu">
<div style="height: 50px;line-height: 50px">
<a href=""><img src="/static/img/2.png" alt="头像" class="img-circle"></a>
<a href="" style="margin-left: 15px;font-size: 18px;text-decoration: none">{{.User.NickName}}</a>
<a href="/u/{{.User.Id}}" target="_blank"><img src="/static/img/2.png" alt="头像" class="img-circle"></a>
<a href="/u/{{.User.Id}}" target="_blank" style="margin-left: 15px;font-size: 18px;text-decoration: none">{{.User.NickName}}</a>
</div>
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 6px;"/>
<div style="display: flex;height: 30px;line-height: 30px;">

2
views/uinfo.html

@ -20,7 +20,7 @@
<div class="info-header">
<div style="display: flex">
<p style="flex: 1;color: #888">ID: {{.User.UserName}}</p>
<p><a href="" style="text-decoration: none">个人主页 ></a></p>
<p><a href="/u/{{.User.Id}}" style="text-decoration: none">个人主页 ></a></p>
</div>
<div>
<span>博客 {{.User.BlogCount}}</span>

41
views/user.html

@ -0,0 +1,41 @@
{{template "header"}}
<title>【{{.User.NickName}}】个人主页 - 个人随笔</title>
<link type="text/css" rel="styleSheet" href="/static/css/u.css"/>
</head>
<body>
<div class="root-container">
{{template "nav" .}}
<div style="height: 100%;margin: 50px 10% 0 10%;">
<div style="display: flex" class="uinfo">
<img src="/static/img/2.png" alt="头像" class="img-circle" style="width: 120px;height: 120px">
<div style="flex: 1;margin-left: 20px;">
{{/*<h1>{{.User.NickName}}</h1>*/}}
<h1 style="margin-top: 20px;margin-bottom: 0">码农笔录</h1>
<div style="height: 35px;line-height: 35px;font-size: 14px;">
{{.User.DescInfo}}
</div>
<div class="udesc">
<span>加入 {{.User.Ctime.Format "2006-01-02"}}</span>
<span>文章 {{.User.BlogCount}}</span>
<span>访问 {{.User.BlogBrowes}}</span>
<span>评论 {{.User.BlogComment}}</span>
<span>收藏 {{.User.BlogLike}}</span>
</div>
</div>
</div>
<hr class="fhr" color=#ffeeeeee SIZE=0.1 style="margin: 0">
<div style="color: #515a6e;height: 30px;line-height: 30px;">
<span>排序: </span>
<span style="margin-left: 15px"><a href="" style="color: #515a6e;text-decoration: none">发布时间</a></span>
<span style="margin-left: 8px"><a href="" style="color: #515a6e;text-decoration: none">访问量</a></span>
</div>
{{range .Page.List}}
<div class="blog-list">
<p style="margin: 0;font-size: 16px"><a href="">{{.Title}}</a></p>
</div>
<hr style="height:1px;border:none;border-top:1px solid #EEE;margin: 0"/>
{{end}}
</div>
</div>
</body>
</html>
Notiek ielāde…
Atcelt
Saglabāt