From c6c9b8ca67c803c0303bc7696f8ca913b99dc2c3 Mon Sep 17 00:00:00 2001 From: xc Date: Tue, 16 Sep 2025 19:38:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8E=8B=E7=BC=A9=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=BE=93=E5=85=A5=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aufs/core/sendzip.go | 35 ++++++++++++++++++++-------- vue/afvue/src/views/Sfilecompare.vue | 18 ++++++++------ 2 files changed, 36 insertions(+), 17 deletions(-) diff --git a/aufs/core/sendzip.go b/aufs/core/sendzip.go index 40fd392..8f6a18b 100644 --- a/aufs/core/sendzip.go +++ b/aufs/core/sendzip.go @@ -3,6 +3,7 @@ package core import ( "aufs/config" "aufs/util" + "encoding/json" "fmt" "net" "net/http" @@ -19,6 +20,13 @@ type ZipBlock struct { SelFile []string // 选中的文件 } +// 返回的结果结构 +type FsResp struct { + Status int `json:"status"` + Message string `json:"message"` + Data map[string]interface{} `json:"data"` +} + // 远程调用压缩包 func SendZip(w http.ResponseWriter, r *http.Request) { r.ParseForm() @@ -40,16 +48,15 @@ func SendZip(w http.ResponseWriter, r *http.Request) { SelFile: zipfarr, } // 从serip 切割出ip 和端口 - // splitip := strings.Split(serip[0], ":") - // if len(splitip) != 2 { - // http.Error(w, "remote server ip is error!", http.StatusInternalServerError) - // return - // } - // srcip := splitip[0] - // sport := splitip[1] + splitip := strings.Split(serip[0], ":") + if len(splitip) != 2 { + http.Error(w, "remote server ip is error!", http.StatusInternalServerError) + return + } + srcip := splitip[0] + sport := splitip[1] // - // service := fmt.Sprintf("%v:%v", srcip, sport) - service := serip[0] + service := fmt.Sprintf("%v:%v", srcip, sport) client, err := jsonrpc.Dial("tcp", service) if err != nil { fmt.Fprintf(w, "jsonrpc dial faild %v", err) @@ -67,7 +74,15 @@ func SendZip(w http.ResponseWriter, r *http.Request) { } // 输出内容 w.Header().Set("Content-Type", "application/json") - w.Write([]byte(reply)) + // w.Write([]byte(reply)) + + // 封装json + resp := FsResp{ + Status: 200, + Message: "success", + Data: map[string]interface{}{"reply": reply}, + } + json.NewEncoder(w).Encode(resp) } // 将文件打包成压缩包 diff --git a/vue/afvue/src/views/Sfilecompare.vue b/vue/afvue/src/views/Sfilecompare.vue index 09cd51a..baeb3cc 100644 --- a/vue/afvue/src/views/Sfilecompare.vue +++ b/vue/afvue/src/views/Sfilecompare.vue @@ -317,19 +317,23 @@ export default { this.selectedFiles.push(rv) } } - let srt = this.selectedFiles.join(',') - console.log(srt,"srt") + // build to string + // let srt = this.selectedFiles.join(',') + // 当前路径 let curpath = this.fspath - // 拼装 - let param ={ + // 提交post请求 + let data = { sfiles: this.selectedFiles, serverip: this.$refs.fsip.value, - curpath: curpath, + curpath: curpath } - // 提交post请求 - SendZipFile(param).then(res=>{ + // build to schema + const pdata = new URLSearchParams(data) + console.log(pdata,"pdata") + // + SendZipFile(pdata).then(res=>{ console.log(res,"res") })