Merge pull request #681 from LawyZheng/master

Fix Bug: Fail to count times when cache is enabled.
pull/712/head
LawyZheng 2021-04-26 09:24:04 +08:00 committed by GitHub
commit faf980907a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 9 deletions

2
cache/cache.go vendored
View File

@ -7,8 +7,8 @@ import (
"errors"
"time"
"github.com/beego/beego/v2/core/logs"
"github.com/beego/beego/v2/client/cache"
"github.com/beego/beego/v2/core/logs"
)
var bm cache.Cache

View File

@ -145,7 +145,8 @@ func (c *DocumentController) Read() {
}
doc.IncrViewCount(doc.DocumentId)
c.Data["ViewCount"] = doc.ViewCount + 1
doc.ViewCount = doc.ViewCount + 1
doc.PutToCache()
if c.IsAjax() {
var data struct {
@ -159,7 +160,7 @@ func (c *DocumentController) Read() {
data.Body = doc.Release
data.Title = doc.DocumentName + " - Powered by MinDoc"
data.Version = doc.Version
data.ViewCount = doc.ViewCount + 1
data.ViewCount = doc.ViewCount
c.JsonResult(0, "ok", data)
}
@ -178,6 +179,7 @@ func (c *DocumentController) Read() {
c.Data["Result"] = template.HTML(tree)
c.Data["Title"] = doc.DocumentName
c.Data["Content"] = template.HTML(doc.Release)
c.Data["ViewCount"] = doc.ViewCount
}
// 编辑文档