mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-10 01:40:25 +08:00
fix: 前端树形按钮变更为右击显示,后端修复协程panic导致进程退出
This commit is contained in:
@@ -8,10 +8,12 @@ import (
|
||||
"mayfly-go/base/ctx"
|
||||
"mayfly-go/base/ginx"
|
||||
"mayfly-go/base/utils"
|
||||
"mayfly-go/base/ws"
|
||||
"mayfly-go/server/devops/api/form"
|
||||
"mayfly-go/server/devops/api/vo"
|
||||
"mayfly-go/server/devops/application"
|
||||
"mayfly-go/server/devops/domain/entity"
|
||||
sysApplication "mayfly-go/server/sys/application"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -21,6 +23,7 @@ import (
|
||||
type MachineFile struct {
|
||||
MachineFileApp application.MachineFile
|
||||
MachineApp application.Machine
|
||||
MsgApp sysApplication.Msg
|
||||
}
|
||||
|
||||
const (
|
||||
@@ -125,9 +128,24 @@ func (m *MachineFile) UploadFile(rc *ctx.ReqCtx) {
|
||||
|
||||
file, _ := fileheader.Open()
|
||||
bytes, _ := ioutil.ReadAll(file)
|
||||
go m.MachineFileApp.UploadFile(rc.LoginAccount, fid, path, fileheader.Filename, bytes)
|
||||
|
||||
rc.ReqParam = fmt.Sprintf("path: %s", path)
|
||||
|
||||
la := rc.LoginAccount
|
||||
go func() {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
switch t := err.(type) {
|
||||
case *biz.BizError:
|
||||
m.MsgApp.CreateAndSend(la, ws.ErrMsg("文件上传失败", fmt.Sprintf("执行文件上传失败:\n<-e errCode: %d, errMsg: %s", t.Code(), t.Error())))
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
m.MachineFileApp.UploadFile(fid, path, fileheader.Filename, bytes)
|
||||
// 保存消息并发送文件上传成功通知
|
||||
machine := m.MachineApp.GetById(m.MachineFileApp.GetById(fid).MachineId)
|
||||
m.MsgApp.CreateAndSend(la, ws.SuccessMsg("文件上传成功", fmt.Sprintf("[%s]文件已成功上传至 %s[%s:%s]", fileheader.Filename, machine.Name, machine.Ip, path)))
|
||||
}()
|
||||
}
|
||||
|
||||
func (m *MachineFile) RemoveFile(rc *ctx.ReqCtx) {
|
||||
|
||||
Reference in New Issue
Block a user