浏览代码

:art: Support for exporting OPML Fix https://github.com/siyuan-note/siyuan/issues/8131

Liang Ding 2 年之前
父节点
当前提交
af938cc41d
共有 3 个文件被更改,包括 30 次插入1 次删除
  1. 12 1
      app/src/menus/commonMenuItem.ts
  2. 17 0
      kernel/api/export.go
  3. 1 0
      kernel/api/router.go

+ 12 - 1
app/src/menus/commonMenuItem.ts

@@ -656,7 +656,7 @@ export const exportMd = (id: string) => {
                             openByMobile(response.data.zip);
                         });
                     }
-                },{
+                }, {
                     label: "Textile",
                     click: () => {
                         const msgId = showMessage(window.siyuan.languages.exporting, -1);
@@ -667,6 +667,17 @@ export const exportMd = (id: string) => {
                             openByMobile(response.data.zip);
                         });
                     }
+                }, {
+                    label: "OPML",
+                    click: () => {
+                        const msgId = showMessage(window.siyuan.languages.exporting, -1);
+                        fetchPost("/api/export/exportOPML", {
+                            id,
+                        }, response => {
+                            hideMessage(msgId);
+                            openByMobile(response.data.zip);
+                        });
+                    }
                 },
                 ]
             }

+ 17 - 0
kernel/api/export.go

@@ -31,6 +31,23 @@ import (
 	"github.com/siyuan-note/siyuan/kernel/util"
 )
 
+func exportOPML(c *gin.Context) {
+	ret := gulu.Ret.NewResult()
+	defer c.JSON(http.StatusOK, ret)
+
+	arg, ok := util.JsonArg(c, ret)
+	if !ok {
+		return
+	}
+
+	id := arg["id"].(string)
+	name, zipPath := model.ExportPandocConvertZip(id, "opml", ".opml")
+	ret.Data = map[string]interface{}{
+		"name": name,
+		"zip":  zipPath,
+	}
+}
+
 func exportTextile(c *gin.Context) {
 	ret := gulu.Ret.NewResult()
 	defer c.JSON(http.StatusOK, ret)

+ 1 - 0
kernel/api/router.go

@@ -248,6 +248,7 @@ func ServeAPI(ginServer *gin.Engine) {
 	ginServer.Handle("POST", "/api/export/exportReStructuredText", model.CheckAuth, exportReStructuredText)
 	ginServer.Handle("POST", "/api/export/exportAsciiDoc", model.CheckAuth, exportAsciiDoc)
 	ginServer.Handle("POST", "/api/export/exportTextile", model.CheckAuth, exportTextile)
+	ginServer.Handle("POST", "/api/export/exportOPML", model.CheckAuth, exportOPML)
 
 	ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckReadonly, importStdMd)
 	ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckReadonly, importData)