浏览代码

Merge remote-tracking branch 'origin/dev' into dev

Vanessa 1 年之前
父节点
当前提交
37d03ff893

+ 2 - 0
app/changelogs/v2.11.0/v2.11.0.md

@@ -33,6 +33,8 @@ Below are the detailed changes in this version.
 * [Improve data sync conflicts merging](https://github.com/siyuan-note/siyuan/issues/9741)
 * [`Alt+O`, `Alt+B` and `Alt+G` can be used in read-only mode](https://github.com/siyuan-note/siyuan/issues/9745)
 * [Mentions and the last item in the doc tree cannot be clicked when the bottom bar hover window is on](https://github.com/siyuan-note/siyuan/issues/9750)
+* [Make setting window draggable](https://github.com/siyuan-note/siyuan/issues/9752)
+* [Add `Move to New Window` hotkey](https://github.com/siyuan-note/siyuan/issues/9754)
 
 ### Bugfix
 

+ 2 - 0
app/changelogs/v2.11.0/v2.11.0_zh_CHT.md

@@ -33,6 +33,8 @@
 * [改進資料同步衝突合併](https://github.com/siyuan-note/siyuan/issues/9741)
 * [支援在唯讀模式下使用 `Alt+O`, `Alt+B` 和 `Alt+G`](https://github.com/siyuan-note/siyuan/issues/9745)
 * [提及和文檔樹面板最後一項在底部停靠欄懸浮時無法點擊](https://github.com/siyuan-note/siyuan/issues/9750)
+* [設定視窗支援拖曳](https://github.com/siyuan-note/siyuan/issues/9752)
+* [新增 `移動到新視窗` 快捷鍵](https://github.com/siyuan-note/siyuan/issues/9754)
 
 ### 修復缺陷
 

+ 2 - 0
app/changelogs/v2.11.0/v2.11.0_zh_CN.md

@@ -33,6 +33,8 @@
 * [改进数据同步冲突合并](https://github.com/siyuan-note/siyuan/issues/9741)
 * [支持在只读模式下使用 `Alt+O`, `Alt+B` 和 `Alt+G`](https://github.com/siyuan-note/siyuan/issues/9745)
 * [提及和文档树面板最后一项在底部停靠栏悬浮时无法点击](https://github.com/siyuan-note/siyuan/issues/9750)
+* [设置窗口支持拖拽](https://github.com/siyuan-note/siyuan/issues/9752)
+* [添加 `移动到新窗口` 快捷键](https://github.com/siyuan-note/siyuan/issues/9754)
 
 ### 修复缺陷
 

+ 52 - 3
kernel/api/network.go

@@ -24,6 +24,7 @@ import (
 	"io"
 	"math"
 	"net/http"
+	"net/textproto"
 	"net/url"
 	"strings"
 	"time"
@@ -31,19 +32,67 @@ import (
 	"github.com/88250/gulu"
 	"github.com/gin-gonic/gin"
 	"github.com/imroc/req/v3"
+	"github.com/siyuan-note/logging"
 	"github.com/siyuan-note/siyuan/kernel/util"
 )
 
+type File struct {
+	Filename string
+	Header   textproto.MIMEHeader
+	Size     int64
+	Content  string
+}
+
+type MultipartForm struct {
+	Value map[string][]string
+	File  map[string][]File
+}
+
 func echo(c *gin.Context) {
 	ret := gulu.Ret.NewResult()
 	defer c.JSON(http.StatusOK, ret)
 
-	password, passwordSet := c.Request.URL.User.Password()
+	var (
+		password      string
+		passwordSet   bool
+		multipartForm *MultipartForm
+		rawData       any
+	)
+
+	password, passwordSet = c.Request.URL.User.Password()
+
+	if form, err := c.MultipartForm(); nil != err || nil == form {
+		multipartForm = nil
+	} else {
+		multipartForm = &MultipartForm{
+			Value: form.Value,
+			File:  map[string][]File{},
+		}
+		for k, handlers := range form.File {
+			files := make([]File, len(handlers))
+			multipartForm.File[k] = files
+			for i, handler := range handlers {
+				files[i].Filename = handler.Filename
+				files[i].Header = handler.Header
+				files[i].Size = handler.Size
+				if file, err := handler.Open(); nil != err {
+					logging.LogWarnf("echo open form [%s] file [%s] error: %s", k, handler.Filename, err.Error())
+				} else {
+					content := make([]byte, handler.Size)
+					if _, err := file.Read(content); nil != err {
+						logging.LogWarnf("echo read form [%s] file [%s] error: %s", k, handler.Filename, err.Error())
+					} else {
+						files[i].Content = base64.StdEncoding.EncodeToString(content)
+					}
+				}
+			}
+		}
+	}
 
-	var rawData any
 	if data, err := c.GetRawData(); nil == err {
 		rawData = base64.StdEncoding.EncodeToString(data)
 	} else {
+		logging.LogWarnf("echo get raw data error: %s", err.Error())
 		rawData = nil
 	}
 	c.Request.ParseForm()
@@ -73,7 +122,7 @@ func echo(c *gin.Context) {
 			"Host":             c.Request.Host,
 			"Form":             c.Request.Form,
 			"PostForm":         c.Request.PostForm,
-			"MultipartForm":    c.Request.MultipartForm,
+			"MultipartForm":    multipartForm,
 			"Trailer":          c.Request.Trailer,
 			"RemoteAddr":       c.Request.RemoteAddr,
 			"TLS":              c.Request.TLS,