refactor(navigation): simplify main tab labels
This commit is contained in:
@@ -180,7 +180,7 @@ def analyze_product_images(
|
||||
cfg = appconfig.load_config() if config is None else config
|
||||
ai_cfg = appconfig.ai_config(cfg)
|
||||
if _ai_backend(ai_cfg) != "cmhub":
|
||||
raise AIError("商品套图AI帮写需要使用 cmhub 图片理解服务,请到⑤设置配置 cmhub。")
|
||||
raise AIError("商品套图AI帮写需要使用 cmhub 图片理解服务,请到设置配置 cmhub。")
|
||||
|
||||
paths = _validate_cmhub_vision_images(image_paths)
|
||||
runtime = _cmhub_runtime(cfg, "vision", cmhub_config_path)
|
||||
@@ -878,9 +878,9 @@ def fetch_cmhub_models(base_url, api_key, connect_timeout=10, read_timeout=30, u
|
||||
base_url = str(base_url or "").strip()
|
||||
api_key = str(api_key or "")
|
||||
if not base_url:
|
||||
raise CMHubError("cmhub_not_configured", "请去⑤设置配置 cmhub Base URL")
|
||||
raise CMHubError("cmhub_not_configured", "请去设置配置 cmhub Base URL")
|
||||
if not api_key:
|
||||
raise CMHubError("cmhub_not_configured", "请去⑤设置配置 cmhub API Key")
|
||||
raise CMHubError("cmhub_not_configured", "请去设置配置 cmhub API Key")
|
||||
_apply_cmhub_proxy(use_system_proxy)
|
||||
data = _cmhub_call_with_retry(
|
||||
"GET",
|
||||
@@ -904,9 +904,9 @@ def fetch_cmhub_balance(base_url, api_key, connect_timeout=10, read_timeout=30,
|
||||
base_url = str(base_url or "").strip()
|
||||
api_key = str(api_key or "")
|
||||
if not base_url:
|
||||
raise CMHubError("cmhub_not_configured", "请去⑤设置配置 cmhub Base URL")
|
||||
raise CMHubError("cmhub_not_configured", "请去设置配置 cmhub Base URL")
|
||||
if not api_key:
|
||||
raise CMHubError("cmhub_not_configured", "请去⑤设置配置 cmhub API Key")
|
||||
raise CMHubError("cmhub_not_configured", "请去设置配置 cmhub API Key")
|
||||
_apply_cmhub_proxy(use_system_proxy)
|
||||
data = _cmhub_call_with_retry(
|
||||
"GET",
|
||||
@@ -1455,7 +1455,7 @@ def _cmhub_runtime(config, operation, cmhub_config_path):
|
||||
if missing:
|
||||
raise CMHubError(
|
||||
"cmhub_not_configured",
|
||||
"请去⑤设置配置 cmhub:缺少 " + "、".join(missing),
|
||||
"请去设置配置 cmhub:缺少 " + "、".join(missing),
|
||||
retryable=False,
|
||||
)
|
||||
use_system_proxy = bool(hub.get("use_system_proxy", False))
|
||||
@@ -1765,7 +1765,7 @@ def _cmhub_retryable(code):
|
||||
def _cmhub_user_message(code, message):
|
||||
defaults = {
|
||||
"insufficient_points": "点数不足,请先充值",
|
||||
"unauthorized": "cmhub API Key 无效,请去⑤设置重填",
|
||||
"unauthorized": "cmhub API Key 无效,请去设置重填",
|
||||
"account_disabled": "cmhub 账号已禁用,请去网页端处理",
|
||||
"bad_request": "cmhub 请求参数错误",
|
||||
"model_not_allowed": "cmhub 模型别名无权限",
|
||||
|
||||
+1
-1
@@ -279,7 +279,7 @@ def configured_alias_summary(alias, *, model=None):
|
||||
tier = model_tier(model)
|
||||
if alias:
|
||||
return f"cmhub 托管{tier_label(tier)},生图别名 {alias},扣点以返回结果为准"
|
||||
return "cmhub 托管默认档,未配置生图别名;请先到⑤设置选择生图别名"
|
||||
return "cmhub 托管默认档,未配置生图别名;请先到设置选择生图别名"
|
||||
|
||||
|
||||
def _recommended_for_text(model):
|
||||
|
||||
@@ -100,7 +100,7 @@ class MainWindow(QMainWindow):
|
||||
self.setWindowTitle(display_name())
|
||||
_fit_and_center_window(self)
|
||||
self.setStyleSheet(BUTTON_BASE_STYLE)
|
||||
self._settings_tab_index = TAB_TITLES.index("⑤ 设置")
|
||||
self._settings_tab_index = TAB_TITLES.index("设置")
|
||||
self._last_tab_index = 0
|
||||
self._reverting_tab_change = False
|
||||
self.tabs = QTabWidget()
|
||||
@@ -109,7 +109,6 @@ class MainWindow(QMainWindow):
|
||||
self.tabs.currentChanged.connect(self._on_tab_changed)
|
||||
for title in TAB_TITLES:
|
||||
self.tabs.addTab(self._build_tab(title), title)
|
||||
self.tabs.setTabIcon(TAB_TITLES.index("③ 更新蝦皮"), _warning_dot_icon())
|
||||
self.setCentralWidget(self.tabs)
|
||||
self.show_status("就绪", level="muted")
|
||||
if startup_status:
|
||||
@@ -153,20 +152,20 @@ class MainWindow(QMainWindow):
|
||||
open_accounts_callback=lambda: self.open_accounts_tab(),
|
||||
open_settings_callback=lambda: self.open_settings_tab(),
|
||||
)
|
||||
if title == "④ 账号管理":
|
||||
if title == "账号管理":
|
||||
return AccountsTab(
|
||||
db_path=self.db_path,
|
||||
config=self.config,
|
||||
status_callback=self.show_status,
|
||||
)
|
||||
if title == "⑤ 设置":
|
||||
if title == "设置":
|
||||
return SettingsTab(
|
||||
config=self.config,
|
||||
config_path=self.config_path,
|
||||
ai_models_path=self.ai_models_path,
|
||||
status_callback=self.show_status,
|
||||
)
|
||||
if title == "⑥ 商品套图":
|
||||
if title == "商品套图":
|
||||
return ProductSuiteTab(
|
||||
db_path=self.db_path,
|
||||
config=self.config,
|
||||
@@ -209,7 +208,7 @@ class MainWindow(QMainWindow):
|
||||
return True
|
||||
box = QMessageBox(self)
|
||||
box.setWindowTitle("未保存更改")
|
||||
box.setText("⑤ 设置有未保存更改。要先保存再离开吗?")
|
||||
box.setText("设置有未保存更改。要先保存再离开吗?")
|
||||
save_button = box.addButton("保存", QMessageBox.AcceptRole)
|
||||
discard_button = box.addButton("放弃", QMessageBox.DestructiveRole)
|
||||
box.addButton("取消", QMessageBox.RejectRole)
|
||||
@@ -229,7 +228,7 @@ class MainWindow(QMainWindow):
|
||||
event.ignore()
|
||||
|
||||
def open_accounts_tab(self):
|
||||
self.tabs.setCurrentIndex(TAB_TITLES.index("④ 账号管理"))
|
||||
self.tabs.setCurrentIndex(TAB_TITLES.index("账号管理"))
|
||||
|
||||
def open_settings_tab(self):
|
||||
self.tabs.setCurrentIndex(TAB_TITLES.index("⑤ 设置"))
|
||||
self.tabs.setCurrentIndex(TAB_TITLES.index("设置"))
|
||||
|
||||
@@ -212,7 +212,7 @@ class ApplyTab(QWidget):
|
||||
self.empty_state_card,
|
||||
self.empty_state_label,
|
||||
self.empty_state_button,
|
||||
"第一步:前往『④账号管理』配置并登录账号,再回到③更新蝦皮。",
|
||||
"第一步:前往『账号管理』配置并登录账号,再回到③更新蝦皮。",
|
||||
self.open_accounts_callback is not None,
|
||||
)
|
||||
return
|
||||
@@ -766,7 +766,7 @@ class ApplyTab(QWidget):
|
||||
full_message = (
|
||||
f"{message}\n\n"
|
||||
"本轮更新已中止,不会自动打开账号 Chrome,也不会提交任何商品。\n"
|
||||
"请先到「④ 账号管理」配置账号、启动对应账号 Chrome,并确认已人工登录蝦皮。"
|
||||
"请先到「账号管理」配置账号、启动对应账号 Chrome,并确认已人工登录蝦皮。"
|
||||
)
|
||||
QMessageBox.warning(self, "账号未就绪", full_message)
|
||||
self._set_status(full_message.replace("\n", " "))
|
||||
|
||||
@@ -410,7 +410,7 @@ class CollectTab(QWidget):
|
||||
full_message = (
|
||||
f"{message}\n\n"
|
||||
"本轮采集已中止。\n"
|
||||
"请先到「④ 账号管理」检查账号配置、Chrome 路径和登录状态。"
|
||||
"请先到「账号管理」检查账号配置、Chrome 路径和登录状态。"
|
||||
)
|
||||
QMessageBox.warning(self, "账号未就绪", full_message)
|
||||
self._set_status(full_message.replace("\n", " "))
|
||||
@@ -928,7 +928,7 @@ class CollectTab(QWidget):
|
||||
if skip_summary:
|
||||
lines.append(skip_summary)
|
||||
if skip_counts[ALIAS_UNMATCHED] > 0:
|
||||
lines.append("请检查 Excel 别名是否与④账号管理中的账号别名一致。")
|
||||
lines.append("请检查 Excel 别名是否与账号管理中的账号别名一致。")
|
||||
if launched:
|
||||
lines.append(
|
||||
"本轮已自动启动账号 Chrome:"
|
||||
@@ -940,7 +940,7 @@ class CollectTab(QWidget):
|
||||
+ "、".join(self._account_label(item) for item in login_required)
|
||||
)
|
||||
if skip_counts[LOGIN_REQUIRED] > 0:
|
||||
lines.append("请到④账号管理完成对应账号登录后,再重新采集略过任务。")
|
||||
lines.append("请到账号管理完成对应账号登录后,再重新采集略过任务。")
|
||||
if launched or reused or login_required:
|
||||
lines.append("采集结束后不会自动关闭账号 Chrome,请按需自行关闭。")
|
||||
text = "\n".join(lines)
|
||||
@@ -1078,7 +1078,7 @@ class CollectTab(QWidget):
|
||||
self.empty_state_card,
|
||||
self.empty_state_label,
|
||||
self.empty_state_button,
|
||||
"第一步:前往『④账号管理』配置并登录账号,再回到①导入 Excel。",
|
||||
"第一步:前往『账号管理』配置并登录账号,再回到①导入 Excel。",
|
||||
self.open_accounts_callback is not None,
|
||||
)
|
||||
return
|
||||
|
||||
@@ -2365,7 +2365,7 @@ class GenerateTab(QWidget):
|
||||
self.empty_state_card,
|
||||
self.empty_state_label,
|
||||
self.empty_state_button,
|
||||
"第一步:前往『④账号管理』配置并登录账号,再回到②生成标题和封面。",
|
||||
"第一步:前往『账号管理』配置并登录账号,再回到②生成标题和封面。",
|
||||
self.open_accounts_callback is not None,
|
||||
)
|
||||
return
|
||||
|
||||
@@ -781,7 +781,7 @@ class ImageStudioTab(QWidget):
|
||||
account.alias,
|
||||
)
|
||||
if not self.accounts:
|
||||
self.account_combo.addItem("暂无账号,请先到④账号管理添加", "")
|
||||
self.account_combo.addItem("暂无账号,请先到账号管理添加", "")
|
||||
|
||||
def refresh_projects(self):
|
||||
try:
|
||||
|
||||
@@ -2472,7 +2472,7 @@ class ProductSuiteTab(QWidget):
|
||||
Qt.ToolTipRole,
|
||||
)
|
||||
if not self.accounts:
|
||||
self.account_combo.addItem("暂无账号,请先到④账号管理添加", "")
|
||||
self.account_combo.addItem("暂无账号,请先到账号管理添加", "")
|
||||
index = self.account_combo.findData(selected)
|
||||
if index >= 0:
|
||||
self.account_combo.setCurrentIndex(index)
|
||||
@@ -2889,7 +2889,7 @@ class ProductSuiteTab(QWidget):
|
||||
return False
|
||||
if self._account_for_alias(state.account_alias) is None:
|
||||
if show_message:
|
||||
self._message("账号不可用", "所选账号不存在,请到④账号管理刷新账号。")
|
||||
self._message("账号不可用", "所选账号不存在,请到账号管理刷新账号。")
|
||||
return False
|
||||
return True
|
||||
|
||||
@@ -2917,7 +2917,7 @@ class ProductSuiteTab(QWidget):
|
||||
return None
|
||||
account = self._account_for_alias(state.account_alias)
|
||||
if account is None:
|
||||
self._message("账号不可用", "所选账号不存在,请到④账号管理刷新账号。")
|
||||
self._message("账号不可用", "所选账号不存在,请到账号管理刷新账号。")
|
||||
return None
|
||||
previous_id = state.project_id
|
||||
try:
|
||||
|
||||
+3
-16
@@ -58,9 +58,9 @@ TAB_TITLES = [
|
||||
"① 导入采集",
|
||||
"② AI生成",
|
||||
"③ 更新蝦皮",
|
||||
"④ 账号管理",
|
||||
"⑤ 设置",
|
||||
"⑥ 商品套图",
|
||||
"账号管理",
|
||||
"设置",
|
||||
"商品套图",
|
||||
]
|
||||
|
||||
TAB_STYLE = """
|
||||
@@ -307,19 +307,6 @@ def _login_status_color(status):
|
||||
return _qcolor(COLOR_MUTED)
|
||||
|
||||
|
||||
def _warning_dot_icon(size=12):
|
||||
pixmap = QPixmap(size, size)
|
||||
pixmap.fill(Qt.transparent)
|
||||
painter = QPainter(pixmap)
|
||||
painter.setRenderHint(QPainter.Antialiasing)
|
||||
painter.setPen(Qt.NoPen)
|
||||
painter.setBrush(QColor(COLOR_WARNING))
|
||||
margin = max(1, size // 6)
|
||||
painter.drawEllipse(margin, margin, size - margin * 2, size - margin * 2)
|
||||
painter.end()
|
||||
return QIcon(pixmap)
|
||||
|
||||
|
||||
def _build_empty_state_card(object_name, button_text="前往账号管理"):
|
||||
card = QWidget()
|
||||
card.setObjectName(object_name)
|
||||
|
||||
+3
-3
@@ -980,9 +980,9 @@ class GenerateWorker(BaseWorker):
|
||||
if code_text == "insufficient_points" or "点数不足" in raw:
|
||||
return "点数不足,请先充值"
|
||||
if code_text == "unauthorized" or "api key 无效" in raw.lower():
|
||||
return "cmhub API Key 无效,请去⑤设置重填"
|
||||
return "cmhub API Key 无效,请去设置重填"
|
||||
if code_text in {"model_not_allowed", "no_pricing_rule"} or "模型别名" in raw or "模型配置不可用" in raw:
|
||||
return "cmhub 模型别名不可用,请去⑤设置刷新别名并保存"
|
||||
return "cmhub 模型别名不可用,请去设置刷新别名并保存"
|
||||
if code_text == "content_blocked" or "内容安全" in raw:
|
||||
return "cmhub 内容安全策略拒绝本次生成"
|
||||
if code_text == "rate_limited" or "rate_limited" in lowered or "请求过于频繁" in raw:
|
||||
@@ -997,7 +997,7 @@ class GenerateWorker(BaseWorker):
|
||||
or "接口不存在" in raw
|
||||
or str(status or "") == "404"
|
||||
):
|
||||
return "cmhub 网关接口不可用,请检查⑤设置中的 Base URL,或联系服务方确认网关版本"
|
||||
return "cmhub 网关接口不可用,请检查设置中的 Base URL,或联系服务方确认网关版本"
|
||||
if code_text == "upstream_error" or "upstream_error" in lowered or "上游" in raw:
|
||||
return "cmhub 上游生成失败,请稍后重试"
|
||||
if "下载 cmhub 图片失败" in raw:
|
||||
|
||||
Reference in New Issue
Block a user