diff --git a/web/app/Controllers/CloudApiController.php b/web/app/Controllers/CloudApiController.php index 9fe4d0ec..baf63f7e 100644 --- a/web/app/Controllers/CloudApiController.php +++ b/web/app/Controllers/CloudApiController.php @@ -8,7 +8,6 @@ use App\Models\CloudJob; use App\Models\CloudOrder; use App\Models\CloudServicePeriod; use App\Models\CloudSSHKey; -use App\Models\Shop; use App\Models\User; use App\Services\Auth; use App\Services\AdminCsrf; @@ -221,9 +220,9 @@ final class CloudApiController } } - public function plans($request, $response) + public function catalog($request, $response) { - return $this->json($response, ['plans' => CloudDeploymentPageService::plans()]); + return $this->json($response, CloudDeploymentPageService::saleCatalog()); } public function orders($request, $response) @@ -1221,10 +1220,9 @@ final class CloudApiController { $actor = $this->actor($request); $query = $request->getQueryParams(); - $engine = new CloudEngineClient(); // Cloud images are a panel-wide catalog. Host-specific replication is // owned by the private engine and must not make the browser reload or - // replace the catalog whenever a customer changes region or plan. + // replace the catalog whenever a customer changes region, line or offer. $catalog = CloudDeploymentPageService::freshTemplateCatalog($actor); $templatePayload = [ 'templates' => is_array($catalog['templates'] ?? null) @@ -1233,40 +1231,19 @@ final class CloudApiController // Replication state is a host-internal catalog detail. It can contain // pool names, source paths, or future engine fields and is not needed // by the user image picker, so never copy it into a public response. - if (isset($query['vm_id'])) { - $hostId = (int) CloudAccess::instance($query['vm_id'], $actor)->host_id; - } elseif (isset($query['plan_id'])) { - // Compatibility for a browser opened before global catalogs were - // deployed. New clients request /resources once without a plan. - $plan = Shop::where('id', $query['plan_id'] ?? 0)->where('status', 1)->first(); - $hostId = (int) ($plan?->host_id ?? 0); - if (!CloudHost::where('id', $hostId)->where('enabled', 1)->exists()) { - throw new CloudError('套餐宿主机不可用', 404); - } - } else { - return $this->json($response, $templatePayload); - } if (!isset($query['vm_id'])) { - return $this->json($response, $templatePayload + ['host_id' => $hostId]); + return $this->json($response, $templatePayload); } - $value = $engine->host($hostId, 'GET', 'resources', $actor); + $hostId = (int) CloudAccess::instance($query['vm_id'], $actor)->host_id; + $engine = new CloudEngineClient(); $rescue = $engine->host($hostId, 'GET', 'rescue-templates', $actor); - // The engine resource response contains host pool/bridge names and - // root-pool filenames. The browser only needs the public catalog and - // rescue display names, so construct a fixed DTO instead of unsetting - // a few currently-known fields and accidentally exposing future ones. + // The rescue response can contain host paths or future internal fields. + // The browser only needs display names, so construct a fixed DTO instead + // of unsetting a few currently-known fields and exposing future ones. $public = $templatePayload; $public['rescue_templates'] = $this->publicRescueTemplates( $rescue['templates'] ?? [] ); - $public['host_id'] = $hostId; - if (is_int($value['storage_available_gib'] ?? null) - || is_float($value['storage_available_gib'] ?? null)) { - $capacity = (float) $value['storage_available_gib']; - if (is_finite($capacity) && $capacity >= 0 && $capacity <= 1048576) { - $public['storage_available_gib'] = $capacity; - } - } return $this->json($response, $public); } diff --git a/web/app/Controllers/CloudPageController.php b/web/app/Controllers/CloudPageController.php index e9cd3ed6..f950ffe1 100644 --- a/web/app/Controllers/CloudPageController.php +++ b/web/app/Controllers/CloudPageController.php @@ -85,31 +85,52 @@ final class CloudPageController { $actor = CloudAccess::actor(false); $user = $request->getAttribute('auth_user') ?? Auth::getUser(); - $plans = CloudDeploymentPageService::publicPagePlans(); - $regions = CloudDeploymentPageService::regions($plans); + $saleCatalog = CloudDeploymentPageService::saleCatalog(); + $regions = $saleCatalog['regions']; + $lines = $saleCatalog['lines']; + $offers = $saleCatalog['offers']; + $linesEnabled = $saleCatalog['lines_enabled'] === true; $catalog = CloudDeploymentPageService::templateCatalogForPage($actor); $templates = is_array($catalog['templates'] ?? null) ? $catalog['templates'] : []; $catalogUnavailable = ($catalog['catalog_unavailable'] ?? false) === true; $keys = $this->sshKeyOptions((int) $actor['user_id']); - $defaultHostId = $regions === [] ? 0 : (int) $regions[0]['host_id']; - $bootstrapRegions = array_map(static fn (array $region): array => - array_diff_key($region, ['plans' => true]), $regions); + $defaultRegionId = $regions === [] ? 0 : (int) $regions[0]['id']; + $defaultLineId = 0; + $firstLineId = 0; + foreach ($lines as $line) { + if ((int) $line['region_id'] !== $defaultRegionId) { + continue; + } + $firstLineId = $firstLineId ?: (int) $line['id']; + if ($line['is_default'] === true) { + $defaultLineId = (int) $line['id']; + break; + } + } + $defaultLineId = $defaultLineId ?: $firstLineId; $payload = [ 'user' => $this->userBootstrap($user, $actor), - 'plans' => $plans, - 'regions' => $bootstrapRegions, + 'regions' => $regions, + 'lines' => $lines, + 'offers' => $offers, + 'lines_enabled' => $linesEnabled, 'templates' => $templates, 'ssh_keys' => $keys, - 'default_host_id' => $defaultHostId, + 'default_region_id' => $defaultRegionId, + 'default_line_id' => $defaultLineId, 'catalog_unavailable' => $catalogUnavailable, ]; return $this->render($response, 'deploy', '部署实例', '', '', [ 'cloud_deploy_regions' => $regions, + 'cloud_deploy_lines' => $lines, + 'cloud_deploy_offers' => $offers, + 'cloud_deploy_lines_enabled' => $linesEnabled, 'cloud_deploy_template_groups' => CloudDeploymentPageService::templateGroups($templates), 'cloud_deploy_ssh_keys' => $keys, - 'cloud_deploy_default_host_id' => $defaultHostId, + 'cloud_deploy_default_region_id' => $defaultRegionId, + 'cloud_deploy_default_line_id' => $defaultLineId, 'cloud_deploy_catalog_unavailable' => $catalogUnavailable, 'cloud_deploy_bootstrap_json' => $this->safeJson($payload), ]); @@ -283,9 +304,13 @@ final class CloudPageController $smarty->assign('cloud_detail_has_ssh_keys', false); $smarty->assign('cloud_detail_no_ssh_keys', true); $smarty->assign('cloud_deploy_regions', []); + $smarty->assign('cloud_deploy_lines', []); + $smarty->assign('cloud_deploy_offers', []); + $smarty->assign('cloud_deploy_lines_enabled', false); $smarty->assign('cloud_deploy_template_groups', []); $smarty->assign('cloud_deploy_ssh_keys', []); - $smarty->assign('cloud_deploy_default_host_id', 0); + $smarty->assign('cloud_deploy_default_region_id', 0); + $smarty->assign('cloud_deploy_default_line_id', 0); $smarty->assign('cloud_deploy_catalog_unavailable', false); $smarty->assign('cloud_deploy_bootstrap_json', '{}'); $smarty->assign('cloud_ssh_keys', []); diff --git a/web/app/Services/Cloud/CloudDeploymentPageService.php b/web/app/Services/Cloud/CloudDeploymentPageService.php index b4b6740a..8bf5b607 100644 --- a/web/app/Services/Cloud/CloudDeploymentPageService.php +++ b/web/app/Services/Cloud/CloudDeploymentPageService.php @@ -2,11 +2,10 @@ namespace App\Services\Cloud; -use App\Models\CloudHost; +use App\Models\CloudOffer; use App\Models\CloudSSHKey; use App\Models\CloudTemplateRetirement; use App\Models\Configurations; -use App\Models\Shop; /** * Database-backed first-paint data for instance deployment and reinstall. @@ -17,80 +16,98 @@ use App\Models\Shop; */ final class CloudDeploymentPageService { + private const GIB = 1073741824; private const TEMPLATE_SNAPSHOT_KEY = 'cloud_public_template_catalog_v1'; private const TEMPLATE_SNAPSHOT_VERSION = 1; private const TEMPLATE_SNAPSHOT_REFRESH_SECONDS = 300; - public static function plans(): array + /** + * Build the public Region -> Line -> Offer sale catalog. + * + * Hosts are not part of the sale catalog. Pools are read only to validate + * the active offer chain, and neither placement identity enters this DTO. + */ + public static function saleCatalog(): array { - $plans = []; - $available = Shop::where('status', 1)->orderBy('sort')->orderBy('id')->get(); - $hostIds = $available->pluck('host_id')->map(static fn ($id): int => (int) $id) - ->filter(static fn (int $id): bool => $id > 0)->unique()->values()->all(); - $hosts = $hostIds === [] ? collect() : CloudHost::whereIn('id', $hostIds) - ->where('enabled', 1)->get(['id', 'name', 'country_code', 'region'])->keyBy('id'); - - foreach ($available as $plan) { - if ((int) $plan->stock === 0) { - continue; - } - $host = $hosts->get((int) $plan->host_id); - if ($host === null) { - continue; - } - $plans[] = [ - 'id' => (int) $plan->id, - 'name' => (string) $plan->name, - 'price' => (string) $plan->price, - 'cpu_cores' => (int) $plan->cpu_cores, - 'memory_mib' => (int) $plan->memory_mib, - 'bandwidth_mbps' => (int) $plan->bandwidth_mbps, - 'disk_gib' => (int) $plan->disk_gib, - 'validity_days' => (int) $plan->validity_days, - 'traffic_quota_bytes' => (int) $plan->traffic_quota_bytes, - 'traffic_gib' => $plan->trafficGiB(), - 'stock' => (int) $plan->stock, - 'host_id' => (int) $host->id, - 'host_name' => (string) $host->name, - 'country_code' => strtoupper(trim((string) ($host->country_code ?? ''))), - 'region' => trim((string) $host->region), - ]; + $linesEnabled = CloudNetworkLineFeature::enabled(); + $query = CloudOffer::query()->from('cloud_offers as offer') + ->join('shop as plan', 'plan.id', '=', 'offer.plan_id') + ->join('cloud_resource_pools as pool', 'pool.id', '=', 'offer.resource_pool_id') + ->join('cloud_network_lines as line', 'line.id', '=', 'pool.line_id') + ->join('cloud_regions as region', 'region.id', '=', 'line.region_id') + ->where('offer.status', 1) + ->where('offer.stock', '<>', 0) + ->where('offer.currency', 'USD') + ->where('plan.status', 1) + ->where('pool.status', 'active') + ->where('line.status', 'active') + ->where('region.status', 'active'); + if (!$linesEnabled) { + $query->where('line.is_default', 1); } - return $plans; - } - - /** Plans embedded in user HTML omit the administrator-facing host label. */ - public static function publicPagePlans(): array - { - return array_map(static function (array $plan): array { - unset($plan['host_name']); - return $plan; - }, self::plans()); - } + $rows = $query->orderByDesc('region.sort')->orderBy('region.id') + ->orderByDesc('line.sort')->orderBy('line.id') + ->orderByDesc('offer.sort')->orderBy('offer.id') + ->get([ + 'offer.id as offer_id', 'offer.name as offer_name', + 'offer.price as offer_price', + 'plan.cpu_cores', 'plan.memory_mib', 'plan.bandwidth_mbps', + 'plan.disk_gib', 'plan.validity_days', 'plan.traffic_quota_bytes', + 'line.id as line_id', 'line.name as line_name', 'line.is_default', + 'region.id as region_id', 'region.name as region_name', + 'region.country_code', + ]); - public static function regions(array $plans): array - { $regions = []; - foreach ($plans as $plan) { - $hostId = max(0, (int) ($plan['host_id'] ?? 0)); - if ($hostId === 0) { - continue; - } - if (!isset($regions[$hostId])) { - $countryCode = strtoupper(trim((string) ($plan['country_code'] ?? ''))); - $regions[$hostId] = [ - 'host_id' => $hostId, + $lines = []; + $offers = []; + foreach ($rows as $row) { + $regionId = (int) $row->region_id; + $lineId = (int) $row->line_id; + if (!isset($regions[$regionId])) { + $countryCode = strtoupper(trim((string) $row->country_code)); + $regions[$regionId] = [ + 'id' => $regionId, + 'name' => trim((string) $row->region_name), 'country_code' => $countryCode, 'flag' => self::countryFlag($countryCode), - 'region' => trim((string) ($plan['region'] ?? '')) ?: '地区未设置', - 'plans' => [], ]; } - $regions[$hostId]['plans'][] = $plan; + if (!isset($lines[$lineId])) { + $lines[$lineId] = [ + 'id' => $lineId, + 'region_id' => $regionId, + 'name' => trim((string) $row->line_name), + 'is_default' => (bool) $row->is_default, + ]; + } + $trafficBytes = max(0, (int) $row->traffic_quota_bytes); + $trafficGiB = intdiv($trafficBytes, self::GIB); + $offers[] = [ + 'id' => (int) $row->offer_id, + 'name' => trim((string) $row->offer_name), + 'price' => number_format((float) $row->offer_price, 2, '.', ''), + 'currency' => 'USD', + 'region_id' => $regionId, + 'line_id' => $lineId, + 'cpu_cores' => (int) $row->cpu_cores, + 'memory_mib' => (int) $row->memory_mib, + 'bandwidth_mbps' => (int) $row->bandwidth_mbps, + 'disk_gib' => (int) $row->disk_gib, + 'validity_days' => (int) $row->validity_days, + 'traffic_quota_bytes' => $trafficBytes, + 'traffic_gib' => $trafficGiB, + 'traffic_tib' => self::formatDecimalUnit($trafficGiB, 1024, 10), + ]; } - return array_values($regions); + return [ + 'lines_enabled' => $linesEnabled, + 'regions' => array_values($regions), + 'lines' => array_values($lines), + 'offers' => $offers, + ]; } public static function sshKeys(int $userId): array @@ -431,4 +448,11 @@ final class CloudDeploymentPageService return mb_chr(127397 + ord($countryCode[0]), 'UTF-8') . mb_chr(127397 + ord($countryCode[1]), 'UTF-8'); } + + private static function formatDecimalUnit(int $value, int $unit, int $precision): string + { + $formatted = number_format($value / $unit, $precision, '.', ''); + $formatted = rtrim(rtrim($formatted, '0'), '.'); + return $formatted === '' ? '0' : $formatted; + } } diff --git a/web/config/routes_cloud.php b/web/config/routes_cloud.php index b9ed4f7b..c57bb0d2 100644 --- a/web/config/routes_cloud.php +++ b/web/config/routes_cloud.php @@ -4,7 +4,7 @@ $app->get('/api/v1/session', 'App\Controllers\CloudApiController:session'); $app->post('/api/internal/cloud/session-introspection', 'App\Controllers\CloudInternalController:introspection'); $app->group('/api/v1', function () { $this->get('/announcements', 'App\Controllers\AnnouncementController:index'); - $this->get('/plans', 'App\Controllers\CloudApiController:plans'); + $this->get('/catalog', 'App\Controllers\CloudApiController:catalog'); $this->map(['GET', 'POST'], '/orders', 'App\Controllers\CloudApiController:orders'); $this->get('/orders/by-request/{key:[A-Za-z0-9_.-]+}', 'App\Controllers\CloudApiController:orderRequest'); diff --git a/web/public/cloud/runtime.js b/web/public/cloud/runtime.js index 3bed4d54..7dd77784 100644 --- a/web/public/cloud/runtime.js +++ b/web/public/cloud/runtime.js @@ -3,7 +3,7 @@ import { toast } from './toast.js?v=2026100102'; // PHP owns authentication, authorisation, ownership and purchasing. No engine // address, token, host credential or unrestricted create API exists in this UI. const byId = (id) => document.getElementById(id); -const state = { csrfToken: '', userId: '', username: '', admin: false, vms: [], plans: [], regions: [], sshKeys: [], templates: [], templateCatalogUnavailable: false, resources: null, selectedRegionHostId: '', view: 'list', selectedVmId: null, detailTab: 'operations', metricsRange: '24h', metricsPayload: null, metricsRequest: null, metricsPollTimer: null, metricsResizeTimer: null, trafficDailyPayload: null, trafficDailyVmId: '', trafficDailyRequest: null, trafficDailyResizeTimer: null, trafficDailyLoadedAt: 0, credentialPassword: '', credentialVisible: false, credentialTimer: null, reinstallPassword: '', reinstallPasswordDismissed: false, rfb: null, consoleToken: 0, loadingVMs: false, selectedKeys: { create: '', reinstall: '' }, resourceController: null, mutationBusy: false, provisionIdempotency: '', provisionFingerprint: '', rescueActive: false, rescueStaged: false }; +const state = { csrfToken: '', userId: '', username: '', admin: false, vms: [], offers: [], regions: [], lines: [], linesEnabled: false, sshKeys: [], templates: [], templateCatalogUnavailable: false, resources: null, selectedRegionId: '', selectedLineId: '', view: 'list', selectedVmId: null, detailTab: 'operations', metricsRange: '24h', metricsPayload: null, metricsRequest: null, metricsPollTimer: null, metricsResizeTimer: null, trafficDailyPayload: null, trafficDailyVmId: '', trafficDailyRequest: null, trafficDailyResizeTimer: null, trafficDailyLoadedAt: 0, credentialPassword: '', credentialVisible: false, credentialTimer: null, reinstallPassword: '', reinstallPasswordDismissed: false, rfb: null, consoleToken: 0, loadingVMs: false, selectedKeys: { create: '', reinstall: '' }, resourceController: null, mutationBusy: false, provisionIdempotency: '', provisionFingerprint: '', rescueActive: false, rescueStaged: false }; // Keep the historical storage key so an interrupted deployment made just // before an online update can still reconcile to the same opening invoice. const PROVISION_INVOICE_STORAGE_PREFIX = 'virt-cloud:pending-order:'; @@ -16,7 +16,7 @@ const CLOUD_PATHS = Object.freeze({ const vmPagePath = (id, child = '') => `${CLOUD_PATHS.instances}/${encodeURIComponent(String(id))}${child ? `/${child}` : ''}`; const navigate = (path) => location.assign(path); const text = (id, value) => { byId(id).textContent = value ?? '—'; }; -const items = (payload) => Array.isArray(payload) ? payload : Array.isArray(payload?.items) ? payload.items : Array.isArray(payload?.plans) ? payload.plans : Array.isArray(payload?.templates) ? payload.templates : Array.isArray(payload?.keys) ? payload.keys : Array.isArray(payload?.vms) ? payload.vms : []; +const items = (payload) => Array.isArray(payload) ? payload : Array.isArray(payload?.items) ? payload.items : Array.isArray(payload?.templates) ? payload.templates : Array.isArray(payload?.keys) ? payload.keys : Array.isArray(payload?.vms) ? payload.vms : []; function readBootstrap(id) { const source = byId(id); if (!source) return null; @@ -392,26 +392,60 @@ function flagForCountry(code) { return String.fromCodePoint(...Array.from(normalized, character => 127397 + character.charCodeAt(0))); } function saleRegions() { - const regions = new Map(); + const regions = []; + const seen = new Set(); for (const region of state.regions) { - const hostId = String(region?.host_id ?? region?.id ?? ''); - if (!/^\d+$/.test(hostId) || regions.has(hostId)) continue; - regions.set(hostId, { - hostId, + const id = String(region?.id ?? ''); + if (!/^[1-9]\d*$/.test(id) || seen.has(id)) continue; + seen.add(id); + regions.push({ + id, countryCode: String(region.country_code || '').trim().toUpperCase(), - region: String(region.region || region.name || '地区未设置').trim() || '地区未设置', + name: String(region.name || '地区未设置').trim() || '地区未设置', }); } - for (const plan of state.plans) { - const hostId = String(plan?.host_id || ''); - if (!/^\d+$/.test(hostId) || regions.has(hostId)) continue; - regions.set(hostId, { - hostId, - countryCode: String(plan.country_code || '').trim().toUpperCase(), - region: String(plan.region || '地区未设置').trim() || '地区未设置', + return regions; +} +function saleLines(regionId = state.selectedRegionId) { + const lines = []; + const seen = new Set(); + for (const line of state.lines) { + const id = String(line?.id ?? ''); + if (!/^[1-9]\d*$/.test(id) || seen.has(id) + || String(line?.region_id ?? '') !== String(regionId) + || (!state.linesEnabled && line?.is_default !== true)) continue; + seen.add(id); + lines.push({ + id, + regionId: String(line.region_id), + name: String(line.name || '线路未设置').trim() || '线路未设置', + isDefault: line.is_default === true, }); } - return Array.from(regions.values()); + return lines; +} +function saleOffers(regionId = state.selectedRegionId, lineId = state.selectedLineId) { + return state.offers.filter(offer => /^[1-9]\d*$/.test(String(offer?.id ?? '')) + && String(offer?.region_id ?? '') === String(regionId) + && String(offer?.line_id ?? '') === String(lineId) + && String(offer?.currency || '').toUpperCase() === 'USD'); +} +function defaultSaleLine(lines) { return lines.find(line => line.isDefault) || lines[0] || null; } +function applySaleCatalog(catalog) { + state.regions = bootstrapItems(catalog, 'regions'); + state.lines = bootstrapItems(catalog, 'lines'); + state.offers = bootstrapItems(catalog, 'offers'); + state.linesEnabled = catalog?.lines_enabled === true; + const regions = saleRegions(); + const requestedRegionId = String(catalog?.default_region_id ?? ''); + state.selectedRegionId = regions.some(region => region.id === requestedRegionId) + ? requestedRegionId : (regions[0]?.id || ''); + const lines = saleLines(state.selectedRegionId); + const requestedLineId = String(catalog?.default_line_id ?? ''); + state.selectedLineId = lines.some(line => line.id === requestedLineId) + ? requestedLineId : (defaultSaleLine(lines)?.id || ''); + byId('vm-region').value = state.selectedRegionId; + byId('vm-line').value = state.selectedLineId; } function setDeploymentStepEnabled(id, enabled) { const step = byId(id); @@ -420,36 +454,35 @@ function setDeploymentStepEnabled(id, enabled) { step.setAttribute('aria-disabled', String(!enabled)); } function updateCreateAvailability() { - const plan = state.plans.find(item => String(item.id) === byId('vm-plan')?.value); - const validHost = plan && String(plan.host_id) === state.selectedRegionHostId; + const offer = saleOffers().find(item => String(item.id) === byId('vm-offer')?.value); const validMedia = Boolean(byId('vm-template')?.value); - if (byId('create-submit')) byId('create-submit').disabled = state.mutationBusy || !validHost || !validMedia; + if (byId('create-submit')) byId('create-submit').disabled = state.mutationBusy || !offer || !validMedia; } function strongPassword(value) { return !value || (value.length >= 12 && value.length <= 128 && /^[\x21-\x7e]+$/.test(value) && /[A-Z]/.test(value) && /[a-z]/.test(value) && /[0-9]/.test(value) && /[^A-Za-z0-9]/.test(value)); } function formatUsd(value) { const amount = Number(value); - if (!Number.isFinite(amount) || amount < 0) return '$—'; - return `$${amount.toLocaleString('en-US', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`; + if (!Number.isFinite(amount) || amount < 0) return '$— USD'; + return `$${amount.toFixed(2)} USD`; } function formatMemoryGiB(memoryMib) { const amount = Number(memoryMib); if (!Number.isFinite(amount) || amount < 0) return '— GB'; return `${(amount / 1024).toLocaleString('en-US', { maximumFractionDigits: 1 })} GB`; } -function formatTrafficTiBFromGiB(trafficGiB) { - const amount = Number(trafficGiB); +function formatTrafficTiB(trafficTiB) { + const amount = Number(trafficTiB); if (!Number.isFinite(amount) || amount < 0) return '—'; if (amount === 0) return '不限'; - return `${(amount / 1024).toLocaleString('en-US', { maximumFractionDigits: 10 })} TB`; + return `${amount.toFixed(10).replace(/\.?0+$/, '')} TB`; } -function planValidityDays(plan) { return firstNumber(plan?.validity_days, plan?.service_days, plan?.period_days); } -function planTrafficBytes(plan) { - const gib = firstNumber(plan?.traffic_gib); - return firstNumber(plan?.traffic_quota_bytes, gib === null ? null : gib * 1024 ** 3); +function offerValidityDays(offer) { return firstNumber(offer?.validity_days, offer?.service_days, offer?.period_days); } +function offerTrafficBytes(offer) { + const gib = firstNumber(offer?.traffic_gib); + return firstNumber(offer?.traffic_quota_bytes, gib === null ? null : gib * 1024 ** 3); } -function planBillingLabel(plan) { - const days = planValidityDays(plan); - const traffic = planTrafficBytes(plan); +function offerBillingLabel(offer) { + const days = offerValidityDays(offer); + const traffic = offerTrafficBytes(offer); return `${days === null ? '账期未提供' : `${Math.floor(days)} 天/期`} · ${traffic === null ? '每期流量未提供' : `每期流量 ${formatTrafficQuota(traffic)}`}`; } function resetInstallChoices() { @@ -474,109 +507,151 @@ function renderRegionPicker() { const cards = saleRegions().map(region => { const button = makeElement('button', 'region-option'); button.type = 'button'; - button.dataset.hostId = region.hostId; - button.setAttribute('aria-pressed', String(state.selectedRegionHostId === region.hostId)); - button.setAttribute('aria-label', `选择地区 ${region.region}`); - button.append(makeElement('span', 'region-flag', flagForCountry(region.countryCode)), makeElement('strong', '', region.region)); - button.addEventListener('click', () => void selectRegion(region.hostId)); + button.dataset.regionId = region.id; + button.setAttribute('aria-pressed', String(state.selectedRegionId === region.id)); + button.setAttribute('aria-label', `选择地区 ${region.name}`); + button.append(makeElement('span', 'region-flag', flagForCountry(region.countryCode)), makeElement('strong', '', region.name)); + button.addEventListener('click', () => void selectRegion(region.id)); return button; }); if (!cards.length) cards.push(makeElement('p', 'template-catalog-empty', '暂无可部署地区,请联系管理员配置在售商品。')); container.replaceChildren(...cards); - byId('vm-region-host').value = state.selectedRegionHostId; -} -function renderPlanPicker() { - const container = byId('vm-plan-picker'); - const selectedPlanId = byId('vm-plan').value; - const plans = state.plans.filter(plan => String(plan.host_id) === state.selectedRegionHostId); - if (!plans.length) { - container.replaceChildren(makeElement('p', 'template-catalog-empty', '当前地区暂无可用实例规格。')); + byId('vm-region').value = state.selectedRegionId; +} +function renderLinePicker() { + const container = byId('vm-line-picker'); + if (!container) return; + const cards = saleLines().map(line => { + const button = makeElement('button', 'line-option'); + button.type = 'button'; + button.dataset.lineId = line.id; + button.setAttribute('aria-pressed', String(state.selectedLineId === line.id)); + button.setAttribute('aria-label', `选择线路 ${line.name}`); + button.append(makeElement('strong', '', line.name)); + button.addEventListener('click', () => void selectLine(line.id)); + return button; + }); + if (!cards.length) cards.push(makeElement('p', 'template-catalog-empty', '当前地区暂无可用线路。')); + container.replaceChildren(...cards); +} +function renderOfferPicker() { + const container = byId('vm-offer-picker'); + const selectedOfferId = byId('vm-offer').value; + const offers = saleOffers(); + if (!offers.length) { + container.replaceChildren(makeElement('p', 'template-catalog-empty', '当前选择暂无可用实例规格。')); return; } - const header = makeElement('div', 'plan-table-head'); - ['名称', 'CPU', '内存', '硬盘', '每月流量', '价格'].forEach(label => header.append(makeElement('span', '', label))); - const rows = plans.map(plan => { - const button = makeElement('button', 'plan-option'); - const memory = formatMemoryGiB(plan.memory_mib); - const traffic = formatTrafficTiBFromGiB(plan.traffic_gib); - const price = formatUsd(plan.price); + const header = makeElement('div', 'offer-table-head'); + ['名称', 'CPU', '内存', '硬盘', '每期流量', '价格'].forEach(label => header.append(makeElement('span', '', label))); + const rows = offers.map(offer => { + const button = makeElement('button', 'offer-option'); + const memory = formatMemoryGiB(offer.memory_mib); + const traffic = formatTrafficTiB(offer.traffic_tib); + const price = formatUsd(offer.price); button.type = 'button'; - button.dataset.planId = String(plan.id); - button.setAttribute('aria-pressed', String(selectedPlanId === String(plan.id))); - button.setAttribute('aria-label', `选择实例规格 ${plan.name},${plan.cpu_cores} vCPU,内存 ${memory},硬盘 ${plan.disk_gib} GB,每月流量 ${traffic},价格 ${price}`); + button.dataset.offerId = String(offer.id); + button.setAttribute('aria-pressed', String(selectedOfferId === String(offer.id))); + button.setAttribute('aria-label', `选择实例规格 ${offer.name},${offer.cpu_cores} vCPU,内存 ${memory},硬盘 ${offer.disk_gib} GB,每期流量 ${traffic},价格 ${price}`); button.append( - makeElement('strong', 'plan-option-name', plan.name), - makeElement('span', 'plan-option-value', `${plan.cpu_cores} vCPU`), - makeElement('span', 'plan-option-value', memory), - makeElement('span', 'plan-option-value', `${plan.disk_gib} GB`), - makeElement('span', 'plan-option-value', traffic), - makeElement('strong', 'plan-option-price', price), + makeElement('strong', 'offer-option-name', offer.name), + makeElement('span', 'offer-option-value', `${offer.cpu_cores} vCPU`), + makeElement('span', 'offer-option-value', memory), + makeElement('span', 'offer-option-value', `${offer.disk_gib} GB`), + makeElement('span', 'offer-option-value', traffic), + makeElement('strong', 'offer-option-price', price), ); - button.addEventListener('click', () => void selectPlan(String(plan.id))); + button.addEventListener('click', () => void selectOffer(String(offer.id))); return button; }); container.replaceChildren(header, ...rows); } -async function selectRegion(hostId) { +async function selectRegion(regionId) { if (state.mutationBusy) return; - const normalized = String(hostId || ''); - if (!saleRegions().some(region => region.hostId === normalized)) return; - if (state.selectedRegionHostId === normalized && byId('vm-plan').value) return; - state.selectedRegionHostId = normalized; - byId('vm-plan').value = ''; + const normalized = String(regionId || ''); + if (!saleRegions().some(region => region.id === normalized)) return; + if (state.selectedRegionId === normalized) return; + state.selectedRegionId = normalized; + state.selectedLineId = defaultSaleLine(saleLines(normalized))?.id || ''; + byId('vm-region').value = state.selectedRegionId; + byId('vm-line').value = state.selectedLineId; + byId('vm-offer').value = ''; renderRegionPicker(); - renderPlanPicker(); - setDeploymentStepEnabled('vm-plan-step', true); + renderLinePicker(); + renderOfferPicker(); + setDeploymentStepEnabled('vm-line-step', state.linesEnabled); + setDeploymentStepEnabled('vm-offer-step', Boolean(state.selectedLineId)); + showError('create-error', ''); + updateCreateAvailability(); +} +async function selectLine(lineId) { + if (state.mutationBusy) return; + const line = saleLines().find(item => item.id === String(lineId)); + if (!line || state.selectedLineId === line.id) return; + state.selectedLineId = line.id; + byId('vm-line').value = line.id; + byId('vm-offer').value = ''; + byId('vm-line-picker')?.querySelectorAll('.line-option').forEach(button => { + button.setAttribute('aria-pressed', String(button.dataset.lineId === line.id)); + }); + renderOfferPicker(); + setDeploymentStepEnabled('vm-offer-step', true); showError('create-error', ''); updateCreateAvailability(); } -async function selectPlan(planId) { +async function selectOffer(offerId) { if (state.mutationBusy) return; - 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); - byId('vm-plan-picker').querySelectorAll('.plan-option').forEach(button => { - button.setAttribute('aria-pressed', String(button.dataset.planId === String(plan.id))); + const offer = saleOffers().find(item => String(item.id) === String(offerId)); + if (!offer) return; + byId('vm-offer').value = String(offer.id); + byId('vm-offer-picker').querySelectorAll('.offer-option').forEach(button => { + button.setAttribute('aria-pressed', String(button.dataset.offerId === String(offer.id))); }); showError('create-error', ''); updateCreateAvailability(); } async function openCreate(bootstrap = null) { state.view = 'create'; state.selectedVmId = null; showError('create-error', ''); - byId('vm-plan').value = ''; - if (bootstrap && Array.isArray(bootstrap.plans) && Array.isArray(bootstrap.templates)) { - state.regions = bootstrapItems(bootstrap, 'regions'); - state.plans = bootstrapItems(bootstrap, 'plans'); - if (!state.plans.length) state.plans = state.regions.flatMap(region => Array.isArray(region?.plans) ? region.plans : []); + byId('vm-offer').value = ''; + if (bootstrap && Array.isArray(bootstrap.offers) && Array.isArray(bootstrap.regions) + && Array.isArray(bootstrap.lines) && Array.isArray(bootstrap.templates)) { + applySaleCatalog(bootstrap); state.templates = bootstrapItems(bootstrap, 'templates', 'cloud_templates'); state.templateCatalogUnavailable = bootstrap.catalog_unavailable === true; state.sshKeys = bootstrapItems(bootstrap, 'ssh_keys', 'keys'); state.resources = { templates: state.templates }; state.selectedKeys.create = ''; - const regions = saleRegions(); - const requestedDefault = bootstrap.default_host_id ?? bootstrap.default_region?.host_id ?? bootstrap.default_region; - const requestedHostId = String(requestedDefault ?? ''); - state.selectedRegionHostId = regions.some(region => region.hostId === requestedHostId) - ? requestedHostId : (regions[0]?.hostId || ''); - byId('vm-region-host').value = state.selectedRegionHostId; renderRegionPicker(); - renderPlanPicker(); + renderLinePicker(); + renderOfferPicker(); renderTemplateCatalog('vm-template'); renderKeyCards('create'); byId('vm-template').disabled = !state.templates.some(item => item?.id); byId('vm-name').disabled = false; byId('vm-root-password').disabled = false; - setDeploymentStepEnabled('vm-plan-step', Boolean(state.selectedRegionHostId)); + setDeploymentStepEnabled('vm-line-step', state.linesEnabled && Boolean(state.selectedRegionId)); + setDeploymentStepEnabled('vm-offer-step', Boolean(state.selectedLineId)); setDeploymentStepEnabled('vm-source-step', true); setDeploymentStepEnabled('vm-config-step', true); updateCreateAvailability(); return; } - state.regions = []; - state.selectedRegionHostId = ''; byId('vm-region-host').value = ''; - setDeploymentStepEnabled('vm-plan-step', false); resetInstallChoices(); + state.regions = []; state.lines = []; state.offers = []; state.linesEnabled = false; + state.selectedRegionId = ''; state.selectedLineId = ''; + byId('vm-region').value = ''; byId('vm-line').value = ''; + setDeploymentStepEnabled('vm-line-step', false); + setDeploymentStepEnabled('vm-offer-step', false); + resetInstallChoices(); const results = await Promise.allSettled([ - api('/api/v1/plans').then(plans => { state.plans = items(plans); renderRegionPicker(); }), + api('/api/v1/catalog').then(catalog => { + applySaleCatalog(catalog); + renderRegionPicker(); + renderLinePicker(); + renderOfferPicker(); + setDeploymentStepEnabled('vm-line-step', state.linesEnabled && Boolean(state.selectedRegionId)); + setDeploymentStepEnabled('vm-offer-step', Boolean(state.selectedLineId)); + updateCreateAvailability(); + }), loadKeys(), loadGlobalTemplates(), ]); @@ -646,16 +721,16 @@ async function buy(event) { const password = byId('vm-root-password').value; if (!strongPassword(password)) return showError('create-error', '密码需为 12 至 128 位英文可打印字符且不能包含空格,并包含大写、小写、数字和符号。'); if (!byId('vm-template').value) return showError('create-error', '请选择系统镜像版本。'); - if (!byId('vm-plan').value) return showError('create-error', '请先选择可用套餐。'); - const selectedPlan = state.plans.find(plan => String(plan.id) === byId('vm-plan').value); - if (!selectedPlan || String(selectedPlan.host_id) !== state.selectedRegionHostId) return showError('create-error', '地区与实例规格不匹配,请重新选择。'); - const purchaseSummary = selectedPlan ? `${formatUsd(selectedPlan.price)},${planBillingLabel(selectedPlan)}` : '所选套餐'; + if (!byId('vm-offer').value) return showError('create-error', '请先选择可用实例规格。'); + const selectedOffer = saleOffers().find(offer => String(offer.id) === byId('vm-offer').value); + if (!selectedOffer) return showError('create-error', '地区、线路与实例规格不匹配,请重新选择。'); + const purchaseSummary = `${formatUsd(selectedOffer.price)},${offerBillingLabel(selectedOffer)}`; if (!confirm(`确认创建此实例?将先生成 ${purchaseSummary} 的开通账单,支付完成后才会开始创建。`)) return; state.mutationBusy = true; const formBody = byId('create-form')?.querySelector('.workspace-form-body'); if (formBody) { formBody.inert = true; formBody.setAttribute('aria-busy', 'true'); } byId('create-submit').disabled = true; showError('create-error', ''); - const body = { plan_id: Number(byId('vm-plan').value), name: byId('vm-name').value.trim(), source: 'cloud', template_id: byId('vm-template').value }; + const body = { offer_id: Number(byId('vm-offer').value), name: byId('vm-name').value.trim(), source: 'cloud', template_id: byId('vm-template').value }; if (state.selectedKeys.create) body.guest_ssh_key_id = state.selectedKeys.create; if (password) body.root_password = password; try { diff --git a/web/public/cloud/styles.css b/web/public/cloud/styles.css index 8bea679e..0055a522 100644 --- a/web/public/cloud/styles.css +++ b/web/public/cloud/styles.css @@ -201,7 +201,7 @@ tbody tr:hover{background:#fcfefe} #rescue-template-file{height:auto;padding:10px 12px} @media(max-width:510px){.rescue-template-cards{grid-template-columns:repeat(2,minmax(0,1fr))}.rescue-actions .button{width:100%}.rescue-template-row{align-items:flex-start;flex-direction:column}} -/* Region-first instance deployment and account-owned installation media. */ +/* Region/line/offer instance deployment and account-owned installation media. */ .deploy-flow{display:grid;gap:0} .deployment-step{min-width:0;padding:0 0 29px;margin:0 0 27px;border-bottom:1px solid #e8eef2;transition:opacity .18s} .deployment-step:last-of-type{margin-bottom:0;border-bottom:0} @@ -215,18 +215,23 @@ tbody tr:hover{background:#fcfefe} .region-option[aria-pressed="true"]{border-color:#35afb7;background:#eaf8f8;box-shadow:0 0 0 2px rgba(20,166,175,.09)} .region-option strong{min-width:0;font-size:13px;line-height:1.5;overflow-wrap:anywhere} .region-flag{display:grid;place-items:center;flex:none;width:38px;height:38px;border-radius:10px;background:#f0f4f7;font-size:25px;line-height:1} -.plan-picker{display:grid;min-width:0;overflow:hidden;border:1px solid #dce7ec;border-radius:11px;background:#fff} -.plan-table-head,.plan-option{display:grid;grid-template-columns:minmax(150px,1.35fr) repeat(5,minmax(92px,1fr));align-items:center;column-gap:18px} -.plan-table-head{padding:13px 48px 13px 19px;border-bottom:1px solid #e5ecef;background:#f8fafb;color:#8292a3;font-size:10px;font-weight:800} -.plan-option{position:relative;width:100%;min-width:0;min-height:72px;padding:15px 48px 15px 19px;border:0;border-bottom:1px solid #e7edef;border-radius:0;background:#fff;color:#4e6577;text-align:left} -.plan-option:last-of-type{border-bottom:0;border-bottom-right-radius:10px;border-bottom-left-radius:10px} -.plan-option:hover{background:#f7fbfc} -.plan-option:focus-visible{z-index:2;outline:3px solid rgba(18,166,176,.22);outline-offset:-3px} -.plan-option[aria-pressed="true"]{z-index:1;background:#eef9fa;box-shadow:inset 0 0 0 2px #2eabb4;color:#30485d} -.plan-option[aria-pressed="true"]::after{content:"✓";position:absolute;top:8px;right:10px;display:grid;place-items:center;width:21px;height:21px;border-radius:50%;background:#18a6b0;color:#fff;font-size:12px;font-weight:900} -.plan-option-name,.plan-option-price{min-width:0;color:#273d52;font-size:12px;overflow-wrap:anywhere} -.plan-option-price{color:#0d929d;font-size:13px} -.plan-option-value{min-width:0;font-size:11px;font-weight:700;white-space:nowrap} +.line-picker{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px} +.line-option{min-width:0;min-height:58px;padding:13px 16px;border:1px solid #dce7ec;border-radius:11px;background:#fff;color:#30485d;text-align:left} +.line-option:hover{border-color:#87cdd1;background:#f8fcfc} +.line-option[aria-pressed="true"]{border-color:#35afb7;background:#eaf8f8;box-shadow:0 0 0 2px rgba(20,166,175,.09)} +.line-option strong{font-size:13px;line-height:1.5;overflow-wrap:anywhere} +.offer-picker{display:grid;min-width:0;overflow:hidden;border:1px solid #dce7ec;border-radius:11px;background:#fff} +.offer-table-head,.offer-option{display:grid;grid-template-columns:minmax(150px,1.35fr) repeat(5,minmax(92px,1fr));align-items:center;column-gap:18px} +.offer-table-head{padding:13px 48px 13px 19px;border-bottom:1px solid #e5ecef;background:#f8fafb;color:#8292a3;font-size:10px;font-weight:800} +.offer-option{position:relative;width:100%;min-width:0;min-height:72px;padding:15px 48px 15px 19px;border:0;border-bottom:1px solid #e7edef;border-radius:0;background:#fff;color:#4e6577;text-align:left} +.offer-option:last-of-type{border-bottom:0;border-bottom-right-radius:10px;border-bottom-left-radius:10px} +.offer-option:hover{background:#f7fbfc} +.offer-option:focus-visible{z-index:2;outline:3px solid rgba(18,166,176,.22);outline-offset:-3px} +.offer-option[aria-pressed="true"]{z-index:1;background:#eef9fa;box-shadow:inset 0 0 0 2px #2eabb4;color:#30485d} +.offer-option[aria-pressed="true"]::after{content:"✓";position:absolute;top:8px;right:10px;display:grid;place-items:center;width:21px;height:21px;border-radius:50%;background:#18a6b0;color:#fff;font-size:12px;font-weight:900} +.offer-option-name,.offer-option-price{min-width:0;color:#273d52;font-size:12px;overflow-wrap:anywhere} +.offer-option-price{color:#0d929d;font-size:13px} +.offer-option-value{min-width:0;font-size:11px;font-weight:700;white-space:nowrap} /* Keep every user-facing button control free of browser or hover underlines. Plain content and navigation links intentionally keep their own styling. */ body[data-cloud-page] :is(button, [role="button"], .button, .row-button, .icon-button, .vu-btn, .vu-icon-btn), @@ -259,18 +264,18 @@ body.vu-body .ssh-key-picker-manage:hover { .user-isos-grid .host-test-status{margin:16px 0 0} @media(max-width:960px){.user-isos-grid{grid-template-columns:1fr}} @media(max-width:740px){ - .region-picker{grid-template-columns:repeat(2,minmax(0,1fr))} - .plan-table-head{display:none} - .plan-option:first-of-type{border-top-left-radius:10px;border-top-right-radius:10px} - .plan-option{grid-template-columns:repeat(2,minmax(0,1fr));gap:13px 18px;min-height:0;padding:18px 45px 18px 18px} - .plan-option-name{grid-column:1/-1;font-size:13px} - .plan-option-value,.plan-option-price{display:grid;gap:3px;white-space:normal} - .plan-option-value::before,.plan-option-price::before{color:#91a0ae;font-size:9px;font-weight:800} - .plan-option>:nth-child(2)::before{content:"CPU"} - .plan-option>:nth-child(3)::before{content:"内存"} - .plan-option>:nth-child(4)::before{content:"硬盘"} - .plan-option>:nth-child(5)::before{content:"每月流量"} - .plan-option>:nth-child(6)::before{content:"价格"} + .region-picker,.line-picker{grid-template-columns:repeat(2,minmax(0,1fr))} + .offer-table-head{display:none} + .offer-option:first-of-type{border-top-left-radius:10px;border-top-right-radius:10px} + .offer-option{grid-template-columns:repeat(2,minmax(0,1fr));gap:13px 18px;min-height:0;padding:18px 45px 18px 18px} + .offer-option-name{grid-column:1/-1;font-size:13px} + .offer-option-value,.offer-option-price{display:grid;gap:3px;white-space:normal} + .offer-option-value::before,.offer-option-price::before{color:#91a0ae;font-size:9px;font-weight:800} + .offer-option>:nth-child(2)::before{content:"CPU"} + .offer-option>:nth-child(3)::before{content:"内存"} + .offer-option>:nth-child(4)::before{content:"硬盘"} + .offer-option>:nth-child(5)::before{content:"每期流量"} + .offer-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{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:none}.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%}} +@media(max-width:510px){.deployment-step{padding-bottom:23px;margin-bottom:22px}.deployment-step-heading{margin-bottom:16px}.region-picker,.line-picker{grid-template-columns:1fr}.region-option{min-height:66px}.line-option{min-height:54px}.offer-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}.offer-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}.offer-option[aria-pressed="true"]{box-shadow:none}.offer-option[aria-pressed="true"]::after{content:"✓";top:13px;right:14px;width:22px;height:22px;border:1.5px solid #18a6b0;background:#18a6b0;color:#fff}.offer-option-name{grid-column:1/3;grid-row:1;align-self:center;font-size:14px}.offer-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}.offer-option-price::before{display:none;content:none}.offer-option-value{display:grid;grid-row:2;gap:4px;white-space:normal}.offer-option-value::before{color:#718599;font-size:9px;font-weight:800;white-space:nowrap}.offer-option>:nth-child(2){grid-column:1}.offer-option>:nth-child(3){grid-column:2}.offer-option>:nth-child(4){grid-column:3}.offer-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%}} .vm-state-sync{display:block;margin-top:4px;color:#8b9aaa;font-size:10px;line-height:1.35;white-space:nowrap}.vm-state-sync.stale{color:#b98129}.vm-state-sync.offline{color:#bd5b63}.vm-detail-state-stack{display:flex;flex-direction:column;align-items:flex-end;gap:3px}.vm-detail-state-stack .vm-state-sync{margin-top:0} diff --git a/web/resources/views/venix/cloud/pages/deploy.tpl b/web/resources/views/venix/cloud/pages/deploy.tpl index 27fefe5f..8e808c9a 100644 --- a/web/resources/views/venix/cloud/pages/deploy.tpl +++ b/web/resources/views/venix/cloud/pages/deploy.tpl @@ -6,48 +6,61 @@
暂无可部署地区,请联系管理员配置在售商品。
{else} {foreach $cloud_deploy_regions as $region} -当前地区暂无可用线路。
{/if} +当前地区暂无可用实例规格。
{/if} + {if !$default_line_has_offers}当前选择暂无可用实例规格。
{/if}{if !empty($cloud_deploy_catalog_unavailable)}系统镜像目录暂时无法读取,请稍后刷新。{else}暂无可用云镜像,请联系管理员导入模板。{/if}
@@ -70,7 +83,7 @@暂无公钥,可先到“公钥管理”添加。不选公钥也会生成强密码。
{else}{foreach $cloud_deploy_ssh_keys as $key}