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() {