From 0803e58dcd5c41f08f2efd915592cfb9f4af94f5 Mon Sep 17 00:00:00 2001 From: jingrow Date: Tue, 29 Jul 2025 17:20:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=A5=97=E9=A4=90=E8=AE=A1?= =?UTF-8?q?=E5=88=92=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=85=88=E9=80=89=E6=8B=A9=E9=95=9C=E5=83=8F=E5=86=8D=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E9=95=9C=E5=83=8F=E6=98=BE=E7=A4=BA=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E7=9A=84=E5=A5=97=E9=A4=90=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/src2/pages/NewJsiteServer.vue | 74 ++++++++++++++++++------- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/dashboard/src2/pages/NewJsiteServer.vue b/dashboard/src2/pages/NewJsiteServer.vue index a109de6..1704900 100644 --- a/dashboard/src2/pages/NewJsiteServer.vue +++ b/dashboard/src2/pages/NewJsiteServer.vue @@ -32,31 +32,24 @@ {{ getRegionName(region) }} - -
- 正在加载区域列表... -
-
- 已加载 {{ regions.length }} 个区域 -
- - + +
- - + +
@@ -533,6 +526,40 @@ export default { }, }, + computed: { + filteredPlans() { + // 如果没有选择镜像,返回空数组 + if (!this.selectedImageId) { + return []; + } + + // 获取选择的镜像信息 + const selectedImage = this.images.find(img => this.getImageId(img) === this.selectedImageId); + if (!selectedImage) { + return []; + } + + // 获取镜像平台信息 + const imagePlatform = selectedImage.platform || ''; + + // 根据镜像平台过滤套餐 + return this.plans.filter(plan => { + const supportPlatform = plan.support_platform; + if (!supportPlatform) { + return true; // 如果没有support_platform信息,默认显示 + } + + try { + // 解析support_platform字段(JSON字符串格式) + const platforms = JSON.parse(supportPlatform); + return platforms.includes(imagePlatform); + } catch (e) { + // 如果解析失败,尝试字符串匹配 + return supportPlatform.includes(imagePlatform); + } + }); + } + }, beforeUnmount() { this.stopPaymentCheck(); }, @@ -547,13 +574,22 @@ export default { this.images = []; if (this.selectedRegionId) { - await this.$resources.aliyunPlans.submit({ region_id: this.selectedRegionId }); + // 只加载镜像,套餐将在选择镜像后加载 await this.$resources.aliyunImages.submit({ region_id: this.selectedRegionId, image_type: 'system' // 明确指定镜像类型 }); } }, + async onImageChange() { + this.selectedPlanId = ''; + this.plans = []; + if (this.selectedImageId) { + await this.$resources.aliyunPlans.submit({ + region_id: this.selectedRegionId + }); + } + }, async createInstance() { if (!this.selectedRegionId || !this.selectedPlanId || !this.selectedImageId) { this.error = '请选择完整配置'; @@ -675,7 +711,7 @@ export default { return `${typePrefix}${cpu}核/${memoryDisplay}/${disk}GB/${bandwidthDisplay}/${publicIpNum}个公网IP - ¥${price}/月`; }, getSelectedPlanPrice() { - const selectedPlan = this.plans.find(plan => plan.plan_id === this.selectedPlanId); + const selectedPlan = this.filteredPlans.find(plan => plan.plan_id === this.selectedPlanId); return selectedPlan ? (selectedPlan.origin_price || 0) : 0; }, getTotalAmount() {