feat: 接入远程订阅策略门禁 T-705
Tests / Python 3.11 / Windows (push) Has been cancelled

This commit is contained in:
chengma
2026-07-28 15:42:19 +08:00
parent 593c6f77cb
commit df9da63841
15 changed files with 925 additions and 73 deletions
+45 -3
View File
@@ -6,7 +6,16 @@ import os
import sys
from dataclasses import replace
from .. import appconfig, chrome, db, diagnostics, image_studio_generation, update_check, update_health
from .. import (
appconfig,
chrome,
client_policy,
db,
diagnostics,
image_studio_generation,
update_check,
update_health,
)
from ..version import APP_NAME, APP_VERSION, display_name
from . import widgets as _widgets
from .widgets import *
@@ -70,6 +79,10 @@ def _write_update_check_diagnostic(message, *, result=None, exc=None):
"min_supported_version": result.min_supported_version,
"download_url": result.download_url,
"error": result.error,
"client_policy_mode": (
result.client_policy.mode if result.client_policy is not None else ""
),
"client_policy_error": result.client_policy_error,
}
try:
diagnostics.write_diagnostic_log(
@@ -91,15 +104,24 @@ def _show_forced_update_dialog(result, *, parent=None, dialog_factory=None) -> b
return False
def _run_startup_update_gate(*, checker=None, dialog_factory=None) -> bool:
def _run_startup_update_gate(
*,
checker=None,
dialog_factory=None,
result_callback=None,
) -> bool:
try:
result = (checker or update_check.check_for_update)()
except Exception as exc:
_write_update_check_diagnostic("启动版本检查异常,已允许继续使用", exc=exc)
return True
if result_callback is not None:
result_callback(result)
if result.error:
_write_update_check_diagnostic("启动版本检查失败,已允许继续使用", result=result)
elif result.client_policy_error:
_write_update_check_diagnostic("客户端订阅策略已按安全兼容规则处理", result=result)
if result.forced:
failed = update_health.get_failed_release(
appconfig.app_base_dir(),
@@ -148,7 +170,8 @@ def main() -> int:
update_health.write_health(health_context, "environment_blocked", str(exc))
QMessageBox.critical(None, "启动配置错误", str(exc))
return 1
if not _run_startup_update_gate():
startup_update_results = []
if not _run_startup_update_gate(result_callback=startup_update_results.append):
return 1
try:
startup = chrome.ensure_configured_chrome_path()
@@ -183,9 +206,28 @@ def main() -> int:
)
except Exception as exc:
_write_update_check_diagnostic("自定义网关套图任务恢复检查失败", exc=exc)
remote_policy = (
startup_update_results[-1].client_policy
if startup_update_results
else None
)
resolved_policy = client_policy.resolve_client_policy(
remote_policy,
config=startup["config"],
)
if resolved_policy.warning:
_write_update_check_diagnostic(
"客户端订阅策略使用兼容模式",
result=(
startup_update_results[-1]
if startup_update_results
else None
),
)
window = MainWindow(
config=startup["config"],
startup_status=startup["message"],
subscription_policy=resolved_policy,
)
if runtime_lease is not None:
app.aboutToQuit.connect(runtime_lease.release)