1
1
forked from wangqifan/calc

优化实例搜索功能,调整CPU核心数和内存容量的最大值,确保输入更灵活,同时限制返回结果数量至40条。

This commit is contained in:
wangqifan 2025-08-29 18:42:01 +08:00
parent b1d50572df
commit a4e6da603e
2 changed files with 9 additions and 6 deletions

View File

@ -71,11 +71,11 @@ async def search_instances_v2(
query += " AND area_en = %s"
params.append(region_name)
if cpu_cores:
if cpu_cores > 0:
query += " AND vcpu = %s"
params.append(cpu_cores)
if memory_gb:
if memory_gb > 0:
query += " AND memory = %s"
params.append(memory_gb)
@ -88,6 +88,9 @@ async def search_instances_v2(
cursor.execute(query, params)
results = cursor.fetchall()
if len(results) >= 40:
results = results[0:40]
# 处理结果
instances = []
for row in results:

View File

@ -16,7 +16,7 @@
<el-input-number
v-model="form.cpu_cores"
:min="0"
:max="64"
:max="9999"
:step="1"
placeholder="所需CPU核心数"
class="full-width">
@ -29,7 +29,7 @@
<el-input-number
v-model="form.memory_gb"
:min="0"
:max="256"
:max="99999"
:step="0.5"
placeholder="所需内存容量(GB)"
class="full-width">
@ -388,8 +388,8 @@ export default {
data() {
return {
form: {
cpu_cores: null,
memory_gb: null,
cpu_cores: 0,
memory_gb: 0,
disk_gb: 30, // 30GB
region: 'us-east-1',
disk_type: 'gp3',