From fe42fb13e2071192d7ac5ed527fd6b705b5533ea Mon Sep 17 00:00:00 2001 From: "zhangsheng.93" Date: Mon, 20 Nov 2023 07:41:53 +0000 Subject: [PATCH] fix: the mobile phone displays abnormally and Markdown does not allow conversion --- .github/workflows/build.yml | 2 +- conf/lang/en-us.ini | 3 ++- conf/lang/zh-cn.ini | 1 + controllers/BookController.go | 3 +++ static/css/markdown.css | 15 +++++++++++---- utils/html.go | 6 ++++-- 6 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 45202c0c..8c65dfec 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.20 - name: Build run: | diff --git a/conf/lang/en-us.ini b/conf/lang/en-us.ini index c6a7b715..40ea2147 100644 --- a/conf/lang/en-us.ini +++ b/conf/lang/en-us.ini @@ -224,6 +224,7 @@ project_label_desc = Allows up to 10 labels, use ";" to separate multiple tags cannot_change_own_status = Cannot change own status cannot_change_super_status = Cannot change super administrator status cannot_change_super_priv = Cannot change super administrator permissions +editors_not_compatible = two editors are not compatible [blog] author = Author @@ -571,4 +572,4 @@ create_time = Create Time creator = Creator doc_amount = Number of Document last_edit = Last Edit -delete_project = Delete Project \ No newline at end of file +delete_project = Delete Project diff --git a/conf/lang/zh-cn.ini b/conf/lang/zh-cn.ini index f08944bf..912e7419 100644 --- a/conf/lang/zh-cn.ini +++ b/conf/lang/zh-cn.ini @@ -224,6 +224,7 @@ project_label_desc = 最多允许添加10个标签,多个标签请用“;” cannot_change_own_status = 不能变更自己的状态 cannot_change_super_status = 不能变更超级管理员的状态 cannot_change_super_priv = 不能变更超级管理员的权限 +editors_not_compatible = 两种编辑器不兼容 [blog] author = 作者 diff --git a/controllers/BookController.go b/controllers/BookController.go index 0a4b2860..56a234c7 100644 --- a/controllers/BookController.go +++ b/controllers/BookController.go @@ -173,6 +173,9 @@ func (c *BookController) SaveBook() { book.CommentStatus = commentStatus book.Publisher = publisher //book.Label = tag + if book.Editor == EditorMarkdown && editor == EditorCherryMarkdown || book.Editor == EditorCherryMarkdown && editor == EditorMarkdown { + c.JsonResult(6006, i18n.Tr(c.Lang, "message.editors_not_compatible")) + } book.Editor = editor if editor == EditorCherryMarkdown { book.Theme = "cherry" diff --git a/static/css/markdown.css b/static/css/markdown.css index f2993192..345b0297 100644 --- a/static/css/markdown.css +++ b/static/css/markdown.css @@ -548,12 +548,13 @@ iframe.cherry-dialog-iframe { margin-right: 50px; } -.markdown-article-body { - margin-right: 200px !important; +@media screen and (min-width: 840px) { + .markdown-article { + margin-right: 200px !important; + } } .markdown-article-head { - margin-right: 200px !important; width: unset !important; padding: unset !important; padding-top: 10px !important; @@ -562,4 +563,10 @@ iframe.cherry-dialog-iframe { .markdown-title { padding: unset !important; width: 100% !important; -} \ No newline at end of file +} + +@media screen and (max-width: 839px) { + .toc { + display: none !important; + } +} diff --git a/utils/html.go b/utils/html.go index 18f6fe3b..dc326287 100644 --- a/utils/html.go +++ b/utils/html.go @@ -34,7 +34,7 @@ func StripTags(s string) string { return src } -//自动提取文章摘要 +// 自动提取文章摘要 func AutoSummary(body string, l int) string { //匹配图片,如果图片语法是在代码块中,这里同样会处理 @@ -60,7 +60,7 @@ func AutoSummary(body string, l int) string { return content } -//安全处理HTML文档,过滤危险标签和属性. +// 安全处理HTML文档,过滤危险标签和属性. func SafetyProcessor(html string) string { //安全过滤,移除危险标签和属性 @@ -117,6 +117,8 @@ func SafetyProcessor(html string) string { if selector := docQuery.Find("div.markdown-article").First(); selector.Size() <= 0 { if selector := docQuery.Find("div.markdown-toc").First(); selector.Size() > 0 { docQuery.Find("div.markdown-toc").NextAll().WrapAllHtml("
") + } else if selector := docQuery.Find("dir.toc").First(); selector.Size() > 0 { + docQuery.Find("dir.toc").NextAll().WrapAllHtml("
") } }