From 3ba575213e4fd56848a8cfc2804587a6f0e6d2be Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 28 Sep 2026 21:11:55 +0800 Subject: [PATCH] feat: compact mobile instance plans --- web/public/cloud/runtime.js | 4 +++- web/public/cloud/styles.css | 2 +- web/resources/views/venix/layout_assets.tpl | 2 +- web/tests/VirtualizationAssetsTest.php | 24 +++++++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/web/public/cloud/runtime.js b/web/public/cloud/runtime.js index 0eb5a77b..07493ef9 100644 --- a/web/public/cloud/runtime.js +++ b/web/public/cloud/runtime.js @@ -495,7 +495,9 @@ async function selectPlan(planId) { const plan = state.plans.find(item => String(item.id) === String(planId) && String(item.host_id) === state.selectedRegionHostId); if (!plan) return; byId('vm-plan').value = String(plan.id); - renderPlanPicker(); + byId('vm-plan-picker').querySelectorAll('.plan-option').forEach(button => { + button.setAttribute('aria-pressed', String(button.dataset.planId === String(plan.id))); + }); showError('create-error', ''); updateCreateAvailability(); } diff --git a/web/public/cloud/styles.css b/web/public/cloud/styles.css index 3c38e72c..a79a8f0d 100644 --- a/web/public/cloud/styles.css +++ b/web/public/cloud/styles.css @@ -255,4 +255,4 @@ tbody tr:hover{background:#fcfefe} .plan-option>:nth-child(5)::before{content:"每月流量"} .plan-option>:nth-child(6)::before{content:"价格"} } -@media(max-width:510px){.deployment-step{padding-bottom:23px;margin-bottom:22px}.deployment-step-heading{margin-bottom:16px}.region-picker,.user-iso-picker{grid-template-columns:1fr}.region-option{min-height:66px}.template-family-card{height:140px;min-height:140px;border:1px solid #dce7ec;border-radius:12px;background:#fff;overflow:hidden;box-shadow:none}.template-family-summary{height:100%;min-height:100%;border:0;border-radius:inherit;background:transparent}.template-family-card[open]{z-index:70;border-color:#a8dadd;box-shadow:0 12px 28px rgba(30,66,82,.14)}.template-family-card.has-selection{border-color:#2eabb4;background:#f5fbfb}.template-versions{position:absolute;inset:0;z-index:80;width:auto;height:auto;max-height:none;margin:0;padding:6px 8px 40px;overflow-y:auto;border:0;border-radius:inherit;background:#fbfdfd;box-shadow:none;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.template-family-card[open] .template-family-footer{position:absolute;right:7px;bottom:7px;z-index:90;width:32px;min-height:32px;border-radius:999px;background:#eaf8f8}.template-family-card[open] .template-family-selection{display:none}.user-iso-row{align-items:flex-start;flex-direction:column}.user-iso-row .row-button{width:100%}.user-iso-empty{align-items:flex-start;flex-direction:column}} +@media(max-width:510px){.deployment-step{padding-bottom:23px;margin-bottom:22px}.deployment-step-heading{margin-bottom:16px}.region-picker,.user-iso-picker{grid-template-columns:1fr}.region-option{min-height:66px}.plan-option{grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:auto auto;gap:12px 8px;min-height:108px;padding:15px 14px 14px 16px}.plan-option::after{content:"";position:absolute;top:13px;right:14px;display:grid;place-items:center;width:22px;height:22px;border:1.5px solid #bdccd4;border-radius:50%;background:#fff;color:transparent;font-size:12px;font-weight:900}.plan-option[aria-pressed="true"]{box-shadow:inset 4px 0 0 #20a8b1}.plan-option[aria-pressed="true"]::after{content:"✓";top:13px;right:14px;width:22px;height:22px;border:1.5px solid #18a6b0;background:#18a6b0;color:#fff}.plan-option-name{grid-column:1/3;grid-row:1;align-self:center;font-size:14px}.plan-option-price{display:block;grid-column:3/5;grid-row:1;align-self:center;justify-self:end;padding-right:30px;font-size:14px;white-space:nowrap}.plan-option-price::before{display:none;content:none}.plan-option-value{display:grid;grid-row:2;gap:4px;white-space:normal}.plan-option-value::before{color:#718599;font-size:9px;font-weight:800;white-space:nowrap}.plan-option>:nth-child(2){grid-column:1}.plan-option>:nth-child(3){grid-column:2}.plan-option>:nth-child(4){grid-column:3}.plan-option>:nth-child(5){grid-column:4}.template-family-card{height:140px;min-height:140px;border:1px solid #dce7ec;border-radius:12px;background:#fff;overflow:hidden;box-shadow:none}.template-family-summary{height:100%;min-height:100%;border:0;border-radius:inherit;background:transparent}.template-family-card[open]{z-index:70;border-color:#a8dadd;box-shadow:0 12px 28px rgba(30,66,82,.14)}.template-family-card.has-selection{border-color:#2eabb4;background:#f5fbfb}.template-versions{position:absolute;inset:0;z-index:80;width:auto;height:auto;max-height:none;margin:0;padding:6px 8px 40px;overflow-y:auto;border:0;border-radius:inherit;background:#fbfdfd;box-shadow:none;overscroll-behavior:contain;-webkit-overflow-scrolling:touch}.template-family-card[open] .template-family-footer{position:absolute;right:7px;bottom:7px;z-index:90;width:32px;min-height:32px;border-radius:999px;background:#eaf8f8}.template-family-card[open] .template-family-selection{display:none}.user-iso-row{align-items:flex-start;flex-direction:column}.user-iso-row .row-button{width:100%}.user-iso-empty{align-items:flex-start;flex-direction:column}} diff --git a/web/resources/views/venix/layout_assets.tpl b/web/resources/views/venix/layout_assets.tpl index e92ade3c..3de667b6 100644 --- a/web/resources/views/venix/layout_assets.tpl +++ b/web/resources/views/venix/layout_assets.tpl @@ -1 +1 @@ -{assign var=venix_asset_version value='2026092818' scope='global'} +{assign var=venix_asset_version value='2026092819' scope='global'} diff --git a/web/tests/VirtualizationAssetsTest.php b/web/tests/VirtualizationAssetsTest.php index 5a6d0642..9794034c 100644 --- a/web/tests/VirtualizationAssetsTest.php +++ b/web/tests/VirtualizationAssetsTest.php @@ -159,6 +159,13 @@ $selectPlanEnd = $selectPlanStart === false ? false : strpos($runtimeDeployScript, 'async function openCreate(', $selectPlanStart); $selectPlan = $selectPlanStart === false || $selectPlanEnd === false ? '' : substr($runtimeDeployScript, $selectPlanStart, $selectPlanEnd - $selectPlanStart); +$assert($selectPlan !== '' + && !str_contains($selectPlan, 'renderPlanPicker();') + && str_contains($selectPlan, + "byId('vm-plan-picker').querySelectorAll('.plan-option').forEach(button => {") + && str_contains($selectPlan, + "button.setAttribute('aria-pressed', String(button.dataset.planId === String(plan.id)));"), + 'Selecting a plan must preserve the focused row instead of replacing the plan list.'); $openCreateStart = strpos($runtimeDeployScript, 'async function openCreate('); $openCreateEnd = $openCreateStart === false ? false : strpos($runtimeDeployScript, 'async function loadGlobalTemplates()', $openCreateStart); @@ -245,6 +252,23 @@ $cardVersionRule = strpos($baseStyles, '.template-version-option{width:100%;display:grid;gap:3px;'); $flatVersionRule = strpos($baseStyles, '.template-version-option{min-height:44px;padding:11px 4px;border:0;'); +$assert(str_contains($mobileDeploymentStyles, + '.plan-option{grid-template-columns:repeat(4,minmax(0,1fr));grid-template-rows:auto auto;gap:12px 8px;min-height:108px;') + && str_contains($mobileDeploymentStyles, + '.plan-option-name{grid-column:1/3;grid-row:1;align-self:center;font-size:14px}') + && str_contains($mobileDeploymentStyles, + '.plan-option-price{display:block;grid-column:3/5;grid-row:1;align-self:center;justify-self:end;padding-right:30px;') + && str_contains($mobileDeploymentStyles, + '.plan-option-value{display:grid;grid-row:2;gap:4px;white-space:normal}') + && str_contains($mobileDeploymentStyles, + '.plan-option>:nth-child(2){grid-column:1}.plan-option>:nth-child(3){grid-column:2}.plan-option>:nth-child(4){grid-column:3}.plan-option>:nth-child(5){grid-column:4}') + && str_contains($mobileDeploymentStyles, + '.plan-option[aria-pressed="true"]{box-shadow:inset 4px 0 0 #20a8b1}') + && str_contains($mobileDeploymentStyles, + '.plan-option-price::before{display:none;content:none}') + && !str_contains($mobileDeploymentStyles, + '.plan-option{grid-template-columns:repeat(2,minmax(0,1fr))'), + 'Mobile deployment plans must use a compact two-row comparison layout without replacing semantic plan buttons.'); $assert(str_contains($baseStyles, '.template-catalog{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));align-items:start;') && str_contains($baseStyles,