Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e8774ab643
4 changed files with 55 additions and 1 deletions
|
@ -16,7 +16,7 @@ export const exportAsset = (src: string) => {
|
|||
properties: ["showOverwriteConfirmation"],
|
||||
}).then((result: SaveDialogReturnValue) => {
|
||||
if (!result.canceled) {
|
||||
fetchPost("/api/file/saveAs", {src, targe: result.filePath})
|
||||
fetchPost("/api/file/copyFile", {src, dest: result.filePath})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -37,6 +37,14 @@ export class Preview {
|
|||
previewElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
|
||||
if (event.target.tagName === "A") {
|
||||
const linkAddress = event.target.getAttribute("href");
|
||||
if (linkAddress.startsWith("#")) {
|
||||
// 导出预览模式点击块引转换后的脚注跳转不正确 https://github.com/siyuan-note/siyuan/issues/5700
|
||||
// 对于超链接锚点不做任何处理
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return
|
||||
}
|
||||
|
||||
if (isMobile()) {
|
||||
openByMobile(linkAddress);
|
||||
event.stopPropagation();
|
||||
|
|
|
@ -34,6 +34,51 @@ import (
|
|||
"github.com/siyuan-note/siyuan/kernel/util"
|
||||
)
|
||||
|
||||
func copyFile(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
defer c.JSON(http.StatusOK, ret)
|
||||
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
src := arg["src"].(string)
|
||||
src, err := model.GetAssetAbsPath(src)
|
||||
if nil != err {
|
||||
logging.LogErrorf("get asset [%s] abs path failed: %s", src, err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
|
||||
info, err := os.Stat(src)
|
||||
if nil != err {
|
||||
logging.LogErrorf("stat [%s] failed: %s", src, err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
ret.Code = -1
|
||||
ret.Msg = "file is a directory"
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
|
||||
dest := arg["dest"].(string)
|
||||
if err = gulu.File.CopyFile(src, dest); nil != err {
|
||||
logging.LogErrorf("copy file [%s] to [%s] failed: %s", src, dest, err)
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
ret.Data = map[string]interface{}{"closeTimeout": 5000}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func getFile(c *gin.Context) {
|
||||
ret := gulu.Ret.NewResult()
|
||||
arg, ok := util.JsonArg(c, ret)
|
||||
|
|
|
@ -147,6 +147,7 @@ func ServeAPI(ginServer *gin.Engine) {
|
|||
|
||||
ginServer.Handle("POST", "/api/file/getFile", model.CheckAuth, getFile)
|
||||
ginServer.Handle("POST", "/api/file/putFile", model.CheckAuth, putFile)
|
||||
ginServer.Handle("POST", "/api/file/copyFile", model.CheckAuth, copyFile)
|
||||
|
||||
ginServer.Handle("POST", "/api/ref/refreshBacklink", model.CheckAuth, refreshBacklink)
|
||||
ginServer.Handle("POST", "/api/ref/getBacklink", model.CheckAuth, getBacklink)
|
||||
|
|
Loading…
Add table
Reference in a new issue