diff --git a/src/views/acs/nodes/VmDetail.vue b/src/views/acs/nodes/VmDetail.vue index cdd7998..12d47a1 100644 --- a/src/views/acs/nodes/VmDetail.vue +++ b/src/views/acs/nodes/VmDetail.vue @@ -15,6 +15,7 @@
返回 刷新数据 + 清除缓存
@@ -99,7 +100,7 @@
链接端口号
-
{{ vmInfo.link_port || '10006' }}
+
{{ vmInfo.node_port || (portsList.length > 0 ? portsList[0].node_port : '10006') }}
虚拟机用户名
@@ -825,7 +826,7 @@ const setCachedData = (instanceId, data) => { console.log(`缓存虚拟机数据: ${instanceId}`, cacheData); }; -const isCacheValid = (cachedData, maxAge = 5 * 60 * 1000) => { // 默认5分钟有效期 +const isCacheValid = (cachedData, maxAge = 10 * 60 * 1000) => { // 默认10分钟有效期 if (!cachedData || !cachedData.timestamp) return false; return (Date.now() - cachedData.timestamp) < maxAge; }; @@ -1379,12 +1380,17 @@ const fetchVmInfo = async (instanceId = null, useCache = true) => { const serverRes = await selectServer({server_id:res.data.data.server_id}) const planRes = await selectServerPlan({plan_id:res.data.data.plan_id,server_type:"hyperV"}) const imageRes= await Mirrorinfo({image_id:res.data.data.image_id,server_type:"hyperV"}) + + // 如果端口列表已加载,获取第一个端口号 + const firstPort = portsList.value.length > 0 ? portsList.value[0].node_port : null; + const data = { ...res.data.data, server_name:serverRes.data.data.name, server_ip:serverRes.data.data.server_ip, plan_name:planRes.data.data.name, - image_name:imageRes.data.data.name + image_name:imageRes.data.data.name, + node_port: res.data.data.node_port || firstPort // 优先使用API返回的,否则用端口列表的第一个 } if (res && res.data && res.data.code === 200) { vmInfo.value = data || {}; @@ -1554,6 +1560,13 @@ const refreshData = () => { loadAllData(instanceId, false); }; +// 清除所有缓存 +const clearAllCache = () => { + console.log('清除所有虚拟机缓存'); + dataCache.value.clear(); + ElMessage.success('已清除所有缓存'); +}; + // 启动虚拟机 const handleStart = async () => { try {