feat: refine settings sections

This commit is contained in:
chengma
2026-07-02 10:59:21 +08:00
parent 820612c3ab
commit 86b931b26d
5 changed files with 65 additions and 30 deletions
+37 -16
View File
@@ -4870,6 +4870,7 @@ if QT_IMPORT_ERROR is None:
self.current_model_name = None
self.test_worker = None
self.test_thread = None
self._compat_test_item_id = ""
self.model_combo = QComboBox()
self.model_combo.setObjectName("aiModelCombo")
@@ -4944,9 +4945,6 @@ if QT_IMPORT_ERROR is None:
self.cdp_ready_timeout_spin.setObjectName("cdpReadyTimeoutSpin")
self.cdp_ready_timeout_spin.setRange(1, 3600)
self.save_config_button = QPushButton("保存设置")
self.test_item_id_edit = QLineEdit()
self.test_item_id_edit.setObjectName("testItemIdEdit")
self.test_item_id_edit.setVisible(False)
self.allow_real_submit_checkbox = QCheckBox("允许真实提交线上商品")
self.allow_real_submit_checkbox.setObjectName("allowRealSubmitCheckbox")
self.allow_cover_update_checkbox = QCheckBox("允许更新封面")
@@ -4957,9 +4955,6 @@ if QT_IMPORT_ERROR is None:
self.max_items_per_run_spin.setToolTip("作为每批最大更新条数;正式更新会分批处理当前筛选全部可更新记录。")
self.close_success_tab_checkbox = QCheckBox("成功后关闭本次新开编辑页")
self.close_success_tab_checkbox.setObjectName("closeSuccessTabCheckbox")
self.dry_run_checkbox = QCheckBox("检查本轮更新")
self.dry_run_checkbox.setObjectName("dryRunCheckbox")
self.dry_run_checkbox.setVisible(False)
self.parallel_accounts_checkbox = QCheckBox("多账号并行更新")
self.parallel_accounts_checkbox.setObjectName("parallelAccountsCheckbox")
self.max_parallel_accounts_spin = QSpinBox()
@@ -5045,23 +5040,44 @@ if QT_IMPORT_ERROR is None:
panel = QWidget()
panel.setMaximumWidth(1800)
panel_layout = QVBoxLayout(panel)
self.settings_panel_layout = panel_layout
panel_layout.setContentsMargins(13, 18, 13, 18)
panel_layout.addWidget(QLabel("AI 模型"))
self.ai_model_section_title = self._section_title(
"AI 模型",
"settingsAiModelSectionTitle",
)
self.model_detail_section_title = self._section_title(
"模型详情",
"settingsModelDetailSectionTitle",
)
self.generation_section_title = self._section_title(
"角色与生成参数",
"settingsGenerationSectionTitle",
)
self.shopee_update_section_title = self._section_title(
"Shopee 更新安全 / 执行模式",
"settingsShopeeUpdateSectionTitle",
)
self.infrastructure_section_title = self._section_title(
"基础设施(路径与端口)",
"settingsInfrastructureSectionTitle",
)
panel_layout.addWidget(self.ai_model_section_title)
panel_layout.addLayout(model_picker_layout)
panel_layout.addSpacing(14)
panel_layout.addWidget(QLabel("模型详情"))
panel_layout.addWidget(self.model_detail_section_title)
panel_layout.addLayout(form)
panel_layout.addLayout(action_layout)
panel_layout.addWidget(self.test_result_label)
panel_layout.addSpacing(18)
panel_layout.addWidget(QLabel("角色与生成参数"))
panel_layout.addWidget(self.generation_section_title)
panel_layout.addLayout(ai_form)
panel_layout.addSpacing(18)
panel_layout.addWidget(QLabel("路径与端口"))
panel_layout.addLayout(path_form)
panel_layout.addSpacing(18)
panel_layout.addWidget(QLabel("Shopee 更新安全"))
panel_layout.addWidget(self.shopee_update_section_title)
panel_layout.addLayout(self.shopee_update_form_layout)
panel_layout.addSpacing(18)
panel_layout.addWidget(self.infrastructure_section_title)
panel_layout.addLayout(path_form)
panel_layout.addWidget(self.save_config_button)
panel_layout.addStretch(1)
@@ -5130,6 +5146,12 @@ if QT_IMPORT_ERROR is None:
else:
layout.addWidget(widget, row, column, 1, span_pairs * 2)
def _section_title(self, text, object_name):
label = QLabel(text)
label.setObjectName(object_name)
label.setStyleSheet("color: #24292f; font-weight: 600; padding-top: 4px;")
return label
def _set_status(self, message):
if self.status_callback is not None:
self.status_callback(message)
@@ -5322,7 +5344,7 @@ if QT_IMPORT_ERROR is None:
"cdp_ready_timeout": self.cdp_ready_timeout_spin.value(),
"ai": ai_cfg,
"shopee_update": {
"test_item_id": self.test_item_id_edit.text().strip(),
"test_item_id": str(self._compat_test_item_id or ""),
"allow_real_submit": self.allow_real_submit_checkbox.isChecked(),
"allow_cover_update": self.allow_cover_update_checkbox.isChecked(),
"max_items_per_run": self.max_items_per_run_spin.value(),
@@ -5382,7 +5404,7 @@ if QT_IMPORT_ERROR is None:
int(appconfig.cdp_ready_timeout(self.config))
)
update_cfg = self._shopee_update_config()
self.test_item_id_edit.setText(str(update_cfg.get("test_item_id", "")))
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))
)
@@ -5395,7 +5417,6 @@ if QT_IMPORT_ERROR is None:
self.close_success_tab_checkbox.setChecked(
bool(update_cfg.get("close_success_tab", False))
)
self.dry_run_checkbox.setChecked(False)
self.parallel_accounts_checkbox.setChecked(
bool(update_cfg.get("parallel_accounts", False))
)
+1 -1
View File
@@ -100,7 +100,7 @@
| T-514 | ①②③ 首次空状态引导卡片 | T-205 | 依据 `docs/ux-review.md` P1。①②③ 增加轻量空状态引导卡片,不改采集/生成/更新流程和既有预检拦截逻辑。无账号时三页均显示「第一步:前往『④账号管理』配置并登录账号」并提供「前往账号管理」按钮;有账号但无任务时,①提示导入 Excel,②提示先完成①采集,③提示先完成②生成;账号/任务就绪后卡片自动隐藏,老用户无感。卡片只做 UI 引导,不替代执行前账号 Chrome/CDP/登录态检查 | DONE |
| T-515 | 批次阶段进度总览 | T-206, T-401 | 依据 `docs/ux-review.md` P1。加轻量批次进度总览:①②③在当前批次/全部批次摘要区下方显示同一组阶段计数,按当前批次筛选聚合总数、导入、已采集、已生成、已更新、失败、略过。计数口径:失败/略过优先按 `status=failed/skipped` 统计;已更新按 `stage=applied` 且非失败/略过;已生成按 `stage=generated` 且非失败/略过;已采集按 `stage=collected` 且非失败/略过;导入按其余未进入后续阶段任务统计。数据由现有 `db.list_tasks(batch_id=...)` 聚合,不新增表;已软删除批次不计入;只做 UI 总览,不改采集/生成/更新执行流程 | DONE |
| T-516 | ①筛选对齐②③ | T-202, T-303b | 依据 `docs/ux-review.md` P2。① 导入采集补齐与②③一致的店铺、商品ID、状态筛选,保持三个列表页筛选心智一致。筛选栏顺序为批次/店铺/商品ID/状态;当前筛选结果用于①表格显示与「采集旧标题/旧封面」作用范围;导入汇总栏、批次进度总览、未匹配数量仍按当前批次全量任务统计,未匹配按钮继续筛出当前筛选结果中的未匹配任务;不改导入、采集、回写、CDP 或 Shopee 更新逻辑 | DONE |
| T-517 | ⑤设置分区 + 清理兼容字段 | T-506, T-507 | 依据 `docs/ux-review.md` P2。⑤ 视觉分区:高频「Shopee 更新安全/执行模式」与低频「基础设施(Chrome路径/端口/DB路径)」分块;彻底隐藏或清理残留的 `test_item_id`、`dry_run` 用户入口(保留内部兼容字段与语义),减少设置页过载与 UI 技术债 | TODO |
| T-517 | ⑤设置分区 + 清理兼容字段 | T-506, T-507 | 依据 `docs/ux-review.md` P2。⑤ 视觉分区:将高频「Shopee 更新安全 / 执行模式」前置成独立分区,低频「基础设施(Chrome路径/端口/DB路径)」独立后置;彻底隐藏 `test_item_id`、`dry_run` 用户入口,不再占用可见表单位置,但保留 `config.json` 内部兼容字段与③「检查本轮更新」语义。只改⑤设置页 UI 分区、保存/加载展示和 GUI 测试,不改配置 schema,不改 Shopee/CDP 更新流程 | DONE |
## 里程碑
File diff suppressed because one or more lines are too long
+6
View File
@@ -974,3 +974,9 @@
- 测试:`tests/test_gui.py` 新增①筛选覆盖,验证店铺、商品ID、状态筛选、空结果提示、未匹配筛出和采集 worker 接收当前筛选任务。
- 验证:`python -m py_compile app\gui.py tests\test_gui.py`、`python -m unittest discover -s tests -p "test_gui.py"`(68 tests)、`python -m compileall app main.py`、`python -m unittest discover -s tests`(156 tests)均通过;Qt 仍有本机字体目录提示,不影响测试结果。
- 下一步:T-517「⑤设置分区 + 清理兼容字段」。
## 【2026-07-02】T-517 完成 · ⑤设置分区与兼容字段清理
- 文档先行:`docs/06-tasks.md` 将 T-517 标记为 DOING 后明确范围:只改⑤设置页 UI 分区、保存/加载展示和 GUI 测试,不改配置 schema,不改 Shopee/CDP 更新流程。
- 代码:`app/gui.py` 将「Shopee 更新安全 / 执行模式」前置为独立分区,将「基础设施(路径与端口)」后置;移除 `test_item_id_edit`、`dry_run_checkbox` 这类用户入口,加载时只记录 `test_item_id` 内部兼容值,保存时保留该值并固定 `dry_run=false`。
- 测试:`tests/test_gui.py` 更新设置页断言,覆盖分区顺序、旧入口不存在、保存设置仍同步 ApplyTab 安全配置且兼容字段不丢。
- 验证:`python -m py_compile app\gui.py tests\test_gui.py` 通过;`python -m unittest discover -s tests -p "test_gui.py"` 通过(68 tests);`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(156 tests);`git diff --check` 无空白错误,仅 LF/CRLF 提示。
+13 -6
View File
@@ -291,14 +291,21 @@ class GuiTests(TempDirMixin, unittest.TestCase):
self.assertEqual(QLineEdit.Password, tab.api_key_edit.echoMode())
self.assertEqual(11, tab.connect_timeout_spin.value())
self.assertFalse(tab.delete_model_button.isEnabled())
self.assertEqual("51100639510", tab.test_item_id_edit.text())
self.assertTrue(tab.test_item_id_edit.isHidden())
self.assertFalse(hasattr(tab, "test_item_id_edit"))
self.assertFalse(hasattr(tab, "dry_run_checkbox"))
self.assertEqual(
"Shopee 更新安全 / 执行模式",
tab.shopee_update_section_title.text(),
)
self.assertEqual("基础设施(路径与端口)", tab.infrastructure_section_title.text())
self.assertLess(
tab.settings_panel_layout.indexOf(tab.shopee_update_section_title),
tab.settings_panel_layout.indexOf(tab.infrastructure_section_title),
)
self.assertFalse(tab.allow_real_submit_checkbox.isChecked())
self.assertFalse(tab.allow_cover_update_checkbox.isChecked())
self.assertEqual(1, tab.max_items_per_run_spin.value())
self.assertFalse(tab.close_success_tab_checkbox.isChecked())
self.assertFalse(tab.dry_run_checkbox.isChecked())
self.assertTrue(tab.dry_run_checkbox.isHidden())
self.assertFalse(tab.parallel_accounts_checkbox.isChecked())
self.assertEqual(2, tab.max_parallel_accounts_spin.value())
@@ -527,7 +534,6 @@ class GuiTests(TempDirMixin, unittest.TestCase):
tab.debug_port_start_spin.setValue(9300)
tab.debug_port_end_spin.setValue(9350)
tab.cdp_ready_timeout_spin.setValue(45)
tab.test_item_id_edit.setText("51100639510")
tab.allow_real_submit_checkbox.setChecked(True)
tab.allow_cover_update_checkbox.setChecked(True)
tab.max_items_per_run_spin.setValue(2)
@@ -576,6 +582,8 @@ class GuiTests(TempDirMixin, unittest.TestCase):
def test_settings_save_updates_apply_tab_shared_safety_config(self):
with self.make_temp_dir() as temp_dir:
cfg = self.make_config(temp_dir)
cfg["shopee_update"] = dict(appconfig.default_config()["shopee_update"])
cfg["shopee_update"]["test_item_id"] = "123456789"
window = MainWindow(
config=cfg,
config_path=cfg["config_path"],
@@ -585,7 +593,6 @@ class GuiTests(TempDirMixin, unittest.TestCase):
settings_tab = window.tabs.widget(TAB_TITLES.index("⑤ 设置"))
apply_tab = window.tabs.widget(TAB_TITLES.index("③ 更新shopee"))
settings_tab.test_item_id_edit.setText("123456789")
settings_tab.allow_real_submit_checkbox.setChecked(True)
settings_tab.allow_cover_update_checkbox.setChecked(True)
settings_tab.max_items_per_run_spin.setValue(3)