fix(billing): refine mobile dates and balance card

go
codex 2 weeks ago
parent 9ea9625576
commit 96f06d3438

@ -265,8 +265,12 @@ body.vu-embedded .dashboard > .main-area > .vu-main > .vu-topbar { margin: 0; }
.cloud-order-actions .row-button:not(:disabled):hover { border-color: #bcdadd; background: #edf8f8; }
.cloud-order:last-child { border: 0; }
.cloud-order code { overflow-wrap: anywhere; }
.invoice-balance-card { display: flex; align-items: center; gap: 14px; margin: 0 0 20px; padding: 18px 22px; border: 1px solid #e0e9ef; border-radius: 13px; background: #fff; box-shadow: 0 10px 30px rgba(19,42,65,.027); color: #77899a; font-size: 12px; font-weight: 700; }
.invoice-balance-card strong { margin-right: auto; color: #1e354d; font-size: 23px; letter-spacing: -.4px; }
.invoice-balance-card { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 16px 24px; margin: 0 0 20px; padding: 20px 22px; border: 1px solid #dce9ed; border-radius: 14px; background: linear-gradient(135deg,#fff 0%,#f7fbfc 100%); box-shadow: 0 10px 30px rgba(19,42,65,.035); }
.invoice-balance-summary { display: grid; gap: 4px; min-width: 0; }
.invoice-balance-label { color: #71869a; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.invoice-balance-card strong { color: #1e354d; font-size: clamp(26px,3vw,32px); font-variant-numeric: tabular-nums; font-weight: 800; letter-spacing: -.55px; line-height: 1.15; overflow-wrap: anywhere; }
.invoice-balance-hint { color: #8a9baa; font-size: 11px; font-weight: 600; line-height: 1.45; }
.invoice-balance-card > .button { min-width: 104px; }
.cloud-invoice { position: relative; }
.cloud-invoice-list-row { grid-template-columns: minmax(240px, 1fr) auto minmax(105px, auto); grid-template-areas: "copy actions amount"; }
.cloud-invoice-list-copy { grid-area: copy; }
@ -283,6 +287,7 @@ body.vu-embedded .dashboard > .main-area > .vu-main > .vu-topbar { margin: 0; }
.invoice-filter-field select,.invoice-filter-field input { width: 100%; height: 42px; min-width: 0; border: 1px solid #dce6ec; border-radius: 9px; background-color: #fff; color: #31495d; font-size: 12px; font-weight: 700; }
.invoice-filter-field select { padding: 0 38px 0 13px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23899aaa' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.invoice-filter-field input { padding: 0 12px; }
.invoice-filter-field input[type="date"] { display: block; width: 100%; max-width: 100%; min-inline-size: 0; font-variant-numeric: tabular-nums; }
.invoice-filter-field select:focus,.invoice-filter-field input:focus { border-color: #35b9c0; box-shadow: 0 0 0 4px rgba(25,179,187,.1); outline: none; }
.invoice-filter-actions { display: flex; align-items: center; gap: 7px; min-height: 42px; }
.cloud-invoice-context { margin-top: 4px; color: #60788e; }
@ -422,11 +427,10 @@ body.vu-embedded .dashboard > .main-area > .vu-main > .vu-topbar { margin: 0; }
.cloud-order { padding: 19px 17px; }
.cloud-order-actions { width: 100%; }
.cloud-order-actions .row-button { flex: 1 1 145px; }
.invoice-balance-card { align-items: flex-start; flex-wrap: wrap; }
.invoice-balance-card strong { flex: 1 1 calc(100% - 130px); }
.invoice-filter-bar { display: grid; grid-template-columns: 1fr 1fr; align-items: end; }
.invoice-filter-bar { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: end; }
.invoice-filter-field,.invoice-filter-keyword,.invoice-filter-date { width: 100%; min-width: 0; }
.invoice-filter-keyword,.invoice-filter-actions { grid-column: 1 / -1; }
.invoice-filter-date { grid-column: 1 / -1; }
.invoice-filter-actions .button { flex: 1; }
.invoice-pagination { justify-content: space-between; gap: 8px; }
.invoice-pagination > span { min-width: 0; flex: 1; }
@ -452,3 +456,8 @@ body.vu-embedded .dashboard > .main-area > .vu-main > .vu-topbar { margin: 0; }
.vm-traffic-daily-status { margin-inline: 17px; }
.vm-traffic-daily-legend { padding-inline: 17px; }
}
@media (max-width: 360px) {
.invoice-balance-card { grid-template-columns: 1fr; }
.invoice-balance-card > .button { width: 100%; }
}

@ -1,6 +1,13 @@
<section id="invoices-workspace">
<div class="page-heading"><div><span class="eyebrow">BILLING</span><h1>账单信息</h1><p>部署实例时先生成开通账单,支付完成后才开始创建;实例到期前 7 天会自动生成续费账单。实例到期后立即停用网络,到期满 3 天仍未续费,实例及系统盘将被永久删除。</p></div><button id="invoices-refresh" class="button button-outline" type="button">刷新</button></div>
<div class="invoice-balance-card"><span>当前账户余额</span><strong id="invoices-balance">{$cloud_invoice_balance|escape:"html"}</strong><button class="button button-outline small" type="button" data-account-drawer-open="balance" data-drawer-title="余额充值" data-drawer-description="选择充值金额和可用支付方式">余额充值</button></div>
<div class="invoice-balance-card">
<div class="invoice-balance-summary">
<span class="invoice-balance-label">当前账户余额</span>
<strong id="invoices-balance">{$cloud_invoice_balance|escape:"html"}</strong>
<small class="invoice-balance-hint">可用于支付未结清账单</small>
</div>
<button class="button button-outline small" type="button" data-account-drawer-open="balance" data-drawer-title="余额充值" data-drawer-description="选择充值金额和可用支付方式">余额充值</button>
</div>
<form id="invoices-filter-form" class="invoice-filter-bar" method="get" action="/user/cloud/invoices">
<label class="invoice-filter-field" for="invoices-purpose-filter">
<span>账单类型</span>

@ -1,2 +1,2 @@
{* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *}
{assign var=venix_asset_version value='2026110121' scope='global'}
{assign var=venix_asset_version value='2026110122' scope='global'}

@ -329,7 +329,7 @@ $assert(str_contains($invoicePresentation,
&& !str_contains($invoicePresentation, 'match (strtolower($status))'),
'User invoice statuses must translate catalog tones, not rebuild semantics.');
$assert(str_contains($layoutAssets,
"venix_asset_version value='2026110121'")
"venix_asset_version value='2026110122'")
&& str_contains($template,
'/cloud/admin-billing.js?v={$venix_asset_version}'),
'Administrator billing asset changes must advance the shared cache key.');

@ -15,7 +15,7 @@ $assert = static function (bool $condition, string $message): void {
};
$assert(is_string($assets)
&& str_contains($assets, "venix_asset_version value='2026110121'")
&& str_contains($assets, "venix_asset_version value='2026110122'")
&& is_string($cloudShell)
&& str_contains($cloudShell, '/cloud/app.js?v={$venix_asset_version}'),
'The cloud application entry must use the shared Venix asset version.');

@ -0,0 +1,118 @@
import assert from 'node:assert/strict';
import { execFile } from 'node:child_process';
import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { promisify } from 'node:util';
const execFileAsync = promisify(execFile);
const root = new URL('../', import.meta.url);
const css = await readFile(new URL('public/cloud/client.css', root), 'utf8');
const template = await readFile(
new URL('resources/views/venix/cloud/pages/invoices.tpl', root),
'utf8',
);
assert.match(template, /class="invoice-balance-summary"/,
'The balance label and amount must share a stable summary container.');
assert.match(template, /class="invoice-balance-hint"/,
'The balance card must explain what the wallet balance can be used for.');
assert.match(css, /\.invoice-balance-summary\s*\{/,
'The balance summary has no dedicated visual hierarchy.');
assert.match(css, /@media \(max-width: 520px\)[\s\S]*?\.invoice-filter-date\s*\{[^}]*grid-column:\s*1\s*\/\s*-1/,
'Mobile date controls must each occupy a full row to avoid native-input overflow.');
assert.match(css, /\.invoice-filter-field input\[type="date"\][^{]*\{[^}]*max-width:\s*100%/,
'Native date controls must be explicitly constrained to their grid cell.');
assert.match(css, /@media \(max-width: 360px\)[\s\S]*?\.invoice-balance-card\s*\{[^}]*grid-template-columns:\s*1fr/,
'Very narrow screens must stack the balance action below the amount.');
const chromeCandidates = [
'/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
'/Applications/Chromium.app/Contents/MacOS/Chromium',
'/usr/bin/google-chrome',
'/usr/bin/chromium',
'/usr/bin/chromium-browser',
];
let chrome = '';
for (const candidate of chromeCandidates) {
try {
await execFileAsync(candidate, ['--version']);
chrome = candidate;
break;
} catch { /* Try the next local browser. */ }
}
if (chrome) {
const directory = await mkdtemp(join(tmpdir(), 'invoice-mobile-layout-'));
const fixture = join(directory, 'fixture.html');
const safeCss = css.replaceAll('</style', '<\\/style');
const html = `<!doctype html><html><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>${safeCss}</style></head><body>
<main style="width:auto;box-sizing:border-box;padding:20px;">
<div class="invoice-balance-card">
<div class="invoice-balance-summary">
<span class="invoice-balance-label">当前账户余额</span>
<strong id="invoices-balance">$10,551.00</strong>
<small class="invoice-balance-hint">可用于支付未结清账单</small>
</div>
<button class="button button-outline small" type="button">余额充值</button>
</div>
<form class="invoice-filter-bar">
<label class="invoice-filter-field"><span>账单类型</span><select><option>全部账单</option></select></label>
<label class="invoice-filter-field"><span>账单状态</span><select><option>全部状态</option></select></label>
<label class="invoice-filter-field invoice-filter-keyword"><span>账单或实例</span><input type="search"></label>
<label class="invoice-filter-field invoice-filter-date" id="from-field"><span>开始日期</span><input id="from-date" type="date"></label>
<label class="invoice-filter-field invoice-filter-date" id="to-field"><span>结束日期</span><input id="to-date" type="date"></label>
<div class="invoice-filter-actions"><button class="button button-primary small">筛选</button><button class="button button-ghost small">清除</button></div>
</form>
</main><script>
const rect = target => { const value = target.getBoundingClientRect(); return { left:value.left, right:value.right, top:value.top, bottom:value.bottom, width:value.width }; };
const card = document.querySelector('.invoice-balance-card');
document.body.dataset.metrics = encodeURIComponent(JSON.stringify({
viewport: document.documentElement.clientWidth,
scrollWidth: document.documentElement.scrollWidth,
from: rect(document.getElementById('from-field')),
to: rect(document.getElementById('to-field')),
fromInput: rect(document.getElementById('from-date')),
toInput: rect(document.getElementById('to-date')),
card: rect(card),
summary: rect(card.querySelector('.invoice-balance-summary')),
recharge: rect(card.querySelector('button')),
}));
</script></body></html>`;
await writeFile(fixture, html);
const measure = async width => {
const profile = join(directory, `profile-${width}`);
const { stdout } = await execFileAsync(chrome, [
'--headless=new', '--disable-gpu', '--no-sandbox', '--hide-scrollbars',
`--window-size=${width},844`, `--user-data-dir=${profile}`,
'--dump-dom', `file://${fixture}`,
], { maxBuffer: 8 * 1024 * 1024 });
const encoded = stdout.match(/data-metrics="([^"]+)"/)?.[1];
assert.ok(encoded, 'Headless browser did not return invoice layout metrics.');
return JSON.parse(decodeURIComponent(encoded));
};
try {
// Desktop Chrome enforces a 500 CSS-pixel minimum headless window. That
// still drives the real max-width:520px mobile rules; the narrower
// max-width:360px fallback is locked by the static contract above.
const regular = await measure(500);
assert.ok(regular.scrollWidth <= regular.viewport,
`Invoice page overflows horizontally (${regular.scrollWidth} > ${regular.viewport}).`);
assert.ok(Math.abs(regular.from.left - regular.to.left) < 1
&& regular.to.top >= regular.from.bottom,
'Mobile date controls are not stacked into stable full-width rows.');
assert.ok(regular.fromInput.right <= regular.viewport
&& regular.toInput.right <= regular.viewport,
'A native date input extends beyond the mobile viewport.');
assert.ok(regular.recharge.left >= regular.summary.right - 1
&& regular.recharge.right <= regular.card.right,
'The balance action is not aligned with the summary on a normal phone.');
} finally {
await rm(directory, { recursive: true, force: true });
}
}
console.log(`Cloud invoice mobile date and balance layout checks passed${chrome ? ' with headless browser.' : ' (browser unavailable; static contract only).'}`);
Loading…
Cancel
Save