T-580 精简设置页更新执行配置

This commit is contained in:
chengma
2026-07-10 10:12:15 +08:00
parent c078e68e98
commit e70e831afa
12 changed files with 259 additions and 287 deletions
+8 -37
View File
@@ -259,11 +259,6 @@ class ApplyTab(QWidget):
self._set_status(content_error.replace("\n", " "))
return
dry_run = bool(dry_run)
safety_error = self._update_safety_error(tasks, dry_run=dry_run)
if safety_error:
self._show_update_safety_error(safety_error)
self._set_status(safety_error.replace("\n", " "))
return
answer = QMessageBox.question(
self,
"确认检查本轮更新" if dry_run else "确认开始更新",
@@ -279,10 +274,8 @@ class ApplyTab(QWidget):
tasks,
db_path=self.db_path,
config=self.config,
close_success_tab=bool(update_cfg.get("close_success_tab", False)),
dry_run=dry_run,
update_mode=update_mode,
parallel_accounts=bool(update_cfg.get("parallel_accounts", False)),
max_parallel_accounts=max(
1,
int(update_cfg.get("max_parallel_accounts", 1) or 1),
@@ -492,12 +485,15 @@ class ApplyTab(QWidget):
update_mode = self._current_update_mode()
update_mode_text = self._update_mode_label(update_mode)
cover_warning = "\n本轮将更新线上封面,请确认封面内容无误。" if appconfig.update_mode_includes_cover(update_mode) else ""
close_text = "是" if update_cfg.get("close_success_tab") else "否"
batch_size = max(1, int(update_cfg.get("max_items_per_run", 1) or 1))
batch_count = (len(tasks) + batch_size - 1) // batch_size if tasks else 0
max_parallel_accounts = max(
1,
int(update_cfg.get("max_parallel_accounts", 1) or 1),
)
parallel_text = (
f"开启,最多 {update_cfg.get('max_parallel_accounts', 1)} 个账号"
if update_cfg.get("parallel_accounts")
f"最多 {max_parallel_accounts} 个账号"
if max_parallel_accounts > 1
else "关闭"
)
intro = (
@@ -514,9 +510,9 @@ class ApplyTab(QWidget):
+ f"更新内容:{update_mode_text}\n"
+ f"任务数:{len(tasks)}\n"
+ f"预计批次:{batch_count}\n\n"
+ "安全设置:"
+ "执行设置:"
+ f"每批最大更新条数={batch_size},"
+ f"成功后关闭新页={close_text},"
+ "成功后自动关闭程序新开编辑页,"
+ f"多账号并行={parallel_text}\n\n"
+ cover_warning
+ ("\n\n" if cover_warning else "")
@@ -527,30 +523,6 @@ class ApplyTab(QWidget):
)
)
def _update_safety_error(self, tasks, dry_run=False):
update_cfg = self._shopee_update_config()
if dry_run:
return None
if not update_cfg.get("allow_real_submit", False):
return (
"设置未开启「允许真实提交线上商品」,已阻止本次更新。\n"
"请到⑤设置 > 蝦皮更新安全开启该开关后再开始更新。"
)
return None
def _show_update_safety_error(self, message):
box = QMessageBox(self)
box.setIcon(QMessageBox.Warning)
box.setWindowTitle("更新安全开关")
box.setText(str(message))
settings_button = None
if self.open_settings_callback is not None:
settings_button = box.addButton("前往设置", QMessageBox.ActionRole)
box.addButton(QMessageBox.Ok)
box.exec()
if settings_button is not None and box.clickedButton() is settings_button:
self.open_settings_callback()
def _shopee_update_config(self):
return appconfig.shopee_update_config(self.config)
@@ -584,7 +556,6 @@ class ApplyTab(QWidget):
update_mode = self._current_update_mode()
update_cfg = self._shopee_update_config()
update_cfg["update_mode"] = update_mode
update_cfg["allow_cover_update"] = appconfig.update_mode_includes_cover(update_mode)
payload = {
key: value
for key, value in self.config.items()
+15 -50
View File
@@ -161,9 +161,6 @@ class SettingsTab(QWidget):
for resolution in self.RESOLUTION_ITEMS:
self.resolution_combo.addItem(resolution, resolution)
self.response_timeout_label = QLabel("")
self.jpg_quality_spin = QSpinBox()
self.jpg_quality_spin.setObjectName("jpgQualitySpin")
self.jpg_quality_spin.setRange(1, 100)
self.chrome_path_edit = QLineEdit()
self.chrome_path_edit.setObjectName("chromePathEdit")
self.chrome_path_browse_button = QPushButton("选择...")
@@ -204,32 +201,17 @@ class SettingsTab(QWidget):
self.unsaved_changes_label.setObjectName("settingsUnsavedChangesLabel")
self.unsaved_changes_label.setStyleSheet("color: #bc4c00; font-weight: 600;")
self.unsaved_changes_label.setVisible(False)
self.allow_real_submit_checkbox = QCheckBox("允许真实提交线上商品")
self.allow_real_submit_checkbox.setObjectName("allowRealSubmitCheckbox")
self.allow_cover_update_checkbox = QCheckBox("允许更新封面")
self.allow_cover_update_checkbox.setObjectName("allowCoverUpdateCheckbox")
self.allow_cover_update_checkbox.setVisible(False)
self.max_items_per_run_spin = QSpinBox()
self.max_items_per_run_spin.setObjectName("maxItemsPerRunSpin")
self.max_items_per_run_spin.setRange(1, 9999)
self.max_items_per_run_spin.setToolTip("作为每批最大更新条数;正式更新会分批处理当前筛选全部可更新记录。")
self.close_success_tab_checkbox = QCheckBox("成功后关闭本次新开编辑页")
self.close_success_tab_checkbox.setObjectName("closeSuccessTabCheckbox")
self.parallel_accounts_checkbox = QCheckBox("多账号并行更新")
self.parallel_accounts_checkbox.setObjectName("parallelAccountsCheckbox")
self.max_parallel_accounts_spin = QSpinBox()
self.max_parallel_accounts_spin.setObjectName("maxParallelAccountsSpin")
self.max_parallel_accounts_spin.setRange(1, 16)
self.max_parallel_accounts_label = QLabel("最大并行账号数")
self.parallel_accounts_group = QWidget()
self.parallel_accounts_group.setObjectName("parallelAccountsGroup")
parallel_accounts_layout = QHBoxLayout(self.parallel_accounts_group)
parallel_accounts_layout.setContentsMargins(0, 0, 0, 0)
parallel_accounts_layout.setSpacing(12)
parallel_accounts_layout.addWidget(self.parallel_accounts_checkbox)
parallel_accounts_layout.addWidget(self.max_parallel_accounts_label)
parallel_accounts_layout.addWidget(self.max_parallel_accounts_spin)
parallel_accounts_layout.addStretch(1)
self.max_parallel_accounts_spin.setRange(
appconfig.SHOPEE_PARALLEL_ACCOUNTS_MIN,
appconfig.SHOPEE_PARALLEL_ACCOUNTS_MAX,
)
self.max_parallel_accounts_spin.setToolTip("1=逐个更新,不并行;大于1时按账号并行更新,最多同时5个账号。")
model_picker_layout = QHBoxLayout()
model_picker_layout.addWidget(self.model_combo, 1)
@@ -268,7 +250,6 @@ class SettingsTab(QWidget):
("失败重试次数", self.retry_spin),
("分辨率", self.resolution_combo),
("返回超时", self.response_timeout_label),
("jpg质量", self.jpg_quality_spin),
]
)
@@ -285,7 +266,7 @@ class SettingsTab(QWidget):
("Chrome路径", self.chrome_path_widget, True),
("默认调试端口", self.default_debug_port_spin),
("调试端口范围", port_range_widget),
("CDP就绪超时(秒)", self.cdp_ready_timeout_spin),
("Chrome 就绪超时(秒)", self.cdp_ready_timeout_spin),
]
)
self.infrastructure_form_layout = path_form
@@ -293,9 +274,7 @@ class SettingsTab(QWidget):
self.shopee_update_form_layout = self._three_column_form(
[
("每批最大更新条数", self.max_items_per_run_spin),
("", self.allow_real_submit_checkbox),
("", self.close_success_tab_checkbox),
("", self.parallel_accounts_group, 2),
("同时更新蝦皮账号", self.max_parallel_accounts_spin),
]
)
@@ -357,7 +336,7 @@ class SettingsTab(QWidget):
"settingsGenerationSectionTitle",
)
self.shopee_update_section_title = self._section_title(
"蝦皮更新安全 / 执行模式",
"蝦皮更新执行",
"settingsShopeeUpdateSectionTitle",
)
self.infrastructure_section_title = self._section_title(
@@ -507,7 +486,6 @@ class SettingsTab(QWidget):
self.title_concurrency_spin,
self.image_concurrency_spin,
self.retry_spin,
self.jpg_quality_spin,
self.default_debug_port_spin,
self.debug_port_start_spin,
self.debug_port_end_spin,
@@ -518,9 +496,6 @@ class SettingsTab(QWidget):
checkboxes = (
self.cmhub_check_balance_checkbox,
self.enabled_checkbox,
self.allow_real_submit_checkbox,
self.close_success_tab_checkbox,
self.parallel_accounts_checkbox,
)
for widget in line_edits:
widget.textChanged.connect(self._mark_dirty)
@@ -768,7 +743,6 @@ class SettingsTab(QWidget):
"title_concurrency": self.title_concurrency_spin.value(),
"image_concurrency": self.image_concurrency_spin.value(),
"retry": self.retry_spin.value(),
"jpg_quality": self.jpg_quality_spin.value(),
"resolution": self.resolution_combo.currentData() or "1k",
"resolution_timeouts": dict(ai_cfg.get("resolution_timeouts", {})),
}
@@ -802,13 +776,9 @@ class SettingsTab(QWidget):
"ai": ai_cfg,
"shopee_update": {
"test_item_id": str(self._compat_test_item_id or ""),
"allow_real_submit": self.allow_real_submit_checkbox.isChecked(),
"allow_cover_update": appconfig.update_mode_includes_cover(update_mode),
"update_mode": update_mode,
"max_items_per_run": self.max_items_per_run_spin.value(),
"close_success_tab": self.close_success_tab_checkbox.isChecked(),
"dry_run": False,
"parallel_accounts": self.parallel_accounts_checkbox.isChecked(),
"max_parallel_accounts": self.max_parallel_accounts_spin.value(),
},
}
@@ -899,7 +869,6 @@ class SettingsTab(QWidget):
self.resolution_combo,
str(ai_cfg.get("resolution", "1k")),
)
self.jpg_quality_spin.setValue(int(ai_cfg.get("jpg_quality", 90) or 90))
self.chrome_path_edit.setText(appconfig.chrome_path(self.config))
self.user_data_root_edit.setText(
str(self.config.get("user_data_root", "chrome_user_data_dir") or "")
@@ -917,21 +886,17 @@ class SettingsTab(QWidget):
)
update_cfg = self._shopee_update_config()
self._compat_test_item_id = str(update_cfg.get("test_item_id", ""))
self.allow_real_submit_checkbox.setChecked(
bool(update_cfg.get("allow_real_submit", False))
)
self.allow_cover_update_checkbox.setChecked(bool(update_cfg.get("allow_cover_update", False)))
self.max_items_per_run_spin.setValue(
max(1, int(update_cfg.get("max_items_per_run", 1) or 1))
)
self.close_success_tab_checkbox.setChecked(
bool(update_cfg.get("close_success_tab", False))
)
self.parallel_accounts_checkbox.setChecked(
bool(update_cfg.get("parallel_accounts", False))
)
self.max_parallel_accounts_spin.setValue(
max(1, int(update_cfg.get("max_parallel_accounts", 2) or 2))
max(
appconfig.SHOPEE_PARALLEL_ACCOUNTS_MIN,
min(
appconfig.SHOPEE_PARALLEL_ACCOUNTS_MAX,
int(update_cfg.get("max_parallel_accounts", 1) or 1),
),
)
)
self._update_response_timeout_label()
self._on_backend_changed()
+8 -11
View File
@@ -573,10 +573,8 @@ class ApplyWorker(BaseWorker):
db_path=None,
config=None,
preflight=True,
close_success_tab=False,
dry_run=False,
update_mode=None,
parallel_accounts=False,
max_parallel_accounts=1,
batch_size=None,
diagnostic_log_dir=None,
@@ -586,14 +584,15 @@ class ApplyWorker(BaseWorker):
self.db_path = db_path
self.config = config
self.preflight = preflight
self.close_success_tab = close_success_tab
self.dry_run = bool(dry_run)
self.update_mode = appconfig.normalize_update_mode(
update_mode,
allow_cover_update=appconfig.shopee_update_config(config).get("allow_cover_update", False),
)
self.parallel_accounts = bool(parallel_accounts)
self.max_parallel_accounts = max(1, int(max_parallel_accounts or 1))
self.max_parallel_accounts = max(
appconfig.SHOPEE_PARALLEL_ACCOUNTS_MIN,
min(appconfig.SHOPEE_PARALLEL_ACCOUNTS_MAX, int(max_parallel_accounts or 1)),
)
self.batch_size = None if batch_size is None else max(1, int(batch_size or 1))
self._current_batch_size = None
self._batch_count = 0
@@ -633,7 +632,7 @@ class ApplyWorker(BaseWorker):
batch_count=len(batches),
parallel=(
f"多账号并行最多{self.max_parallel_accounts}"
if self.parallel_accounts
if self.max_parallel_accounts > 1
else "串行"
),
)
@@ -671,7 +670,7 @@ class ApplyWorker(BaseWorker):
break
outcome = self._preview_task(task, account_by_alias)
self._record_outcome(counters, total, outcome)
elif self.parallel_accounts and self.max_parallel_accounts > 1:
elif self.max_parallel_accounts > 1:
self._run_parallel_by_account(batch_tasks, account_by_alias, counters, total)
else:
for task in batch_tasks:
@@ -936,7 +935,6 @@ class ApplyWorker(BaseWorker):
result = editor.apply_task(
account,
task,
close_success_tab=self.close_success_tab,
on_step=on_step,
bring_to_front=bring_to_front,
update_mode=self.update_mode,
@@ -1103,7 +1101,7 @@ class ApplyWorker(BaseWorker):
"failed": counters["failed"],
"batch_ids": batch_ids,
"dry_run": self.dry_run,
"parallel_accounts": self.parallel_accounts,
"account_parallel": self.max_parallel_accounts > 1,
"batch_size": self._current_batch_size,
"batch_count": self._batch_count,
"update_mode": self.update_mode,
@@ -1123,9 +1121,8 @@ class ApplyWorker(BaseWorker):
total=len(eligible),
options={
"batch_ids": batch_ids,
"close_success_tab": self.close_success_tab,
"dry_run": self.dry_run,
"parallel_accounts": self.parallel_accounts,
"account_parallel": self.max_parallel_accounts > 1,
"max_parallel_accounts": self.max_parallel_accounts,
"batch_size": self._current_batch_size,
"batch_count": self._batch_count,