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