main #2

Merged
jingrow merged 250 commits from main into v1 2026-01-13 22:45:50 +08:00
Showing only changes of commit 0803e58dcd - Show all commits

View File

@ -32,31 +32,24 @@
{{ getRegionName(region) }}
</option>
</select>
<!-- 调试信息 -->
<div v-if="regions.length === 0" class="mt-2 text-sm text-gray-500">
正在加载区域列表...
</div>
<div v-if="regions.length > 0" class="mt-2 text-sm text-gray-500">
已加载 {{ regions.length }} 个区域
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">套餐选择</label>
<select v-model="selectedPlanId" class="w-full border rounded px-3 py-2" required>
<option value="">请选择套餐</option>
<option v-for="plan in plans" :key="plan.plan_id" :value="plan.plan_id">
{{ getPlanDisplayName(plan) }}
<label class="block text-sm font-medium text-gray-700 mb-2">镜像选择Jsite服务器推荐选择Ubuntu-22.04</label>
<select v-model="selectedImageId" class="w-full border rounded px-3 py-2" required @change="onImageChange">
<option value="">请选择镜像</option>
<option v-for="image in images" :key="getImageId(image)" :value="getImageId(image)">
{{ getImageDisplayName(image) }}
</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">镜像选择</label>
<select v-model="selectedImageId" class="w-full border rounded px-3 py-2" required>
<option value="">请选择镜像</option>
<option v-for="image in images" :key="getImageId(image)" :value="getImageId(image)">
{{ getImageDisplayName(image) }}
<label class="block text-sm font-medium text-gray-700 mb-2">套餐选择</label>
<select v-model="selectedPlanId" class="w-full border rounded px-3 py-2" required :disabled="!selectedImageId">
<option value="">请选择套餐</option>
<option v-for="plan in filteredPlans" :key="plan.plan_id" :value="plan.plan_id">
{{ getPlanDisplayName(plan) }}
</option>
</select>
</div>
@ -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_platformJSON
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() {