mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-11-02 15:30:25 +08:00
fix: 修复机器列表查询与放开vnc
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
<script lang="ts" setup>
|
||||
import { toRefs, reactive, onMounted } from 'vue';
|
||||
import { machineApi } from '../machine/api';
|
||||
import { MachineProtocolEnum } from '../machine/enums';
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
@@ -46,7 +47,7 @@ onMounted(async () => {
|
||||
|
||||
const getSshTunnelMachines = async () => {
|
||||
if (state.sshTunnelMachineList.length == 0) {
|
||||
const res = await machineApi.list.request({ pageNum: 1, pageSize: 100, ssh: 1 });
|
||||
const res = await machineApi.list.request({ pageNum: 1, pageSize: 100, protocol: MachineProtocolEnum.Ssh.value });
|
||||
state.sshTunnelMachineList = res.list;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</el-tooltip>
|
||||
|
||||
<el-button v-if="data.protocol == MachineProtocolEnum.Rdp.value" type="primary" @click="showRDP(data)" link>RDP</el-button>
|
||||
<el-button v-if="data.protocol == 3" type="primary" @click="showRDP(data)" link>VNC</el-button>
|
||||
<el-button v-if="data.protocol == MachineProtocolEnum.Vnc.value" type="primary" @click="showRDP(data)" link>VNC</el-button>
|
||||
|
||||
<el-divider direction="vertical" border-style="dashed" />
|
||||
</span>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { EnumValue } from '@/common/Enum';
|
||||
export const MachineProtocolEnum = {
|
||||
Ssh: EnumValue.of(1, 'SSH'),
|
||||
Rdp: EnumValue.of(2, 'RDP'),
|
||||
Vnc: EnumValue.of(3, 'VNC'),
|
||||
};
|
||||
|
||||
// 脚本执行结果类型
|
||||
|
||||
@@ -24,4 +24,5 @@ const (
|
||||
|
||||
MachineProtocolSsh = 1
|
||||
MachineProtocolRdp = 2
|
||||
MachineProtocolVnc = 3
|
||||
)
|
||||
|
||||
@@ -3,13 +3,13 @@ package entity
|
||||
import "time"
|
||||
|
||||
type MachineQuery struct {
|
||||
Ids string `json:"ids" form:"ids"`
|
||||
Code string `json:"code" form:"code"`
|
||||
Name string `json:"name" form:"name"`
|
||||
Status int8 `json:"status" form:"status"`
|
||||
Ip string `json:"ip" form:"ip"` // IP地址
|
||||
TagPath string `json:"tagPath" form:"tagPath"`
|
||||
Ssh int8 `json:"ssh" form:"ssh"`
|
||||
Ids string `json:"ids" form:"ids"`
|
||||
Code string `json:"code" form:"code"`
|
||||
Name string `json:"name" form:"name"`
|
||||
Status int8 `json:"status" form:"status"`
|
||||
Ip string `json:"ip" form:"ip"` // IP地址
|
||||
TagPath string `json:"tagPath" form:"tagPath"`
|
||||
Protocol int8 `json:"protocol" form:"protocol"`
|
||||
|
||||
Codes []string
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import (
|
||||
"mayfly-go/internal/machine/domain/repository"
|
||||
"mayfly-go/pkg/base"
|
||||
"mayfly-go/pkg/model"
|
||||
"mayfly-go/pkg/utils/collx"
|
||||
"strings"
|
||||
|
||||
"github.com/may-fly/cast"
|
||||
)
|
||||
|
||||
type machineRepoImpl struct {
|
||||
@@ -23,11 +27,12 @@ func (m *machineRepoImpl) GetMachineList(condition *entity.MachineQuery, pagePar
|
||||
Like("name", condition.Name).
|
||||
In("code", condition.Codes).
|
||||
Like("code", condition.Code).
|
||||
In("id", condition.Ids)
|
||||
Eq("protocol", condition.Protocol)
|
||||
|
||||
// 只查询ssh服务器
|
||||
if condition.Ssh == entity.MachineProtocolSsh {
|
||||
qd.Eq("protocol", entity.MachineProtocolSsh)
|
||||
if condition.Ids != "" {
|
||||
qd.In("id", collx.ArrayMap[string, uint64](strings.Split(condition.Ids, ","), func(val string) uint64 {
|
||||
return cast.ToUint64(val)
|
||||
}))
|
||||
}
|
||||
|
||||
return m.PageByCond(qd, pageParam, toEntity)
|
||||
|
||||
Reference in New Issue
Block a user