feat(vm): 虚拟机详情页新增 SSH 连接按钮
Build and Deploy Vue3 / build (push) Successful in 1m41s
Build and Deploy Vue3 / deploy (push) Failing after 32s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shiran
2026-06-08 11:33:32 +08:00
parent 86794145f1
commit 3227a50f9a
2 changed files with 20 additions and 0 deletions
+10
View File
@@ -36,6 +36,7 @@
</div>
<div class="overview-actions">
<el-button v-if="isVmGoods" size="small" type="primary" @click="handleVnc">VNC</el-button>
<el-button v-if="isVmGoods" size="small" type="success" @click="handleSshConnect" :disabled="!vmPublicIpList.length || isWindows">SSH连接</el-button>
<el-button v-if="isVmGoods" size="small" type="success" @click="handlePower('start')" :disabled="vm?.status === 'running'">启动</el-button>
<el-button v-if="isVmGoods" size="small" type="warning" @click="handlePower('reboot')">重启</el-button>
<el-button v-if="isVmGoods" size="small" type="danger" @click="handlePower('stop')" :disabled="vm?.status === 'stopped' || vm?.status === 'stop'">关机</el-button>
@@ -1407,6 +1408,15 @@ const loadSgLockInfo = async () => {
const vncVisible = ref(false)
const vncLoading = ref(false)
const vncResult = ref(null)
const handleSshConnect = () => {
const host = vmPublicIpList.value[0]
if (!host) return ElMessage.warning('无可用公网 IP')
const username = isWindows.value ? 'Administrator' : 'root'
const password = vm.value?.root_password || ''
const encodedPwd = btoa(password)
window.open(`https://webssh1.007yjs.com/?hostname=${encodeURIComponent(host)}&username=${encodeURIComponent(username)}&password=${encodedPwd}`, '_blank')
}
const handleVnc = async () => {
vncVisible.value = true; vncLoading.value = true; vncResult.value = null
try {
+10
View File
@@ -18,6 +18,7 @@
</div>
<div class="overview-actions">
<el-button type="primary" @click="handleGetVnc">远程连接</el-button>
<el-button type="success" @click="handleSshConnect" :disabled="!publicIpList.length || isWindows">SSH连接</el-button>
<el-button type="danger" @click="handlePower('stop')" :disabled="detail.status === 'stopped' || detail.status === 'stop' || isMigrating">关机</el-button>
<el-dropdown trigger="click" @command="handleMoreCommand">
<el-button>更多 <el-icon class="el-icon--right"><ArrowDown /></el-icon></el-button>
@@ -2783,6 +2784,15 @@ const loadVncNodes = async () => {
} catch { /* */ }
}
const handleSshConnect = () => {
const host = publicIpList.value[0]
if (!host) return ElMessage.warning('无可用公网 IP')
const username = isWindows.value ? 'Administrator' : 'root'
const password = detail.value?.root_password || ''
const encodedPwd = btoa(password)
window.open(`https://webssh1.007yjs.com/?hostname=${encodeURIComponent(host)}&username=${encodeURIComponent(username)}&password=${encodedPwd}`, '_blank')
}
const handleGetVnc = async () => {
vncNodeId.value = null
vncResult.value = null