feat(subscription): add membership access preflight

This commit is contained in:
chengma
2026-07-21 17:38:05 +08:00
parent ca46c34dfe
commit 9ee48dc2aa
14 changed files with 788 additions and 4 deletions
+4
View File
@@ -983,6 +983,7 @@ class GenerateTab(QWidget):
title_templates_dir=None,
open_accounts_callback=None,
refresh_workflow_callback=None,
subscription_preflight_callback=None,
):
super().__init__(parent)
self.config = appconfig.load_config(config_path or appconfig.CONFIG_PATH) if config is None else config
@@ -995,6 +996,7 @@ class GenerateTab(QWidget):
self.status_callback = status_callback
self.open_accounts_callback = open_accounts_callback
self.refresh_workflow_callback = refresh_workflow_callback
self.subscription_preflight_callback = subscription_preflight_callback
self.title_prompt_path = title_prompt_path or appconfig.title_prompt_path(self.config)
self.cover_prompts_dir = cover_prompts_dir or appconfig.cover_prompts_dir(self.config)
self.title_templates_dir = title_templates_dir or appconfig.title_templates_dir(self.config)
@@ -1757,6 +1759,8 @@ class GenerateTab(QWidget):
if self.generate_thread is not None:
self._set_status("AI 生成正在进行...")
return
if self.subscription_preflight_callback is not None and not self.subscription_preflight_callback("开始 AI 生成"):
return
if not self._save_generate_mode_setting(show_status=False):
return
generate_mode = self._current_generate_mode()
+6
View File
@@ -1973,6 +1973,7 @@ class ProductSuiteTab(QWidget):
config=None,
config_path=None,
status_callback=None,
subscription_preflight_callback=None,
):
super().__init__(parent)
self.setObjectName("productSuiteTab")
@@ -1982,6 +1983,7 @@ class ProductSuiteTab(QWidget):
self.cmhub_config_path = self.config.get("cmhub_config_path") or appconfig.cmhub_config_file_path(self.config)
self.product_suite_prompt_path = appconfig.product_suite_prompt_path(self.config)
self.status_callback = status_callback
self.subscription_preflight_callback = subscription_preflight_callback
self.accounts = []
self._states = {}
self._retired_states = []
@@ -4392,6 +4394,8 @@ class ProductSuiteTab(QWidget):
def start_ai_write(self, checked=False):
if not self._require_default_gateway("商品套图AI帮写"):
return
if self.subscription_preflight_callback is not None and not self.subscription_preflight_callback("开始 AI 帮写"):
return
state = self._displayed_state
if state is None:
return
@@ -4729,6 +4733,8 @@ class ProductSuiteTab(QWidget):
retry_job_id=None,
confirm_direct_retry=False,
):
if self.subscription_preflight_callback is not None and not self.subscription_preflight_callback("生成商品套图"):
return False
if not self._ensure_generation_gateway():
return False
if state.generation_running():