feat(vm): 虚拟机详情页新增 SSH 连接按钮
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="overview-actions">
|
<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="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="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="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>
|
<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 vncVisible = ref(false)
|
||||||
const vncLoading = ref(false)
|
const vncLoading = ref(false)
|
||||||
const vncResult = ref(null)
|
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 () => {
|
const handleVnc = async () => {
|
||||||
vncVisible.value = true; vncLoading.value = true; vncResult.value = null
|
vncVisible.value = true; vncLoading.value = true; vncResult.value = null
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="overview-actions">
|
<div class="overview-actions">
|
||||||
<el-button type="primary" @click="handleGetVnc">远程连接</el-button>
|
<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-button type="danger" @click="handlePower('stop')" :disabled="detail.status === 'stopped' || detail.status === 'stop' || isMigrating">关机</el-button>
|
||||||
<el-dropdown trigger="click" @command="handleMoreCommand">
|
<el-dropdown trigger="click" @command="handleMoreCommand">
|
||||||
<el-button>更多 <el-icon class="el-icon--right"><ArrowDown /></el-icon></el-button>
|
<el-button>更多 <el-icon class="el-icon--right"><ArrowDown /></el-icon></el-button>
|
||||||
@@ -2783,6 +2784,15 @@ const loadVncNodes = async () => {
|
|||||||
} catch { /* */ }
|
} 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 () => {
|
const handleGetVnc = async () => {
|
||||||
vncNodeId.value = null
|
vncNodeId.value = null
|
||||||
vncResult.value = null
|
vncResult.value = null
|
||||||
|
|||||||
Reference in New Issue
Block a user