feat: add simple license activation server
This commit is contained in:
1 parent
b2db5ed499
commit
05be83d289
17 files changed
+1053
-6
No files matched your search
@@ -7,8 +7,9 @@ from typing import Callable
|
||||
|
||||
from douyin.license.license_manager import (
|
||||
get_license_status_payload,
|
||||
install_license_text,
|
||||
install_license_or_activate,
|
||||
)
|
||||
from gui.config_io import read_config
|
||||
|
||||
|
||||
def _format_status(payload: dict) -> str:
|
||||
@@ -24,6 +25,20 @@ def _format_status(payload: dict) -> str:
|
||||
return " | ".join(parts)
|
||||
|
||||
|
||||
def _activation_settings() -> tuple[str, int]:
|
||||
try:
|
||||
cfg = read_config()
|
||||
except Exception:
|
||||
cfg = {}
|
||||
section = cfg.get("license") if isinstance(cfg.get("license"), dict) else {}
|
||||
activation_url = str(section.get("activation_url") or "").strip()
|
||||
try:
|
||||
timeout_seconds = int(section.get("timeout_seconds") or 10)
|
||||
except (TypeError, ValueError):
|
||||
timeout_seconds = 10
|
||||
return activation_url, max(1, timeout_seconds)
|
||||
|
||||
|
||||
def setup_license_tab(
|
||||
parent: ttk.Notebook,
|
||||
*,
|
||||
@@ -81,7 +96,12 @@ def setup_license_tab(
|
||||
if not raw:
|
||||
on_line("[授权] 请输入卡密")
|
||||
return
|
||||
status = install_license_text(raw)
|
||||
activation_url, timeout_seconds = _activation_settings()
|
||||
status = install_license_or_activate(
|
||||
raw,
|
||||
activation_url=activation_url,
|
||||
timeout_seconds=timeout_seconds,
|
||||
)
|
||||
refresh_status()
|
||||
if status.ok:
|
||||
text.delete("1.0", "end")
|
||||
|
||||
Reference in new issue
Block a user