diff --git a/commands/command.go b/commands/command.go index 63a01a2a..b22396c7 100644 --- a/commands/command.go +++ b/commands/command.go @@ -143,6 +143,11 @@ func RegisterModel() { gob.Register(models.Document{}) gob.Register(models.Template{}) //migrate.RegisterMigration() + err := orm.RunSyncdb("default", false, true) + if err != nil { + logs.Error("注册Model失败 ->", err) + os.Exit(1) + } } // RegisterLogger 注册日志 diff --git a/conf/lang/en-us.ini b/conf/lang/en-us.ini index 04d9da11..fcd9a765 100644 --- a/conf/lang/en-us.ini +++ b/conf/lang/en-us.ini @@ -318,6 +318,7 @@ next = next no = no edit_title = Edit Blog private_blog_tips = Private blog, please enter password to access +print_text = Enable Printing [doc] modify_doc = Modify Document diff --git a/conf/lang/zh-cn.ini b/conf/lang/zh-cn.ini index 0dd2e254..388fe510 100644 --- a/conf/lang/zh-cn.ini +++ b/conf/lang/zh-cn.ini @@ -318,6 +318,7 @@ next = 下一篇 no = 无 edit_title = 编辑文章 private_blog_tips = 加密文章,请输入密码访问 +print_text = 开启打印 [doc] modify_doc = 修改文档 diff --git a/controllers/BookController.go b/controllers/BookController.go index 095e82fb..f636dd0d 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -122,6 +122,7 @@ func (c *BookController) Setting() { if book.PrivateToken != "" { book.PrivateToken = conf.URLFor("DocumentController.Index", ":key", book.Identify, "token", book.PrivateToken) } + c.Data["Model"] = book } @@ -153,6 +154,7 @@ func (c *BookController) SaveBook() { isUseFirstDocument := strings.TrimSpace(c.GetString("is_use_first_document")) == "on" autoSave := strings.TrimSpace(c.GetString("auto_save")) == "on" itemId, _ := c.GetInt("itemId") + pringState := strings.TrimSpace(c.GetString("print_state")) == "on" if strings.Count(description, "") > 500 { c.JsonResult(6004, i18n.Tr(c.Lang, "message.project_desc_tips")) @@ -211,6 +213,11 @@ func (c *BookController) SaveBook() { } else { book.AutoSave = 0 } + if pringState { + book.PrintSate = 1 + } else { + book.PrintSate = 0 + } if err := book.Update(); err != nil { c.JsonResult(6006, i18n.Tr(c.Lang, "message.failed")) } @@ -456,6 +463,7 @@ func (c *BookController) Create() { description := strings.TrimSpace(c.GetString("description", "")) privatelyOwned, _ := strconv.Atoi(c.GetString("privately_owned")) commentStatus := c.GetString("comment_status") + editor := c.GetString("editor") itemId, _ := c.GetInt("itemId") if bookName == "" { @@ -522,6 +530,7 @@ func (c *BookController) Create() { book.CommentCount = 0 book.PrivatelyOwned = privatelyOwned book.CommentStatus = commentStatus + book.Identify = identify book.DocCount = 0 book.MemberId = c.Member.MemberId @@ -531,8 +540,7 @@ func (c *BookController) Create() { book.IsDownload = 1 book.AutoRelease = 0 book.ItemId = itemId - - book.Editor = "markdown" + book.Editor = editor book.Theme = "default" if err := book.Insert(c.Lang); err != nil { diff --git a/models/BookModel.go b/models/BookModel.go index d46d2ff5..cfe7cfbc 100644 --- a/models/BookModel.go +++ b/models/BookModel.go @@ -82,7 +82,8 @@ type Book struct { //是否使用第一篇文章项目为默认首页,0 否/1 是 IsUseFirstDocument int `orm:"column(is_use_first_document);type(int);default(0);description(是否使用第一篇文章项目为默认首页,0 否/1 是)" json:"is_use_first_document"` //是否开启自动保存:0 否/1 是 - AutoSave int `orm:"column(auto_save);type(tinyint);default(0);description(是否开启自动保存:0 否/1 是)" json:"auto_save"` + AutoSave int `orm:"column(auto_save);type(tinyint);default(0);description(是否开启自动保存:0 否/1 是)" json:"auto_save"` + PrintSate int `orm:"column(print_state);type(tinyint);default(1);description(启用打印:0 否/1 是)" json:"print_state"` } func (book *Book) String() string { diff --git a/models/BookResult.go b/models/BookResult.go index 0ea535bc..de2ada58 100644 --- a/models/BookResult.go +++ b/models/BookResult.go @@ -71,6 +71,7 @@ type BookResult struct { IsDisplayComment bool `json:"is_display_comment"` IsDownload bool `json:"is_download"` AutoSave bool `json:"auto_save"` + PrintState bool `json:"print_state"` Lang string } @@ -213,6 +214,7 @@ func (m *BookResult) ToBookResult(book Book) *BookResult { m.HistoryCount = book.HistoryCount m.IsDownload = book.IsDownload == 0 m.AutoSave = book.AutoSave == 1 + m.PrintState = book.PrintSate == 1 m.ItemId = book.ItemId m.RoleId = conf.BookRoleNoSpecific diff --git a/static/cherry/cherry-markdown.css b/static/cherry/cherry-markdown.css index 88349c05..69be091e 100644 --- a/static/cherry/cherry-markdown.css +++ b/static/cherry/cherry-markdown.css @@ -2656,7 +2656,7 @@ div[data-type=codeBlock] .token.inserted { } .cherry[data-toolbar-theme=dark] .cherry-insert-table-menu-item.active { - background-color: #d7e6fe; + background-color: #4b4b4b; } .cherry-dropdown { @@ -2692,17 +2692,18 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-dropdown { - background: #20304b; + background: #ffffff; } [data-toolbar-theme=dark] .cherry-dropdown .cherry-dropdown-item { background: transparent; - color: #d7e6fe; + color: #4b4b4b; } [data-toolbar-theme=dark] .cherry-dropdown .cherry-dropdown-item:hover { - background: rgba(255, 255, 255, 0.1); - color: #fff; + background: #e4e4e4; + color: #0a001f; + transition: all .3s; } .cherry-toolbar { @@ -2710,7 +2711,7 @@ div[data-type=codeBlock] .token.inserted { display: flex; justify-content: space-between; padding: 0 20px; - height: 48px; + height: 34px; font-size: 16px; line-height: 2.3; flex-basis: 100%; @@ -2720,6 +2721,7 @@ div[data-type=codeBlock] .token.inserted { box-shadow: 0 0 10px rgba(128, 145, 165, 0.2); background: white; overflow: hidden; + align-items: center; } .cherry-toolbar .icon-loading.loading { @@ -2742,25 +2744,25 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-toolbar { - background: #20304b; + background: #ffffff; box-shadow: 0 0 10px rgba(128, 145, 165, 0.2); } [data-toolbar-theme=dark] .cherry-toolbar .cherry-toolbar-button { - color: #d7e6fe; + color: #4b4b4b; background: transparent; } [data-toolbar-theme=dark] .cherry-toolbar .cherry-toolbar-button:hover { - color: #fff; - background: rgba(255, 255, 255, 0.1); + color: #0a001f; + transition: all .3s; + background: #e4e4e4; } .cherry-toolbar .toolbar-left, .cherry-toolbar .toolbar-right { display: flex; align-items: center; - height: 48px; overflow: hidden; } @@ -2935,12 +2937,12 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-bubble { - border-color: #20304b; - background: #20304b; + border-color: #ffffff; + background: #ffffff; } [data-toolbar-theme=dark] .cherry-bubble .cherry-toolbar-button { - color: #d7e6fe; + color: #4b4b4b; background: transparent; } @@ -2950,15 +2952,15 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-bubble .cherry-bubble-top { - border-bottom-color: #20304b; + border-bottom-color: #ffffff; } [data-toolbar-theme=dark] .cherry-bubble .cherry-bubble-bottom { - border-top-color: #20304b; + border-top-color: #ffffff; } [data-toolbar-theme=dark] .cherry-bubble .cherry-toolbar-button:hover { - border-color: #20304b; + border-color: #ffffff; } .cherry-switch-paste .switch-btn--bg { @@ -3012,7 +3014,7 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-switch-paste[data-type=text] .cherry-text-btn { - color: #d7e6fe; + color: #4b4b4b; } [data-toolbar-theme=dark] .cherry-switch-paste[data-type=text] .cherry-md-btn { @@ -3020,7 +3022,7 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-switch-paste[data-type=md] .cherry-md-btn { - color: #d7e6fe; + color: #4b4b4b; } [data-toolbar-theme=dark] .cherry-switch-paste[data-type=md] .cherry-text-btn { @@ -3192,7 +3194,7 @@ div[data-type=codeBlock] .token.inserted { } .cherry-editor .cm-s-default .cm-url { - background: #d7e6fe; + background: #4b4b4b; font-family: "Menlo", "Liberation Mono", "Consolas", "DejaVu Sans Mono", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-size: 0.9em; } @@ -3347,7 +3349,7 @@ div[data-type=codeBlock] .token.inserted { } [data-toolbar-theme=dark] .cherry-color-wrap h3 { - color: #d7e6fe; + color: #4b4b4b; } .cherry-color-wrap .cherry-color-text { @@ -3522,7 +3524,7 @@ div[data-type=codeBlock] .token.inserted { .cherry.theme__dark .cherry-floatmenu .cherry-toolbar-button, .cherry.theme__dark .cherry-bubble .cherry-toolbar-button, .cherry.theme__dark .cherry-sidebar .cherry-toolbar-button { - color: #d7e6fe; + color: #4b4b4b; } .cherry.theme__dark .cherry-toolbar .cherry-toolbar-button:hover, @@ -3547,7 +3549,7 @@ div[data-type=codeBlock] .token.inserted { } .cherry.theme__dark .cherry-dropdown .cherry-dropdown-item { - color: #d7e6fe; + color: #4b4b4b; } .cherry.theme__dark .cherry-dropdown .cherry-dropdown-item:hover { @@ -3561,7 +3563,7 @@ div[data-type=codeBlock] .token.inserted { } .cherry.theme__dark .cherry-dropdown.cherry-color-wrap h3 { - color: #d7e6fe; + color: #4b4b4b; } .cherry.theme__dark .cherry-dropdown.cherry-color-wrap .cherry-color-item { diff --git a/static/cherry/cherry-markdown.js b/static/cherry/cherry-markdown.js index a166a4f8..847d987d 100644 --- a/static/cherry/cherry-markdown.js +++ b/static/cherry/cherry-markdown.js @@ -22792,7 +22792,7 @@ var $lineNum = Math.max(0, lineNum); this.jumpToLine($lineNum, endLine, percent); - Logger.log('滚动预览区域,左侧应scroll to ', $lineNum); + // Logger.log('滚动预览区域,左侧应scroll to ', $lineNum); } /** * @@ -42219,7 +42219,7 @@ { // 生产环境屏蔽 - Logger.log('markdown引擎渲染了:', str); + // Logger.log('markdown引擎渲染了:', str); } } @@ -56924,7 +56924,7 @@ onScroll = function onScroll() { if (_this2.applyingDomChanges) { - Logger.log(new Date(), 'sync scroll locked'); + // Logger.log(new Date(), 'sync scroll locked'); return; } @@ -57253,13 +57253,13 @@ return obj[index].sign; }); var res = myersDiff.doDiff(); - Logger.log(res); + // Logger.log(res); this.$dealWithMyersDiffResult(res, oldHtmlList.list, newHtmlList.list, domContainer); } else if (newHtmlList.list.length && !oldHtmlList.list.length) { var _context8; // 全新增 - Logger.log('add all'); + // Logger.log('add all'); forEach$3(_context8 = newHtmlList.list).call(_context8, function (piece) { domContainer.appendChild(piece.dom); @@ -57268,7 +57268,7 @@ var _context9; // 全删除 - Logger.log('delete all'); + // Logger.log('delete all'); forEach$3(_context9 = oldHtmlList.list).call(_context9, function (piece) { domContainer.removeChild(piece.dom); diff --git a/views/book/index.tpl b/views/book/index.tpl index 9cb1951e..cc4be564 100644 --- a/views/book/index.tpl +++ b/views/book/index.tpl @@ -180,6 +180,25 @@
+ +