mirror of https://github.com/mindoc-org/mindoc.git
Merge pull request #681 from LawyZheng/master
Fix Bug: Fail to count times when cache is enabled.pull/712/head
commit
faf980907a
|
@ -7,8 +7,8 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/beego/beego/v2/core/logs"
|
|
||||||
"github.com/beego/beego/v2/client/cache"
|
"github.com/beego/beego/v2/client/cache"
|
||||||
|
"github.com/beego/beego/v2/core/logs"
|
||||||
)
|
)
|
||||||
|
|
||||||
var bm cache.Cache
|
var bm cache.Cache
|
||||||
|
|
|
@ -145,21 +145,22 @@ func (c *DocumentController) Read() {
|
||||||
}
|
}
|
||||||
|
|
||||||
doc.IncrViewCount(doc.DocumentId)
|
doc.IncrViewCount(doc.DocumentId)
|
||||||
c.Data["ViewCount"] = doc.ViewCount + 1
|
doc.ViewCount = doc.ViewCount + 1
|
||||||
|
doc.PutToCache()
|
||||||
|
|
||||||
if c.IsAjax() {
|
if c.IsAjax() {
|
||||||
var data struct {
|
var data struct {
|
||||||
DocTitle string `json:"doc_title"`
|
DocTitle string `json:"doc_title"`
|
||||||
Body string `json:"body"`
|
Body string `json:"body"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Version int64 `json:"version"`
|
Version int64 `json:"version"`
|
||||||
ViewCount int `json:"view_count"`
|
ViewCount int `json:"view_count"`
|
||||||
}
|
}
|
||||||
data.DocTitle = doc.DocumentName
|
data.DocTitle = doc.DocumentName
|
||||||
data.Body = doc.Release
|
data.Body = doc.Release
|
||||||
data.Title = doc.DocumentName + " - Powered by MinDoc"
|
data.Title = doc.DocumentName + " - Powered by MinDoc"
|
||||||
data.Version = doc.Version
|
data.Version = doc.Version
|
||||||
data.ViewCount = doc.ViewCount + 1
|
data.ViewCount = doc.ViewCount
|
||||||
|
|
||||||
c.JsonResult(0, "ok", data)
|
c.JsonResult(0, "ok", data)
|
||||||
}
|
}
|
||||||
|
@ -178,6 +179,7 @@ func (c *DocumentController) Read() {
|
||||||
c.Data["Result"] = template.HTML(tree)
|
c.Data["Result"] = template.HTML(tree)
|
||||||
c.Data["Title"] = doc.DocumentName
|
c.Data["Title"] = doc.DocumentName
|
||||||
c.Data["Content"] = template.HTML(doc.Release)
|
c.Data["Content"] = template.HTML(doc.Release)
|
||||||
|
c.Data["ViewCount"] = doc.ViewCount
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑文档
|
// 编辑文档
|
||||||
|
|
|
@ -335,7 +335,7 @@ func (item *Document) Processor() *Document {
|
||||||
selector.First().AppendHtml(release)
|
selector.First().AppendHtml(release)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cdnimg,_ := web.AppConfig.String("cdnimg")
|
cdnimg, _ := web.AppConfig.String("cdnimg")
|
||||||
|
|
||||||
docQuery.Find("img").Each(func(i int, selection *goquery.Selection) {
|
docQuery.Find("img").Each(func(i int, selection *goquery.Selection) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue