Browse Source

调整压缩文件输入输出

master
xyiege 4 months ago
parent
commit
c6c9b8ca67
  1. 35
      aufs/core/sendzip.go
  2. 18
      vue/afvue/src/views/Sfilecompare.vue

35
aufs/core/sendzip.go

@ -3,6 +3,7 @@ package core
import ( import (
"aufs/config" "aufs/config"
"aufs/util" "aufs/util"
"encoding/json"
"fmt" "fmt"
"net" "net"
"net/http" "net/http"
@ -19,6 +20,13 @@ type ZipBlock struct {
SelFile []string // 选中的文件 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) { func SendZip(w http.ResponseWriter, r *http.Request) {
r.ParseForm() r.ParseForm()
@ -40,16 +48,15 @@ func SendZip(w http.ResponseWriter, r *http.Request) {
SelFile: zipfarr, SelFile: zipfarr,
} }
// 从serip 切割出ip 和端口 // 从serip 切割出ip 和端口
// splitip := strings.Split(serip[0], ":") splitip := strings.Split(serip[0], ":")
// if len(splitip) != 2 { if len(splitip) != 2 {
// http.Error(w, "remote server ip is error!", http.StatusInternalServerError) http.Error(w, "remote server ip is error!", http.StatusInternalServerError)
// return return
// } }
// srcip := splitip[0] srcip := splitip[0]
// sport := splitip[1] sport := splitip[1]
// //
// service := fmt.Sprintf("%v:%v", srcip, sport) service := fmt.Sprintf("%v:%v", srcip, sport)
service := serip[0]
client, err := jsonrpc.Dial("tcp", service) client, err := jsonrpc.Dial("tcp", service)
if err != nil { if err != nil {
fmt.Fprintf(w, "jsonrpc dial faild %v", err) 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.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)
} }
// 将文件打包成压缩包 // 将文件打包成压缩包

18
vue/afvue/src/views/Sfilecompare.vue

@ -317,19 +317,23 @@ export default {
this.selectedFiles.push(rv) this.selectedFiles.push(rv)
} }
} }
let srt = this.selectedFiles.join(',') // build to string
console.log(srt,"srt") // let srt = this.selectedFiles.join(',')
// //
let curpath = this.fspath let curpath = this.fspath
// // post
let param ={ let data = {
sfiles: this.selectedFiles, sfiles: this.selectedFiles,
serverip: this.$refs.fsip.value, serverip: this.$refs.fsip.value,
curpath: curpath, curpath: curpath
} }
// post // build to schema
SendZipFile(param).then(res=>{ const pdata = new URLSearchParams(data)
console.log(pdata,"pdata")
//
SendZipFile(pdata).then(res=>{
console.log(res,"res") console.log(res,"res")
}) })

Loading…
Cancel
Save