This commit is contained in:
ВяткинАртём
2026-03-27 11:07:59 +03:00
parent b3a9bc6a8f
commit 78dd5d16ad
10 changed files with 46 additions and 2118 deletions
+27 -20
View File
@@ -8,8 +8,8 @@ import os
import subprocess
import sys
import threading
import webbrowser
import time
import webbrowser
from pathlib import Path
from typing import Dict, Optional
@@ -21,14 +21,6 @@ from PIL import Image, ImageDraw, ImageFont
import proxy.tg_ws_proxy as tg_ws_proxy
from proxy import __version__
from utils.default_config import default_tray_config
from ui.ctk_tray_ui import (
install_tray_config_buttons,
install_tray_config_form,
populate_first_run_window,
tray_settings_scroll_and_footer,
validate_config_form,
)
from ui.ctk_theme import (
CONFIG_DIALOG_FRAME_PAD,
CONFIG_DIALOG_SIZE,
@@ -37,6 +29,14 @@ from ui.ctk_theme import (
ctk_theme_for_platform,
main_content_frame,
)
from ui.ctk_tray_ui import (
install_tray_config_buttons,
install_tray_config_form,
populate_first_run_window,
tray_settings_scroll_and_footer,
validate_config_form,
)
from utils.default_config import default_tray_config
APP_NAME = "TgWsProxy"
APP_DIR = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config")) / APP_NAME
@@ -172,7 +172,7 @@ def setup_logging(verbose: bool = False, log_max_mb: float = 5):
str(LOG_FILE),
maxBytes=max(32 * 1024, log_max_mb * 1024 * 1024),
backupCount=0,
encoding='utf-8',
encoding="utf-8",
)
fh.setLevel(logging.DEBUG)
fh.setFormatter(
@@ -368,6 +368,7 @@ def _maybe_notify_update_async():
return
try:
from utils.update_check import RELEASES_PAGE_URL, get_status, run_check
run_check(__version__)
st = get_status()
if not st.get("has_update"):
@@ -375,8 +376,7 @@ def _maybe_notify_update_async():
url = (st.get("html_url") or "").strip() or RELEASES_PAGE_URL
ver = st.get("latest") or "?"
text = (
f"Доступна новая версия: {ver}\n\n"
f"Открыть страницу релиза в браузере?"
f"Доступна новая версия: {ver}\n\nОткрыть страницу релиза в браузере?"
)
if _ask_yes_no_dialog(text, "TG WS Proxy — обновление"):
webbrowser.open(url)
@@ -436,13 +436,16 @@ def _edit_config_dialog():
scroll, footer = tray_settings_scroll_and_footer(ctk, frame, theme)
widgets = install_tray_config_form(
ctk, scroll, theme, cfg, DEFAULT_CONFIG,
ctk,
scroll,
theme,
cfg,
DEFAULT_CONFIG,
show_autostart=False,
)
def on_save():
merged = validate_config_form(
widgets, DEFAULT_CONFIG, include_autostart=False)
merged = validate_config_form(widgets, DEFAULT_CONFIG, include_autostart=False)
if isinstance(merged, str):
_show_error(merged)
return
@@ -470,12 +473,14 @@ def _edit_config_dialog():
root.destroy()
install_tray_config_buttons(
ctk, footer, theme, on_save=on_save, on_cancel=on_cancel)
ctk, footer, theme, on_save=on_save, on_cancel=on_cancel
)
try:
root.mainloop()
finally:
import tkinter as tk
try:
if root.winfo_exists():
root.destroy()
@@ -551,13 +556,13 @@ def _show_first_run():
if open_tg:
_on_open_in_telegram()
populate_first_run_window(
ctk, root, theme, host=host, port=port, on_done=on_done)
populate_first_run_window(ctk, root, theme, host=host, port=port, on_done=on_done)
try:
root.mainloop()
finally:
import tkinter as tk
try:
if root.winfo_exists():
root.destroy()
@@ -642,8 +647,10 @@ def run_tray():
except Exception:
pass
setup_logging(_config.get("verbose", False),
log_max_mb=_config.get("log_max_mb", DEFAULT_CONFIG["log_max_mb"]))
setup_logging(
_config.get("verbose", False),
log_max_mb=_config.get("log_max_mb", DEFAULT_CONFIG["log_max_mb"]),
)
log.info("TG WS Proxy версия %s, tray app starting", __version__)
log.info("Config: %s", _config)
log.info("Log file: %s", LOG_FILE)