匹配回收,bug修复
This commit is contained in:
24
app/main.py
24
app/main.py
@@ -19,6 +19,7 @@ import threading
|
||||
import time
|
||||
import requests
|
||||
import subprocess
|
||||
import atexit
|
||||
|
||||
from amazon.del_brand import kill_process
|
||||
|
||||
@@ -39,6 +40,21 @@ print(f"""
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
APP_URL = "http://127.0.0.1:5123"
|
||||
PORT = 5123
|
||||
_shutdown_started = False
|
||||
|
||||
|
||||
def cleanup_before_exit():
|
||||
global _shutdown_started
|
||||
if _shutdown_started:
|
||||
return
|
||||
_shutdown_started = True
|
||||
try:
|
||||
kill_process('v6')
|
||||
except Exception as e:
|
||||
print(f"【退出前】关闭紫鸟浏览器进程异常: {str(e)}")
|
||||
|
||||
|
||||
atexit.register(cleanup_before_exit)
|
||||
|
||||
|
||||
def generate_images(params):
|
||||
@@ -57,6 +73,11 @@ class WindowAPI:
|
||||
window.events.restored += lambda _: setattr(self, '_is_maximized', False)
|
||||
|
||||
def close(self):
|
||||
try:
|
||||
self._window.destroy()
|
||||
except:
|
||||
pass
|
||||
return
|
||||
try:
|
||||
kill_process('v6')
|
||||
except Exception as e:
|
||||
@@ -369,6 +390,7 @@ def start_task_monitor():
|
||||
|
||||
|
||||
def on_window_closing():
|
||||
return
|
||||
"""窗口关闭事件处理器,执行与 close() 方法相同的清理逻辑"""
|
||||
# 先关闭窗口,避免看起来卡着
|
||||
try:
|
||||
@@ -419,7 +441,7 @@ def main():
|
||||
window.expose(api.close, api.minimize, api.maximize, api.toggle_maximize, generate_images, api.save_image, api.save_image_to_folder, api.select_folder, api.select_brand_xlsx_files, api.select_brand_folder,
|
||||
api.save_file_from_url, api.save_template_xlsx,api.save_template_zip,api.upload_file_to_java,api.open_external_url,api.enqueue_json,api.get_detail_del,api.save_file_from_url_new)
|
||||
webview.start(
|
||||
debug=False,
|
||||
debug=True,
|
||||
storage_path=cache_path,
|
||||
private_mode=False
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user