diff --git a/mayfly_go_web/src/views/ops/db/DbList.vue b/mayfly_go_web/src/views/ops/db/DbList.vue index f52af841..e0317c19 100644 --- a/mayfly_go_web/src/views/ops/db/DbList.vue +++ b/mayfly_go_web/src/views/ops/db/DbList.vue @@ -81,11 +81,11 @@ @@ -183,15 +183,15 @@ - - + + - - + + @@ -201,14 +201,23 @@ - + -
- 取消 - 确定 -
+
{ const onDumpDbs = async (row: any) => { const dbs = row.database.split(' '); - const data = [] + const data = []; for (let name of dbs) { data.push({ key: name, label: name, - }) + }); } - state.exportDialog.value = [] - state.exportDialog.data = data + state.exportDialog.value = []; + state.exportDialog.data = data; state.exportDialog.dbId = row.id; - state.exportDialog.contents = ["结构", "数据"] - state.exportDialog.extName = "sql" + state.exportDialog.contents = ['结构', '数据']; + state.exportDialog.extName = 'sql'; state.exportDialog.visible = true; }; @@ -679,19 +688,19 @@ const onDumpDbs = async (row: any) => { const dumpDbs = () => { isTrue(state.exportDialog.value.length > 0, '请添加要导出的数据库'); const a = document.createElement('a'); - let type = 0 + let type = 0; for (let c of state.exportDialog.contents) { - if (c == "结构") { - type += 1 - } else if (c == "数据") { - type += 2 + if (c == '结构') { + type += 1; + } else if (c == '数据') { + type += 2; } } a.setAttribute( 'href', - `${config.baseApiUrl}/dbs/${state.exportDialog.dbId}/dump?db=${state.exportDialog.value.join(',')}&type=${type}&extName=${state.exportDialog.extName}&token=${getSession( - 'token' - )}` + `${config.baseApiUrl}/dbs/${state.exportDialog.dbId}/dump?db=${state.exportDialog.value.join(',')}&type=${type}&extName=${ + state.exportDialog.extName + }&token=${getSession('token')}` ); a.click(); state.exportDialog.visible = false; diff --git a/mayfly_go_web/src/views/ops/machine/FileManage.vue b/mayfly_go_web/src/views/ops/machine/FileManage.vue deleted file mode 100755 index fb7ca446..00000000 --- a/mayfly_go_web/src/views/ops/machine/FileManage.vue +++ /dev/null @@ -1,631 +0,0 @@ - - - - diff --git a/mayfly_go_web/src/views/ops/machine/MachineList.vue b/mayfly_go_web/src/views/ops/machine/MachineList.vue index 2ebd0d44..c8da1596 100644 --- a/mayfly_go_web/src/views/ops/machine/MachineList.vue +++ b/mayfly_go_web/src/views/ops/machine/MachineList.vue @@ -150,7 +150,7 @@ - + @@ -173,7 +173,7 @@ import { hasPerms } from '@/components/auth/auth'; const TerminalDialog = defineAsyncComponent(() => import('@/components/terminal/TerminalDialog.vue')); const MachineEdit = defineAsyncComponent(() => import('./MachineEdit.vue')); const ScriptManage = defineAsyncComponent(() => import('./ScriptManage.vue')); -const FileManage = defineAsyncComponent(() => import('./FileManage.vue')); +const FileConfList = defineAsyncComponent(() => import('./file/FileConfList.vue')); const MachineStats = defineAsyncComponent(() => import('./MachineStats.vue')); const MachineRec = defineAsyncComponent(() => import('./MachineRec.vue')); const ProcessList = defineAsyncComponent(() => import('./ProcessList.vue')); diff --git a/mayfly_go_web/src/views/ops/machine/file/FileConfList.vue b/mayfly_go_web/src/views/ops/machine/file/FileConfList.vue new file mode 100755 index 00000000..5e4ae770 --- /dev/null +++ b/mayfly_go_web/src/views/ops/machine/file/FileConfList.vue @@ -0,0 +1,211 @@ + + + + diff --git a/mayfly_go_web/src/views/ops/machine/file/MachineFile.vue b/mayfly_go_web/src/views/ops/machine/file/MachineFile.vue new file mode 100755 index 00000000..4f67ebe8 --- /dev/null +++ b/mayfly_go_web/src/views/ops/machine/file/MachineFile.vue @@ -0,0 +1,478 @@ + + + + diff --git a/mayfly_go_web/src/views/ops/machine/file/MachineFileContent.vue b/mayfly_go_web/src/views/ops/machine/file/MachineFileContent.vue new file mode 100755 index 00000000..bc994e6f --- /dev/null +++ b/mayfly_go_web/src/views/ops/machine/file/MachineFileContent.vue @@ -0,0 +1,107 @@ + + + + diff --git a/server/go.mod b/server/go.mod index 02f67962..9f0f79ba 100644 --- a/server/go.mod +++ b/server/go.mod @@ -23,8 +23,8 @@ require ( github.com/robfig/cron/v3 v3.0.1 // 定时任务 github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2 go.mongodb.org/mongo-driver v1.12.1 // mongo - golang.org/x/crypto v0.12.0 // ssh - golang.org/x/oauth2 v0.11.0 + golang.org/x/crypto v0.13.0 // ssh + golang.org/x/oauth2 v0.12.0 gopkg.in/yaml.v3 v3.0.1 // gorm gorm.io/driver/mysql v1.5.1 @@ -66,10 +66,10 @@ require ( github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect golang.org/x/arch v0.3.0 // indirect golang.org/x/image v0.0.0-20220302094943-723b81ca9867 // indirect - golang.org/x/net v0.14.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/sys v0.12.0 // indirect + golang.org/x/text v0.13.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect diff --git a/server/internal/db/api/db.go b/server/internal/db/api/db.go index 83e2fea6..00f2e794 100644 --- a/server/internal/db/api/db.go +++ b/server/internal/db/api/db.go @@ -94,8 +94,7 @@ func (d *Db) DeleteDb(rc *req.Ctx) { func (d *Db) getDbConnection(g *gin.Context) *application.DbConnection { dbName := g.Query("db") biz.NotEmpty(dbName, "db不能为空") - dbId := getDbId(g) - return d.DbApp.GetDbConnection(dbId, dbName) + return d.DbApp.GetDbConnection(getDbId(g), dbName) } func (d *Db) TableInfos(rc *req.Ctx) { diff --git a/server/internal/machine/api/machine_file.go b/server/internal/machine/api/machine_file.go index de1270ce..7933b441 100644 --- a/server/internal/machine/api/machine_file.go +++ b/server/internal/machine/api/machine_file.go @@ -12,6 +12,7 @@ import ( "mayfly-go/pkg/biz" "mayfly-go/pkg/ginx" "mayfly-go/pkg/req" + "mayfly-go/pkg/utils/timex" "mayfly-go/pkg/ws" "sort" "strconv" @@ -113,11 +114,14 @@ func (m *MachineFile) GetDirEntry(rc *req.Ctx) { fisVO := make([]vo.MachineFileInfo, 0) for _, fi := range fis { fisVO = append(fisVO, vo.MachineFileInfo{ - Name: fi.Name(), - Size: fi.Size(), - Path: readPath + fi.Name(), - Type: getFileType(fi.Mode()), + Name: fi.Name(), + Size: fi.Size(), + Path: readPath + fi.Name(), + Type: getFileType(fi.Mode()), + Mode: fi.Mode().String(), + ModTime: timex.DefaultFormat(fi.ModTime()), }) + } sort.Sort(vo.MachineFileInfos(fisVO)) rc.ResData = fisVO diff --git a/server/internal/machine/api/vo/vo.go b/server/internal/machine/api/vo/vo.go index 7f717eef..685f5510 100644 --- a/server/internal/machine/api/vo/vo.go +++ b/server/internal/machine/api/vo/vo.go @@ -65,10 +65,12 @@ type MachineFileVO struct { } type MachineFileInfo struct { - Name string `json:"name"` - Path string `json:"path"` - Size int64 `json:"size"` - Type string `json:"type"` + Name string `json:"name"` + Path string `json:"path"` + Size int64 `json:"size"` + Type string `json:"type"` + Mode string `json:"mode"` + ModTime string `json:"modTime"` } type MachineFileInfos []MachineFileInfo diff --git a/server/internal/machine/infrastructure/machine/terminal_session.go b/server/internal/machine/infrastructure/machine/terminal_session.go index b8319df9..4d171531 100644 --- a/server/internal/machine/infrastructure/machine/terminal_session.go +++ b/server/internal/machine/infrastructure/machine/terminal_session.go @@ -73,7 +73,9 @@ func (r TerminalSession) Stop() { r.cancel() if r.terminal != nil { if err := r.terminal.Close(); err != nil { - logx.Errorf("关闭机器ssh终端失败: %s", err.Error()) + if err != io.EOF { + logx.Errorf("关闭机器ssh终端失败: %s", err.Error()) + } } } }