Browse Source

change send files

master
godo 10 months ago
parent
commit
b4c5e8f774
  1. 11
      frontend/src/components/localchat/ChatContent.vue
  2. 8
      frontend/src/stores/localchat.ts
  3. 2
      godo/localchat/filedown.go
  4. 2
      godo/localchat/filemsg.go

11
frontend/src/components/localchat/ChatContent.vue

@ -90,19 +90,14 @@ async function scroll({ scrollTop }: { scrollTop: number }) {
</div>
<div v-if="item.type === 'fileSending'">
<el-card style="max-width: 480px">
<template #header>
<div class="card-header">
<span>对方发送文件</span>
</div>
</template>
<div class="file-content">
<div class="file-content" v-if="item.content.status === 'accessed'">
<div class="file-name" @click="sys.openFile(item.content.path)">查看文件</div>
</div>
<template #footer>
<span v-if="item.content.status === 'apply'">
<el-button @click="store.cannelFile(item)">取消</el-button>
<el-button @click="store.cannelFile(item)">拒绝</el-button>
<el-button type="primary" @click="store.accessFile(item)">
接收
接收文件
</el-button>
</span>
<span v-if="item.content.status === 'cannel'">

8
frontend/src/stores/localchat.ts

@ -431,11 +431,13 @@ export const useLocalChatStore = defineStore('localChatStore', () => {
notifyError("确认失败!")
} else {
const res = await coms.json()
if(res.code === 0){
console.log(res)
if(res.code > -1){
item = toRaw(item)
item.content.path = res.data.path
item.content.status = 'accessed'
//console.log(item)
await db.update('chatmsg', res.data.msg.msgId, toRaw(item))
console.log(item)
await db.update('chatmsg', item.id, item)
await getMsgList()
}else{
notifyError(res.message)

2
godo/localchat/filedown.go

@ -118,7 +118,7 @@ func handleResponse(reader io.Reader, ip string) (string, error) {
}
}
return revPath, nil
return filepath.Join(resPath, timestamp), nil
}
// downloadFile 下载单个文件

2
godo/localchat/filemsg.go

@ -73,7 +73,7 @@ func HandlerAccessFile(w http.ResponseWriter, r *http.Request) {
var msg UdpMessage
decoder := json.NewDecoder(r.Body)
if err := decoder.Decode(&msg); err != nil {
http.Error(w, "Invalid request body", http.StatusBadRequest)
libs.ErrorMsg(w, "Invalid request body")
return
}
defer r.Body.Close()

Loading…
Cancel
Save