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 (
"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)
}
// 将文件打包成压缩包

18
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")
})

Loading…
Cancel
Save