feat: 虚拟机流量精细化控制接入(接口新增,待联调)
Build and Deploy Vue3 / build (push) Successful in 1m37s
Build and Deploy Vue3 / deploy (push) Successful in 1m16s

1. userVm.js/kvmService.js 新增 traffic_policy 系列 API(GET/update/add_fixed/add_temporary)
2. UserVmList.vue/VmManage.vue 创建表单新增 traffic_max、traffic_exhausted_rx/tx_mbps 三个可选字段
3. UserVmDetail.vue/VmDetail.vue 修改带宽表单新增耗尽限速字段,并各增加流量策略 Tab(展示+修改策略+增加固定/临时流量)

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
shiran
2026-05-08 15:10:44 +08:00
parent 475c62aefc
commit c43d1978a8
6 changed files with 366 additions and 9 deletions
+15 -1
View File
@@ -176,6 +176,16 @@
<el-form-item label="上行带宽">
<el-input-number v-model="createForm.tx_bandwidth" :min="0" controls-position="right" /><span class="tk-res-unit">Mbps</span>
</el-form-item>
<el-form-item label="流量上限">
<el-input-number v-model="createForm.traffic_max" :min="0" controls-position="right" /><span class="tk-res-unit">MB</span>
<div style="font-size:12px;color:#909399;margin-top:2px">0 表示不限流量</div>
</el-form-item>
<el-form-item label="耗尽下行限速">
<el-input-number v-model="createForm.traffic_exhausted_rx_mbps" :min="0" :precision="2" controls-position="right" /><span class="tk-res-unit">Mbps0 不限)</span>
</el-form-item>
<el-form-item label="耗尽上行限速">
<el-input-number v-model="createForm.traffic_exhausted_tx_mbps" :min="0" :precision="2" controls-position="right" /><span class="tk-res-unit">Mbps0 不限)</span>
</el-form-item>
</div>
<el-form-item label="额外数据卷">
<div style="display:flex;align-items:center;gap:6px">
@@ -616,7 +626,8 @@ const createForm = reactive({
name: '', host_id: null, image_id: 0, vcpu: 0, memory: 0,
system_size: 0, rx_bandwidth: 0, tx_bandwidth: 0, data_volume_size: 0,
host_group_id: null, user_id: 0, ipv4_num: 0, ipv6_num: 0, network_ids: [],
_imageName: '', _groupName: '', _userName: ''
_imageName: '', _groupName: '', _userName: '',
traffic_max: 0, traffic_exhausted_rx_mbps: 0, traffic_exhausted_tx_mbps: 0
})
const createRules = {
@@ -802,6 +813,9 @@ const submitCreate = () => {
if (createForm.ipv4_num) fd.append('ipv4_num', createForm.ipv4_num)
if (createForm.ipv6_num) fd.append('ipv6_num', createForm.ipv6_num)
} else createForm.network_ids.forEach(id => fd.append('network_ids', id))
if (createForm.traffic_max > 0) fd.append('traffic_max', createForm.traffic_max)
if (createForm.traffic_exhausted_rx_mbps > 0) fd.append('traffic_exhausted_rx_mbps', createForm.traffic_exhausted_rx_mbps)
if (createForm.traffic_exhausted_tx_mbps > 0) fd.append('traffic_exhausted_tx_mbps', createForm.traffic_exhausted_tx_mbps)
const res = await createVm(fd)
if (res?.data?.code === 200) { ElMessage.success('创建成功'); createDialogVisible.value = false; loadList() }
else ElMessage.error(extractApiError(res?.data, '创建失败'))