Quellcode durchsuchen

perf:优化导出效果

lifei6671 vor 7 Jahren
Ursprung
Commit
3cd5a46af2
3 geänderte Dateien mit 29 neuen und 22 gelöschten Zeilen
  1. 14 17
      models/BookResult.go
  2. 12 2
      static/css/export.css
  3. 3 3
      views/document/export.tpl

+ 14 - 17
models/BookResult.go

@@ -356,7 +356,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
 		name := strconv.Itoa(item.DocumentId)
 		fpath := filepath.Join(tempOutputPath, name+".html")
 
-		f, err := os.OpenFile(fpath, os.O_CREATE|os.O_RDWR, 0777)
+		f, err := os.OpenFile(fpath, os.O_CREATE|os.O_RDWR, 0755)
 		if err != nil {
 			return convertBookResult, err
 		}
@@ -388,9 +388,6 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
 						beego.Error("复制图片失败 -> ", err, src)
 						return
 					}
-					//if ff, e := ioutil.ReadFile(spath); e == nil {
-					//	encodeString = base64.StdEncoding.EncodeToString(ff)
-					//}
 
 				} else {
 					client := &http.Client{}
@@ -420,15 +417,13 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
 						}
 					}
 				}
-				//if encodeString != "" {
-				//	src = "data:image/" + strings.TrimPrefix(filepath.Ext(src),".") + ";base64," + encodeString
-				//
-				//	contentSelection.SetAttr("src", src)
-				//}
-
 				contentSelection.SetAttr("src", dstSrcString)
 			}
 		})
+		//移除文档底部的更新信息
+		if selection := doc.Find("div.wiki-bottom").First(); selection.Size() > 0 {
+			selection.Remove()
+		}
 
 		html, err = doc.Html()
 		if err != nil {
@@ -448,17 +443,19 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
 	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "editor.md", "css", "editormd.preview.css"), filepath.Join(tempOutputPath, "styles", "editor.md", "css", "editormd.preview.css")); err != nil {
 		beego.Error("复制CSS样式出错 -> static/editor.md/css/editormd.preview.css", err)
 	}
-	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "prettify", "themes", "prettify.css"), filepath.Join(tempOutputPath, "styles", "prettify", "themes", "prettify.css")); err != nil {
-		beego.Error("复制CSS样式出错 -> static/prettify/themes/prettify.css", err)
-	}
+
 	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "css", "markdown.preview.css"), filepath.Join(tempOutputPath, "styles", "css", "markdown.preview.css")); err != nil {
 		beego.Error("复制CSS样式出错 -> static/css/markdown.preview.css", err)
 	}
-	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "highlight", "styles", "vs.css"), filepath.Join(tempOutputPath, "styles", "highlight", "styles", "vs.css")); err != nil {
-		beego.Error("复制CSS样式出错 -> static/highlight/styles/vs.css", err)
+	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static","editor.md","lib", "highlight", "styles", "github.css"), filepath.Join(tempOutputPath, "styles","css", "github.css")); err != nil {
+		beego.Error("复制CSS样式出错 -> static/editor.md/lib/highlight/styles/github.css", err)
+	}
+
+	if err := filetil.CopyDir(filepath.Join(conf.WorkingDirectory,"static","font-awesome"), filepath.Join(tempOutputPath,"styles","font-awesome")); err != nil {
+		beego.Error("复制CSS样式出错 -> static/font-awesome", err)
 	}
-	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "katex", "katex.min.css"), filepath.Join(tempOutputPath, "styles", "katex", "katex.min.css")); err != nil {
-		beego.Error("复制CSS样式出错 -> static/katex/katex.min.css", err)
+	if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static","editor.md","lib","mermaid","mermaid.css"), filepath.Join(tempOutputPath, "styles", "css", "mermaid.css")); err != nil {
+		beego.Error("复制CSS样式出错 -> static/editor.md/lib/mermaid/mermaid.css", err)
 	}
 
 	eBookConverter := &converter.Converter{

+ 12 - 2
static/css/export.css

@@ -9,9 +9,19 @@ body{
 .editormd-preview-container{
     padding: 0 !important;
 }
-
+.markdown-body{
+    -webkit-backface-visibility: inherit !important;
+    backface-visibility: inherit !important;
+}
 .markdown-body pre{
     max-height: none !important;
     white-space: pre-wrap !important;
     word-wrap: break-word !important;
-}
+}
+.markdown-toc{
+    display: none !important;
+    width: 0 !important;
+}
+.article-body .markdown-article{
+    margin-right: 0 !important;
+}

+ 3 - 3
views/document/export.tpl

@@ -7,11 +7,11 @@
     <title>{{.Model.BookName}} - Powered by MinDoc</title>
     <link href="styles/css/kancloud.css" rel="stylesheet">
     <link href="styles/editor.md/css/editormd.preview.css" rel="stylesheet"/>
-    <link href="styles/prettify/themes/prettify.css" rel="stylesheet"/>
     <link href="styles/css/markdown.preview.css" rel="stylesheet"/>
-    <link href="styles/highlight/styles/vs.css" rel="stylesheet"/>
-    <link href="styles/katex/katex.min.css" rel="stylesheet"/>
+    <link href="styles/css/github.css" rel="stylesheet"/>
+    <link href="styles/css/mermaid.css" rel="stylesheet">
     <link href="styles/css/export.css" rel="stylesheet"/>
+    <link href="styles/font-awesome/css/font-awesome.css" />
 </head>
 
 <body>