Skip to content

Commit

Permalink
临时解决阅读页面js报错'menuSetting undefined'
Browse files Browse the repository at this point in the history
  • Loading branch information
gsw945 authored and Go-Go-Farther committed Jun 6, 2023
1 parent e6998f8 commit 745c16b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 20 deletions.
11 changes: 9 additions & 2 deletions controllers/DocumentController.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func (c *DocumentController) Index() {
selected = doc.DocumentId
c.Data["Title"] = doc.DocumentName
c.Data["Content"] = template.HTML(doc.Release)

c.Data["Description"] = utils.AutoSummary(doc.Release, 120)
c.Data["FoldSetting"] = "first"

if bookResult.IsDisplayComment {
// 获取评论、分页
Expand All @@ -78,6 +78,7 @@ func (c *DocumentController) Index() {
} else {
c.Data["Title"] = i18n.Tr(c.Lang, "blog.summary")
c.Data["Content"] = template.HTML(blackfriday.Run([]byte(bookResult.Description)))
c.Data["FoldSetting"] = "closed"
}

tree, err := models.NewDocument().CreateDocumentTreeForHtml(bookResult.BookId, selected)
Expand Down Expand Up @@ -230,6 +231,12 @@ func (c *DocumentController) Read() {
c.Data["Title"] = doc.DocumentName
c.Data["Content"] = template.HTML(doc.Release)
c.Data["ViewCount"] = doc.ViewCount
c.Data["FoldSetting"] = "closed"
if doc.IsOpen == 1 {
c.Data["FoldSetting"] = "open"
} else if doc.IsOpen == 2 {
c.Data["FoldSetting"] = "empty"
}
}

// 编辑文档
Expand Down Expand Up @@ -1148,7 +1155,7 @@ func (c *DocumentController) DeleteHistory() {
c.JsonResult(0, "ok")
}

//通过文档历史恢复文档
// 通过文档历史恢复文档
func (c *DocumentController) RestoreHistory() {
c.Prepare()

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/go-ldap/ldap/v3 v3.4.4
github.com/howeyc/fsnotify v0.9.0
github.com/kardianos/service v1.2.1
github.com/lib/pq v1.10.5
github.com/lifei6671/gocaptcha v0.2.0
github.com/mattn/go-runewidth v0.0.13
github.com/mattn/go-sqlite3 v1.14.15
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/lib/pq v1.10.5 h1:J+gdV2cUmX7ZqL2B0lFcW0m+egaHC2V3lpO8nWxyYiQ=
github.com/lib/pq v1.10.5/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lifei6671/gocaptcha v0.2.0 h1:CwMjGitq5MsYtWODQhlphdl7WhDdD243y1O2d3l8yFU=
github.com/lifei6671/gocaptcha v0.2.0/go.mod h1:mcUWn1eB+kHOBHLQdmWAQ83bhEGrFTnGMqRCY7sFgUc=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
Expand Down
36 changes: 18 additions & 18 deletions views/document/default_read.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -315,39 +315,39 @@ $(function () {
});
window.menuControl = true;
// window.menuSetting = "open" ;
if (menuSetting == 'open' || menuSetting == 'first') {
window.foldSetting = '{{.FoldSetting}}';
if (foldSetting == 'open' || foldSetting == 'first') {
$('#handlerMenuShow').find('span').text('{{i18n .Lang "doc.fold"}}');
$('#handlerMenuShow').find('i').attr("class","fa fa-angle-down");
if (menuSetting == 'open') {
window.jsTree.jstree().open_all()
if (foldSetting == 'open') {
window.jsTree.jstree().open_all();
}
if (menuSetting == 'first') {
window.jsTree.jstree('close_all')
if (foldSetting == 'first') {
window.jsTree.jstree('close_all');
var $target = $('.jstree-container-ul').children('li').filter(function(index){
if($(this).attr('aria-expanded')==false||$(this).attr('aria-expanded')){
return $(this)
return $(this);
}else{
delete $(this)
delete $(this);
}
})
$target.children('i').trigger('click')
});
$target.children('i').trigger('click');
}
} else {
menuControl = false;
window.jsTree.jstree('close_all')
window.jsTree.jstree('close_all');
}
$('#handlerMenuShow').on('click', function(){
if(menuControl){
$(this).find('span').text('{{i18n .Lang "doc.expand"}}')
$(this).find('i').attr("class","fa fa-angle-left")
window.menuControl = false
window.jsTree.jstree('close_all')
$(this).find('span').text('{{i18n .Lang "doc.expand"}}');
$(this).find('i').attr("class","fa fa-angle-left");
window.menuControl = false;
window.jsTree.jstree('close_all');
}else{
window.menuControl = true
$(this).find('span').text('{{i18n .Lang "doc.fold"}}')
$(this).find('i').attr("class","fa fa-angle-down")
window.jsTree.jstree().open_all()
$(this).find('span').text('{{i18n .Lang "doc.fold"}}');
$(this).find('i').attr("class","fa fa-angle-down");
window.jsTree.jstree().open_all();
}
});
Expand Down

0 comments on commit 745c16b

Please sign in to comment.