wuzilong há 7 meses atrás
pai
commit
bd07a19572

BIN
backend-client.zip


+ 54 - 0
backend-client/app/api/v1/router.py

@@ -1645,6 +1645,29 @@ async def save_buff_selection_config(request: Request, db: Session = Depends(get
                 config_json = None
         if not isinstance(config_json, dict):
             return JSONResponse(status_code=200, content=create_client_response(400, "config_json 格式错误", None))
+
+        # 获取系统配置限制
+        heartbeat_service = HeartbeatService(db)
+        client_config = heartbeat_service.get_client_config()
+        max_worker_count = client_config.get('buff_sweep_max_worker_count', 32)
+        min_steam_card_ratio = client_config.get('buff_steam_card_ratio_min', 4)
+
+        # 验证扫货线程数
+        sweep_process_count = config_json.get('sweepProcessCount', 0)
+        if sweep_process_count > max_worker_count:
+            return JSONResponse(
+                status_code=200,
+                content=create_client_response(400, f"扫货线程数不能超过系统配置的最大值 {max_worker_count}", None)
+            )
+
+        # 验证Steam卡价比例
+        steam_card_ratio = config_json.get('steamCardRatio', 0)
+        if steam_card_ratio < min_steam_card_ratio:
+            return JSONResponse(
+                status_code=200,
+                content=create_client_response(400, f"Steam卡价比例不能小于系统配置的最小值 {min_steam_card_ratio}", None)
+            )
+
         is_default = body.get("is_default", True)
         if not isinstance(is_default, bool):
             is_default = is_default in (1, "1", True, "true")
@@ -1904,6 +1927,37 @@ async def start_buff_selection(
             if default_cfg:
                 config_id = default_cfg.id
 
+        # 获取配置并验证系统限制
+        heartbeat_service = HeartbeatService(db)
+        client_config = heartbeat_service.get_client_config()
+        max_worker_count = client_config.get('buff_sweep_max_worker_count', 32)
+        min_steam_card_ratio = client_config.get('buff_steam_card_ratio_min', 4)
+
+        if config_id:
+            cfg_record = db.query(BuffSelectionConfig).filter(
+                BuffSelectionConfig.id == config_id,
+                BuffSelectionConfig.user_id == user_id,
+                BuffSelectionConfig.is_deleted == False,
+            ).first()
+            if cfg_record and cfg_record.config_json:
+                try:
+                    cfg_json = json.loads(cfg_record.config_json)
+                    sweep_process_count = cfg_json.get('sweepProcessCount', 0)
+                    steam_card_ratio = cfg_json.get('steamCardRatio', 0)
+
+                    if sweep_process_count > max_worker_count:
+                        return JSONResponse(
+                            status_code=200,
+                            content=create_client_response(403, f"扫货线程数不能超过系统配置的最大值 {max_worker_count}", None)
+                        )
+                    if steam_card_ratio < min_steam_card_ratio:
+                        return JSONResponse(
+                            status_code=200,
+                            content=create_client_response(403, f"Steam卡价比例不能小于系统配置的最小值 {min_steam_card_ratio}", None)
+                        )
+                except (json.JSONDecodeError, TypeError):
+                    pass
+
         req = BuffSelectionRequest(
             user_id=user_id,
             config_id=config_id,

+ 4 - 0
backend-client/app/services/heartbeat_service.py

@@ -158,6 +158,10 @@ class HeartbeatService:
             # 客户端:每个选品饰品扫描+并发阶段结束后,再处理下一饰品前暂停秒数(非「每页 render」)
             'buff_sweep_pause_after_render_seconds': ('int', 0),
             'buff_sweep_proxy_rotate_every_items': ('int', 0),
+            # 新增:扫货线程数最大数量
+            'buff_sweep_max_worker_count': ('int', 32),
+            # 新增:Steam卡价比例最小值
+            'buff_steam_card_ratio_min': ('int', 4),
         }
 
         def parse_config_value(raw_value: Any, config_type: str) -> Any:

BIN
client-tauri/dist-devtools/steamSH.exe


+ 11 - 0
client-tauri/src-tauri/src/heartbeat.rs

@@ -79,6 +79,10 @@ pub struct HeartbeatConfig {
     pub buff_sweep_proxy_rotate_every_items: u64,
     pub buff_sweep_proxy_retry_times: u64,
     pub buff_sweep_proxy_retry_interval_ms: u64,
+    // 新增:扫货线程数最大数量
+    pub buff_sweep_max_worker_count: u32,
+    // 新增:Steam卡价比例最小值
+    pub buff_steam_card_ratio_min: u32,
 }
 
 impl Default for HeartbeatConfig {
@@ -96,6 +100,8 @@ impl Default for HeartbeatConfig {
             buff_sweep_proxy_rotate_every_items: 0, // 默认不按 render 次数轮换代理
             buff_sweep_proxy_retry_times: 1,
             buff_sweep_proxy_retry_interval_ms: 800,
+            buff_sweep_max_worker_count: 32, // 默认最大32线程
+            buff_steam_card_ratio_min: 4, // 默认最小Steam卡价比4
         }
     }
 }
@@ -362,6 +368,9 @@ async fn execute_heartbeat_inner(
         let buff_sweep_proxy_retry_times = config_json_u64(c, "buff_sweep_proxy_retry_times", 1);
         let buff_sweep_proxy_retry_interval_ms =
             config_json_u64(c, "buff_sweep_proxy_retry_interval_ms", 800);
+        // 新增:扫货线程数最大数量和Steam卡价比例最小值
+        let buff_sweep_max_worker_count = config_json_u64(c, "buff_sweep_max_worker_count", 32) as u32;
+        let buff_steam_card_ratio_min = config_json_u64(c, "buff_steam_card_ratio_min", 4) as u32;
         // 密钥轮换配置
         let key_interval_min = c.get("key_rotation_check_interval_minutes")
             .and_then(|v| v.as_i64().or_else(|| v.as_u64().map(|u| u as i64)))
@@ -386,6 +395,8 @@ async fn execute_heartbeat_inner(
             buff_sweep_proxy_rotate_every_items,
             buff_sweep_proxy_retry_times,
             buff_sweep_proxy_retry_interval_ms,
+            buff_sweep_max_worker_count,
+            buff_steam_card_ratio_min,
         })
     });
 

+ 13 - 2
client-tauri/src/stores/configStore.ts

@@ -40,6 +40,11 @@ export interface ClientConfig {
   // BUFF扫货节流暂停
   buff_sweep_pause_every_items: number
   buff_sweep_pause_seconds: number
+
+  // 新增:扫货线程数最大数量
+  buff_sweep_max_worker_count: number
+  // 新增:Steam卡价比例最小值
+  buff_steam_card_ratio_min: number
 }
 
 export const useConfigStore = defineStore('config', () => {
@@ -67,7 +72,10 @@ export const useConfigStore = defineStore('config', () => {
     max_key_rotation_failures: 20,
 
     buff_sweep_pause_every_items: 0,
-    buff_sweep_pause_seconds: 0
+    buff_sweep_pause_seconds: 0,
+
+    buff_sweep_max_worker_count: 32,
+    buff_steam_card_ratio_min: 4
   })
 
   const lastSyncTime = ref<number>(0)
@@ -182,7 +190,10 @@ export const useConfigStore = defineStore('config', () => {
       max_key_rotation_failures: 20,
 
       buff_sweep_pause_every_items: 0,
-      buff_sweep_pause_seconds: 0
+      buff_sweep_pause_seconds: 0,
+
+      buff_sweep_max_worker_count: 32,
+      buff_steam_card_ratio_min: 4
     }
     lastSyncTime.value = 0
     error.value = null

+ 153 - 18
client-tauri/src/views/BuffSelectionView.vue

@@ -168,7 +168,7 @@
                   <a-input-number
                     v-model:value="form.sweepProcessCount"
                     :min="1"
-                    :max="32"
+                    :max="configStore.config.buff_sweep_max_worker_count ?? 32"
                     :precision="0"
                     placeholder="并行路数"
                     class="input-narrow"
@@ -285,6 +285,18 @@
         <div class="section-header section-header-with-action">
           <span class="section-icon">📋</span>
           <span class="section-title">选品数据</span>
+          <div class="selection-search-bar">
+            <a-input
+              v-model:value="selectionSearchKeyword"
+              placeholder="按饰品ID或名称搜索"
+              class="selection-search-input"
+              allow-clear
+              @pressEnter="onSelectionSearch"
+            />
+            <span v-if="selectionSearchKeyword && filteredSelectionList.length !== selectionList.length" class="selection-search-hint">
+              匹配 {{ filteredSelectionList.length }} / {{ selectionList.length }}
+            </span>
+          </div>
           <div class="section-actions">
             <a-button
               type="link"
@@ -312,8 +324,8 @@
         <div class="section-body table-wrap">
           <a-table
             :columns="columns"
-            :data-source="selectionList"
-            :pagination="{ ...tablePagination, total: selectionList.length }"
+            :data-source="filteredSelectionList"
+            :pagination="{ ...tablePagination, total: filteredSelectionList.length }"
             :loading="tableLoading"
             :row-key="rowKey"
             :row-selection="{ selectedRowKeys: selectionSelectedRowKeys, onChange: onSelectionListSelectionChange }"
@@ -360,8 +372,10 @@
       <!-- 第五部分:扫货成功数据展示 -->
       <div class="section table-section">
         <div class="section-header section-header-with-action">
-          <span class="section-icon">🧾</span>
-          <span class="section-title">扫货成功数据</span>
+          <div class="section-header-left">
+            <span class="section-icon">🧾</span>
+            <span class="section-title">扫货成功数据</span>
+          </div>
           <div class="section-actions">
             <a-button type="link" size="small" class="btn-log" @click="openSweepLogModal">
               扫货日志查看
@@ -419,17 +433,21 @@
       <!-- 第六部分:已绑定 Steam 账号 -->
       <div class="section table-section">
         <div class="section-header section-header-with-action">
-          <span class="section-icon">🎮</span>
-          <span class="section-title">已绑定 Steam 账号</span>
-          <a-button
-            type="link"
-            size="small"
-            :loading="boundSteamRefreshingAll"
-            :disabled="boundSteamLoading || !boundSteamAccounts.length || boundSteamRefreshingAll"
-            @click="handleRefreshAllBoundSteamBalances"
-          >
-            立即刷新全部余额
-          </a-button>
+          <div class="section-header-left">
+            <span class="section-icon">🎮</span>
+            <span class="section-title">已绑定 Steam 账号</span>
+          </div>
+          <div class="section-actions">
+            <a-button
+              type="link"
+              size="small"
+              :loading="boundSteamRefreshingAll"
+              :disabled="boundSteamLoading || !boundSteamAccounts.length || boundSteamRefreshingAll"
+              @click="handleRefreshAllBoundSteamBalances"
+            >
+              立即刷新全部余额
+            </a-button>
+          </div>
         </div>
         <div class="section-body table-wrap">
           <a-table
@@ -660,12 +678,14 @@ import { invoke } from '@tauri-apps/api/tauri'
 import { secureApiClient } from '../utils/secureApiClient'
 import { useAuthStore } from '../stores/authStore'
 import { useBuffSweepStore } from '../stores/buffSweepStore'
+import { useConfigStore } from '../stores/configStore'
 import { formatDate } from '../utils/formatDate'
 
 const STORAGE_KEY = 'buff_selection_conditions'
 const DEBOUNCE_SAVE_MS = 600
 const authStore = useAuthStore()
 const buffSweepStore = useBuffSweepStore()
+const configStore = useConfigStore()
 const emit = defineEmits<{
   (
     e: 'status-change',
@@ -917,6 +937,22 @@ const conditionsSummary = computed(() => {
 const running = computed(() => buffSweepStore.selectionRunning)
 const tableLoading = ref(false)
 const selectionList = ref<any[]>([])
+const selectionSearchKeyword = ref('')
+const filteredSelectionList = computed(() => {
+  if (!selectionSearchKeyword.value.trim()) {
+    return selectionList.value
+  }
+  const keyword = selectionSearchKeyword.value.trim().toLowerCase()
+  return selectionList.value.filter((item) => {
+    const idMatch = String(item.goods_id || item.id || '').toLowerCase().includes(keyword)
+    const nameMatch = (item.goods_name || item.name || '').toLowerCase().includes(keyword)
+    return idMatch || nameMatch
+  })
+})
+const onSelectionSearch = () => {
+  // 搜索时回到第一页
+  tablePagination.current = 1
+}
 const selectionSelectedRowKeys = ref<(string | number)[]>([])
 const selectionDeleting = ref(false)
 const batchImportLoading = ref(false)
@@ -964,6 +1000,8 @@ function notifyBuffStatusChange() {
 const selectionListPollTimer = ref<ReturnType<typeof setInterval> | null>(null)
 const sweepPollTimer = ref<ReturnType<typeof setInterval> | null>(null)
 const sweepPollConsecutiveErrors = ref(0)  // 扫货轮询连续错误计数
+// 扫货成功列表定时刷新:每分钟刷新一次
+const sweepResultRefreshTimer = ref<ReturnType<typeof setInterval> | null>(null)
 const autoSelectionTimer = ref<ReturnType<typeof setInterval> | null>(null)
 /**
  * 允许自动扫货的选品请求单白名单:
@@ -1313,7 +1351,8 @@ function applyConfigToForm(data: Record<string, any>) {
   if (data.sweepAssistantLevel) form.sweepAssistantLevel = data.sweepAssistantLevel
   if (data.sweepProcessCount != null && Number.isFinite(Number(data.sweepProcessCount))) {
     const n = Math.floor(Number(data.sweepProcessCount))
-    form.sweepProcessCount = n >= 1 ? Math.min(32, n) : 3
+    const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
+    form.sweepProcessCount = n >= 1 ? Math.min(maxWorkerCount, n) : 3
   }
 }
 
@@ -1407,6 +1446,17 @@ async function saveConditions() {
     message.warning('Steam 卡价比例不能小于 4,请重新填写')
     return
   }
+  // 验证系统配置限制
+  const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
+  const minSteamCardRatio = configStore.config.buff_steam_card_ratio_min ?? 4
+  if (form.sweepProcessCount > maxWorkerCount) {
+    message.error(`保存失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
+    return
+  }
+  if (form.steamCardRatio < minSteamCardRatio) {
+    message.error(`保存失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
+    return
+  }
   await doSaveConditions(false)
 }
 
@@ -2318,6 +2368,21 @@ function stopSweepPoll() {
   sweepPollConsecutiveErrors.value = 0
 }
 
+// 扫货成功列表定时刷新:每分钟刷新一次
+function startSweepResultRefreshTimer() {
+  if (sweepResultRefreshTimer.value) return
+  sweepResultRefreshTimer.value = setInterval(() => {
+    fetchSweepResult(false)
+  }, 60000)  // 60秒 = 1分钟
+}
+
+function stopSweepResultRefreshTimer() {
+  if (sweepResultRefreshTimer.value) {
+    clearInterval(sweepResultRefreshTimer.value)
+    sweepResultRefreshTimer.value = null
+  }
+}
+
 const SWEEP_POLL_MAX_CONSECUTIVE_ERRORS = 10  // 连续 10 次错误后停止轮询(约 30 秒)
 
 /**
@@ -2519,6 +2584,25 @@ async function handleStart(source: 'manual' | 'auto' = 'manual') {
     if (source === 'manual') message.warning('请先填写利润率')
     return
   }
+  // 验证系统配置限制
+  const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
+  const minSteamCardRatio = configStore.config.buff_steam_card_ratio_min ?? 4
+  if (form.sweepProcessCount > maxWorkerCount) {
+    if (source === 'manual') {
+      message.error(`选品失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
+    } else {
+      message.error(`自动选品失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
+    }
+    return
+  }
+  if (form.steamCardRatio < minSteamCardRatio) {
+    if (source === 'manual') {
+      message.error(`选品失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
+    } else {
+      message.error(`自动选品失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
+    }
+    return
+  }
   const sessionId = authStore.sessionId
   const machineCode = authStore.machineCode
   if (!sessionId || !machineCode) {
@@ -2738,6 +2822,23 @@ async function handleStartSweep(isAuto: boolean, sourceSelectionRequestId?: numb
     if (!isAuto) message.warning('暂无可扫货的选品数据')
     return
   }
+  // 验证系统配置限制
+  const maxWorkerCount = configStore.config.buff_sweep_max_worker_count ?? 32
+  const minSteamCardRatio = configStore.config.buff_steam_card_ratio_min ?? 4
+  if (form.sweepProcessCount > maxWorkerCount) {
+    if (!isAuto) {
+      message.error(`扫货启动失败:扫货线程数不能超过系统配置的最大值 ${maxWorkerCount}`)
+    }
+    buffSweepStore.sweepRunning = false
+    return
+  }
+  if (form.steamCardRatio != null && form.steamCardRatio < minSteamCardRatio) {
+    if (!isAuto) {
+      message.error(`扫货启动失败:Steam卡价比例不能小于系统配置的最小值 ${minSteamCardRatio}`)
+    }
+    buffSweepStore.sweepRunning = false
+    return
+  }
   await prepareBuffEnvironmentBeforeStart('sweep', { manualHint: !isAuto })
   if (isAuto) {
     const requestId = sourceSelectionRequestId ?? null
@@ -2784,7 +2885,7 @@ async function handleStartSweep(isAuto: boolean, sourceSelectionRequestId?: numb
     if (sweepRid != null && selRid != null) {
       const wc =
         form.sweepProcessCount != null && Number.isFinite(Number(form.sweepProcessCount))
-          ? Math.max(1, Math.min(32, Math.floor(Number(form.sweepProcessCount))))
+          ? Math.max(1, Math.min(maxWorkerCount, Math.floor(Number(form.sweepProcessCount))))
           : 3
       const spawned = await secureApiClient.spawnBuffSweepLocalRunner(
         sessionId,
@@ -3064,6 +3165,7 @@ onMounted(async () => {
   initialLoadDone.value = true
   startAutoSelectionScheduler()
   scheduleDeferredBoundSteamLoad()
+  startSweepResultRefreshTimer()
 })
 
 onUnmounted(() => {
@@ -3073,6 +3175,7 @@ onUnmounted(() => {
   stopSelectionLogPoll()
   stopSweepPoll()
   stopSweepLogPoll()
+  stopSweepResultRefreshTimer()
   stopBoundSteamBalancePoll()
   if (deferredBoundSteamLoadTimer.value) {
     clearTimeout(deferredBoundSteamLoadTimer.value)
@@ -3291,12 +3394,44 @@ onUnmounted(() => {
 
 .section-header-with-action {
   justify-content: space-between;
+  gap: 12px;
+}
+
+.section-header-left {
+  display: flex;
+  align-items: center;
+  gap: 8px;
+}
+
+.selection-search-bar {
+  flex: 1;
+  display: flex;
+  align-items: center;
+  gap: 8px;
+  min-width: 0;
+}
+
+.selection-search-input {
+  max-width: 260px;
+  line-height: 1;
+}
+
+.selection-search-input :deep(.ant-input) {
+  height: 30px;
+  line-height: 30px;
+}
+
+.selection-search-hint {
+  font-size: 12px;
+  color: #999;
+  white-space: nowrap;
 }
 
 .section-actions {
   display: inline-flex;
   align-items: center;
   gap: 4px;
+  flex-shrink: 0;
 }
 
 .section-header-with-action .btn-log {

BIN
steam-client/steamAPI/bin/Debug/net8.0/SteamAuth.dll


BIN
steam-client/steamAPI/bin/Debug/net8.0/SteamAuth.pdb


BIN
steam-client/steamAPI/bin/Debug/net8.0/steamAPI.dll


BIN
steam-client/steamAPI/bin/Debug/net8.0/steamAPI.exe


BIN
steam-client/steamAPI/bin/Debug/net8.0/steamAPI.pdb


BIN
steam-client/steamAPI/obj/Debug/net8.0/apphost.exe


BIN
steam-client/steamAPI/obj/Debug/net8.0/ref/steamAPI.dll


BIN
steam-client/steamAPI/obj/Debug/net8.0/refint/steamAPI.dll


+ 1 - 1
steam-client/steamAPI/obj/Debug/net8.0/steamAPI.AssemblyInfo.cs

@@ -14,7 +14,7 @@ using System.Reflection;
 [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
 [assembly: System.Reflection.AssemblyDescriptionAttribute("Steam login verification local service")]
 [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
-[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+dd48fb73e62437a58b7685ebc403b4ffc368cfab")]
+[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6f9bf91f154d6299c9b3c0492453d9862caabb43")]
 [assembly: System.Reflection.AssemblyProductAttribute("steamAPI")]
 [assembly: System.Reflection.AssemblyTitleAttribute("steamAPI")]
 [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

+ 1 - 1
steam-client/steamAPI/obj/Debug/net8.0/steamAPI.AssemblyInfoInputs.cache

@@ -1 +1 @@
-e4e889e2cc277d465062b8d3a3af7327d0f476a085999fd9ac3d005e0bf5bf51
+467069cf03790acf445d98d1844c126622ad49640ae35559b6849d74866e520b

BIN
steam-client/steamAPI/obj/Debug/net8.0/steamAPI.csproj.AssemblyReference.cache


BIN
steam-client/steamAPI/obj/Debug/net8.0/steamAPI.dll


BIN
steam-client/steamAPI/obj/Debug/net8.0/steamAPI.pdb