5454 `
5555)
5656
57- //DocumentController struct.
57+ // DocumentController struct.
5858type DocumentController struct {
5959 BaseController
6060}
@@ -93,7 +93,7 @@ func parseGitCommit(str string) (cont, commit string) {
9393 return
9494}
9595
96- //判断用户是否可以阅读文档.
96+ // 判断用户是否可以阅读文档.
9797func isReadable (identify , token string , this * DocumentController ) * models.BookResult {
9898 book , err := models .NewBook ().FindByFieldFirst ("identify" , identify )
9999 if err != nil {
@@ -153,7 +153,7 @@ func isReadable(identify, token string, this *DocumentController) *models.BookRe
153153 return bookResult
154154}
155155
156- //文档首页.
156+ // 文档首页.
157157func (this * DocumentController ) Index () {
158158 identify := this .Ctx .Input .Param (":key" )
159159 if identify == "" {
@@ -210,7 +210,7 @@ func (this *DocumentController) Index() {
210210 this .Data ["RelateBooks" ] = models .NewRelateBook ().Lists (bookResult .BookId )
211211}
212212
213- //文档首页.
213+ // 文档首页.
214214func (this * DocumentController ) indexWithPassword () {
215215 identify := this .Ctx .Input .Param (":key" )
216216 if identify == "" {
@@ -226,7 +226,7 @@ func (this *DocumentController) indexWithPassword() {
226226 this .Data ["Identify" ] = identify
227227}
228228
229- //阅读文档.
229+ // 阅读文档.
230230func (this * DocumentController ) Read () {
231231
232232 identify := this .Ctx .Input .Param (":key" )
@@ -477,6 +477,7 @@ func (this *DocumentController) Read() {
477477 if wd := this .GetString ("wd" ); strings .TrimSpace (wd ) != "" {
478478 this .Data ["Keywords" ] = models .NewElasticSearchClient ().SegWords (wd )
479479 }
480+ this .Data ["IsThemeDark" ] = this .Ctx .GetCookie ("theme-dark" ) == "true"
480481 this .Data ["Bookmark" ] = existBookmark
481482 this .Data ["Model" ] = bookResult
482483 this .Data ["Book" ] = bookResult //文档下载需要用到Book变量
@@ -492,7 +493,7 @@ func (this *DocumentController) Read() {
492493 this .Data ["Percent" ] = percent
493494}
494495
495- //编辑文档.
496+ // 编辑文档.
496497func (this * DocumentController ) Edit () {
497498 docId := 0 // 文档id
498499
@@ -563,7 +564,7 @@ func (this *DocumentController) Edit() {
563564 }
564565}
565566
566- //创建一个文档.
567+ // 创建一个文档.
567568func (this * DocumentController ) Create () {
568569 identify := this .GetString ("identify" ) //书籍书籍标识
569570 docIdentify := this .GetString ("doc_identify" ) //新建的文档标识
@@ -663,7 +664,7 @@ func (this *DocumentController) Create() {
663664 this .JsonResult (0 , "ok" , document )
664665}
665666
666- //批量创建文档
667+ // 批量创建文档
667668func (this * DocumentController ) CreateMulti () {
668669 bookId , _ := this .GetInt ("book_id" )
669670
@@ -708,7 +709,7 @@ func (this *DocumentController) CreateMulti() {
708709 this .JsonResult (0 , "添加成功" )
709710}
710711
711- //上传附件或图片.
712+ // 上传附件或图片.
712713func (this * DocumentController ) Upload () {
713714 identify := this .GetString ("identify" )
714715 docId , _ := this .GetInt ("doc_id" )
@@ -866,7 +867,7 @@ func (this *DocumentController) Upload() {
866867 this .StopRun ()
867868}
868869
869- //DownloadAttachment 下载附件.
870+ // DownloadAttachment 下载附件.
870871func (this * DocumentController ) DownloadAttachment () {
871872 identify := this .Ctx .Input .Param (":key" )
872873 attachId , _ := strconv .Atoi (this .Ctx .Input .Param (":attach_id" ))
@@ -919,7 +920,7 @@ func (this *DocumentController) DownloadAttachment() {
919920 this .StopRun ()
920921}
921922
922- //删除附件.
923+ // 删除附件.
923924func (this * DocumentController ) RemoveAttachment () {
924925 attachId , _ := this .GetInt ("attach_id" )
925926 if attachId <= 0 {
@@ -958,7 +959,7 @@ func (this *DocumentController) RemoveAttachment() {
958959 this .JsonResult (0 , "ok" , attach )
959960}
960961
961- //删除文档.
962+ // 删除文档.
962963func (this * DocumentController ) Delete () {
963964
964965 identify := this .GetString ("identify" )
@@ -1222,7 +1223,7 @@ func (this *DocumentController) Content() {
12221223
12231224}
12241225
1225- //导出文件
1226+ // 导出文件
12261227func (this * DocumentController ) ExportOld () {
12271228 wecode := strings .TrimSpace (this .GetString ("wecode" ))
12281229 if wecode == "" && (this .Member == nil || this .Member .MemberId == 0 ) {
@@ -1286,7 +1287,7 @@ func (this *DocumentController) ExportOld() {
12861287 this .JsonResult (1 , "下载失败,您要下载的书籍当前并未生成可下载的电子书。" )
12871288}
12881289
1289- //导出文件
1290+ // 导出文件
12901291func (this * DocumentController ) Export () {
12911292 wecode := strings .TrimSpace (this .GetString ("wecode" ))
12921293 if wecode == "" && (this .Member == nil || this .Member .MemberId == 0 ) {
@@ -1389,7 +1390,7 @@ func (this *DocumentController) QrCode() {
13891390 }
13901391}
13911392
1392- //书籍内搜索.
1393+ // 书籍内搜索.
13931394func (this * DocumentController ) Search () {
13941395 identify := this .Ctx .Input .Param (":key" )
13951396 token := this .GetString ("token" )
@@ -1443,7 +1444,7 @@ func (this *DocumentController) Search() {
14431444 }
14441445}
14451446
1446- //文档历史列表.
1447+ // 文档历史列表.
14471448func (this * DocumentController ) History () {
14481449
14491450 this .TplName = "document/history.html"
@@ -1667,7 +1668,7 @@ func (this *DocumentController) Compare() {
16671668 this .Data ["Content" ] = ModelStore .GetFiledById (doc .DocumentId , "markdown" )
16681669}
16691670
1670- //递归生成文档序列数组.
1671+ // 递归生成文档序列数组.
16711672func RecursiveFun (parentId int , prefix , dpath string , this * DocumentController , book * models.BookResult , docs []* models.Document , paths * list.List ) {
16721673 for _ , item := range docs {
16731674 if item .ParentId == parentId {
0 commit comments