mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-19 16:10:12 +01:00
🐛 设置访问授权码后无法导出 PDF https://github.com/siyuan-note/siyuan/issues/5959
This commit is contained in:
parent
4e5a195290
commit
065d88fe17
2 changed files with 33 additions and 0 deletions
|
|
@ -18,7 +18,9 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
|
|
@ -181,6 +183,36 @@ func exportMdHTML(c *gin.Context) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func exportTempContent(c *gin.Context) {
|
||||||
|
ret := gulu.Ret.NewResult()
|
||||||
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
|
arg, ok := util.JsonArg(c, ret)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
content := arg["content"].(string)
|
||||||
|
tmpExport := filepath.Join(util.TempDir, "export")
|
||||||
|
if err := os.MkdirAll(tmpExport, 0755); nil != err {
|
||||||
|
ret.Code = 1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p := filepath.Join(tmpExport, "temp", gulu.Rand.String(7))
|
||||||
|
if err := os.WriteFile(p, []byte(content), 0644); nil != err {
|
||||||
|
ret.Code = 1
|
||||||
|
ret.Msg = err.Error()
|
||||||
|
ret.Data = map[string]interface{}{"closeTimeout": 7000}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
url := path.Join("/export/temp/", filepath.Base(p))
|
||||||
|
ret.Data = map[string]interface{}{
|
||||||
|
"url": url,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func exportPreviewHTML(c *gin.Context) {
|
func exportPreviewHTML(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
||||||
ginServer.Handle("POST", "/api/export/preview", model.CheckAuth, exportPreview)
|
ginServer.Handle("POST", "/api/export/preview", model.CheckAuth, exportPreview)
|
||||||
ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, exportData)
|
ginServer.Handle("POST", "/api/export/exportData", model.CheckAuth, exportData)
|
||||||
ginServer.Handle("POST", "/api/export/exportDataInFolder", model.CheckAuth, exportDataInFolder)
|
ginServer.Handle("POST", "/api/export/exportDataInFolder", model.CheckAuth, exportDataInFolder)
|
||||||
|
ginServer.Handle("POST", "/api/export/exportTempContent", model.CheckAuth, exportTempContent)
|
||||||
|
|
||||||
ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckReadonly, importStdMd)
|
ginServer.Handle("POST", "/api/import/importStdMd", model.CheckAuth, model.CheckReadonly, importStdMd)
|
||||||
ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckReadonly, importData)
|
ginServer.Handle("POST", "/api/import/importData", model.CheckAuth, model.CheckReadonly, importData)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue