diff --git a/web/public/cloud/client.css b/web/public/cloud/client.css index dff39fec..f50f8077 100644 --- a/web/public/cloud/client.css +++ b/web/public/cloud/client.css @@ -220,6 +220,7 @@ body.vu-embedded .dashboard > .main-area > .vu-main > .vu-topbar { margin: 0; } .cloud-payment-qr-error { padding: 24px; text-align: center; } .cloud-payment-qr img,.cloud-payment-qr canvas { display: block; max-width: 196px; height: auto; } .vm-detail-secret { max-width: 100%; overflow-wrap: anywhere; } +.vm-usage-sections { display: grid; gap: 18px; margin-bottom: 18px; } .inventory-panel.vm-service-panel { min-height: 0; margin-top: 0; } .vm-service-panel .panel-heading { align-items: center; } .vm-service-panel .panel-heading > div { min-width: 0; } @@ -237,6 +238,7 @@ body.vu-embedded .dashboard > .main-area > .vu-main > .vu-topbar { margin: 0; } .vm-traffic-progress > span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #1bb6b0, #0f9eaa); transition: width .25s ease; } .vm-traffic-progress.is-exhausted > span { background: #d94350; } .vm-traffic-daily { margin-top: 18px; overflow: hidden; } +.vm-usage-sections .vm-traffic-daily { margin-top: 0; } .vm-traffic-daily-status { margin: 0 24px 4px; padding: 9px 12px; border-radius: 8px; background: #eaf7f7; color: #277b82; font-size: 11px; line-height: 1.5; } .vm-traffic-daily-status.warning { background: #fff6e9; color: #946620; } .vm-traffic-daily-plot { display: flex; align-items: center; justify-content: center; height: 300px; margin: 4px 20px 2px; overflow: hidden; } diff --git a/web/public/cloud/detail.js b/web/public/cloud/detail.js index 5d6f16cf..b1bbf167 100644 --- a/web/public/cloud/detail.js +++ b/web/public/cloud/detail.js @@ -263,10 +263,11 @@ export async function initialize() { const vm = hydrateVmDetailBootstrap(detailBootstrap()); bindPageCleanup(); const vmId = vm.api_id; - state.detailTab = VM_DETAIL_TABS.includes(new URLSearchParams(location.search).get('tab')) - ? new URLSearchParams(location.search).get('tab') : 'operations'; - clearVmMetrics('打开“性能监控”页签后加载监控数据。'); - clearVmTrafficDaily('打开“流量信息”页签后加载最近 30 天数据。'); + const requestedTab = new URLSearchParams(location.search).get('tab'); + const initialTab = requestedTab === 'traffic' ? 'performance' : requestedTab; + state.detailTab = VM_DETAIL_TABS.includes(initialTab) ? initialTab : 'operations'; + clearVmMetrics('打开“使用记录”页签后加载性能数据。'); + clearVmTrafficDaily('打开“使用记录”页签后加载最近 30 天流量数据。'); renderVmDetail(vm); setVmDetailTab(state.detailTab); if (state.detailTab === 'operations-log') void loadOperationLogs(vmId); diff --git a/web/public/cloud/runtime.js b/web/public/cloud/runtime.js index 8c61cac0..201149d0 100644 --- a/web/public/cloud/runtime.js +++ b/web/public/cloud/runtime.js @@ -151,9 +151,10 @@ function clearCredential() { if (byId('vm-detail-root-password')) text('vm-detail-root-password', '********'); byId('vm-detail-password-reveal')?.setAttribute('aria-pressed', 'false'); } -const VM_DETAIL_TABS = ['operations', 'performance', 'traffic', 'operations-log']; +const VM_DETAIL_TABS = ['operations', 'performance', 'operations-log']; function setVmDetailTab(tab, focus = false) { - const next = VM_DETAIL_TABS.includes(tab) ? tab : 'operations'; + const requested = tab === 'traffic' ? 'performance' : tab; + const next = VM_DETAIL_TABS.includes(requested) ? requested : 'operations'; state.detailTab = next; for (const name of VM_DETAIL_TABS) { const button = byId(`vm-detail-tab-${name}`); @@ -166,8 +167,10 @@ function setVmDetailTab(tab, focus = false) { stopVmMetrics(); stopVmTrafficDaily(); if (state.view === 'detail') { - if (next === 'performance') startVmMetrics(); - if (next === 'traffic') startVmTrafficDaily(); + if (next === 'performance') { + startVmMetrics(); + startVmTrafficDaily(); + } } if (focus) byId(`vm-detail-tab-${next}`).focus(); } @@ -1151,19 +1154,19 @@ async function loadVmMetrics() { previous?.controller.abort(); const request = { vmId, range, controller: new AbortController() }; state.metricsRequest = request; - setVmMetricsStatus("正在更新监控数据…"); + setVmMetricsStatus("正在更新性能数据…"); try { const payload = await api(`${vmPath()}/metrics?range=${encodeURIComponent(range)}`, { signal: request.controller.signal, }); if (request !== state.metricsRequest || !metricViewVisible()) return; if (!Array.isArray(payload?.points)) { - throw new Error("监控数据格式无效。"); + throw new Error("性能数据格式无效。"); } renderVmMetrics(payload); } catch (error) { if (request !== state.metricsRequest || request.controller.signal.aborted || !metricViewVisible()) return; - setVmMetricsStatus(`监控数据暂时无法加载:${error.message}。已显示的数据可能不是最新。`, true); + setVmMetricsStatus(`性能数据暂时无法加载:${error.message}。已显示的数据可能不是最新。`, true); } finally { if (request === state.metricsRequest) state.metricsRequest = null; } @@ -1328,7 +1331,7 @@ function renderVmMetrics(payload) { } function trafficDailyViewVisible() { - return state.view === "detail" && state.detailTab === "traffic" && Boolean(state.selectedVmId) && !document.hidden + return state.view === "detail" && state.detailTab === "performance" && Boolean(state.selectedVmId) && !document.hidden && !byId("dashboard-view").hidden && !byId("vm-workspace").hidden && !byId("vm-detail-view").hidden; } diff --git a/web/resources/views/venix/cloud/pages/detail.tpl b/web/resources/views/venix/cloud/pages/detail.tpl index 32719948..92957541 100644 --- a/web/resources/views/venix/cloud/pages/detail.tpl +++ b/web/resources/views/venix/cloud/pages/detail.tpl @@ -4,8 +4,7 @@
服务器 IP:{$cloud_vm_view.ip|default:'未获取'|escape:"html"}区域:{$cloud_vm_view.region|default:'未设置'|escape:"html"}{$cloud_vm_view.created_display|default:'未记录'|escape:"html"}
查看当前服务、网络状态和本期流量使用情况。
按天统计虚拟机的下载和上传流量。
打开流量信息后加载每日统计。
- -每分钟采样并自动刷新,历史数据最长保留 30 天;长时间范围会聚合,较长的采样缺口留空。
正在加载监控数据。
+查看实例性能、服务状态和本期流量使用情况;历史数据最长保留 30 天。
查看当前服务、网络状态和本期流量使用情况。
按天统计虚拟机的下载和上传流量。
打开使用记录后加载每日流量统计。
+ +正在加载性能数据。
—
—