fix: 重构虚拟机内网外网参数设置选择网络
Build and Deploy Vue3 / build (push) Successful in 1m28s
Build and Deploy Vue3 / deploy (push) Successful in 1m1s

This commit is contained in:
lin
2026-03-26 16:36:25 +08:00
parent 40a5e486a6
commit 1a4587f893
13 changed files with 1028 additions and 135 deletions
+52 -4
View File
@@ -45,9 +45,17 @@
<div class="profile-stats">
<div class="stat-item">
<div class="stat-label">认证Token</div>
<div class="stat-value">
<el-tag v-if="serviceInfo.Token || serviceInfo.token" type="success" size="small">已设置</el-tag>
<el-tag v-else type="info" size="small">未设置</el-tag>
<div class="stat-value" v-if="serviceInfo.Token || serviceInfo.token">
<code class="token-text">{{ tokenVisible ? (serviceInfo.Token || serviceInfo.token) : '••••••••••••' }}</code>
<el-button link size="small" @click="tokenVisible = !tokenVisible" style="margin-left: 4px">
<el-icon><View v-if="!tokenVisible" /><Hide v-else /></el-icon>
</el-button>
<el-button link size="small" @click="copyToken" style="margin-left: 2px">
<el-icon><CopyDocument /></el-icon>
</el-button>
</div>
<div class="stat-value" v-else>
<el-tag type="info" size="small">未设置</el-tag>
</div>
</div>
<div class="stat-item">
@@ -134,7 +142,7 @@
import { ref, reactive, computed, provide, onMounted, onActivated, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ArrowLeft, Refresh, Edit, Delete, Monitor } from '@element-plus/icons-vue'
import { ArrowLeft, Refresh, Edit, Delete, Monitor, View, Hide, CopyDocument } from '@element-plus/icons-vue'
import {
getKvmServiceDetail, updateKvmService, deleteKvmService
} from '@/api/admin/kvmService'
@@ -241,6 +249,29 @@ const goBack = () => {
router.push('/virtualization/kvm-service')
}
// Token 显示/复制
const tokenVisible = ref(false)
const copyToken = () => {
const token = serviceInfo.value.Token || serviceInfo.value.token
if (!token) return
const textarea = document.createElement('textarea')
textarea.value = token
textarea.style.position = 'fixed'
textarea.style.opacity = '0'
document.body.appendChild(textarea)
textarea.select()
try {
document.execCommand('copy')
ElMessage.success('Token 已复制到剪贴板')
} catch {
ElMessage.error('复制失败')
} finally {
document.body.removeChild(textarea)
}
}
// 编辑服务
const editDialogVisible = ref(false)
const formRef = ref(null)
@@ -482,6 +513,23 @@ onMounted(() => {
color: #303133;
}
.token-text {
font-family: monospace;
font-size: 12px;
color: #606266;
background: #f5f7fa;
padding: 2px 8px;
border-radius: 4px;
user-select: all;
word-break: break-all;
max-width: 180px;
display: inline-block;
vertical-align: middle;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.note-value {
font-weight: 400;
font-size: 13px;