Update: Refactor to absolute imports, fix QPS limits, and enhance Gitea sync with SQLite support
This commit is contained in:
+19
-10
@@ -13,7 +13,7 @@ from app.core.utils.log_utils import set_log_level
|
||||
|
||||
from .theme import THEMES, get_theme_mode, set_theme_mode, create_modern_button, create_card_frame
|
||||
from .logging_ui import add_to_log, poll_log_queue
|
||||
from .ui_widgets import StatusBar
|
||||
from .ui_widgets import StatusBar, ToolTip
|
||||
from .user_settings import (
|
||||
load_user_settings, save_user_settings, refresh_recent_list_widget,
|
||||
_extract_path_from_recent_item, clear_recent_files, RECENT_LIST_WIDGET,
|
||||
@@ -33,6 +33,7 @@ from .config_dialog import show_config_dialog
|
||||
from .barcode_editor import edit_barcode_mappings
|
||||
from .shortcuts import bind_keyboard_shortcuts
|
||||
from app.core.utils.dialog_utils import show_cloud_sync_dialog
|
||||
from .db_viewer import show_db_viewer
|
||||
|
||||
|
||||
def _init_window():
|
||||
@@ -100,8 +101,14 @@ def _create_left_panel(content_frame, theme, log_text, status_bar):
|
||||
pipeline_section.pack(fill=tk.X, pady=(0, 8))
|
||||
pipeline_frame = tk.Frame(pipeline_section, bg=theme["card_bg"])
|
||||
pipeline_frame.pack(fill=tk.X, padx=8, pady=6)
|
||||
create_modern_button(pipeline_frame, "一键处理", lambda: run_pipeline_directly(log_text, status_bar), "primary", px_width=150, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(pipeline_frame, "一键处理全部图片", lambda: batch_process_all_inputs(log_text, status_bar), "primary", px_width=180, px_height=32).pack(anchor='w', pady=3)
|
||||
|
||||
btn_onekey = create_modern_button(pipeline_frame, "一键处理", lambda: run_pipeline_directly(log_text, status_bar), "primary", px_width=150, px_height=32)
|
||||
btn_onekey.pack(anchor='w', pady=3)
|
||||
ToolTip(btn_onekey.winfo_children()[0], "选择图片或Excel,自动完成OCR识别和采购单生成全流程")
|
||||
|
||||
btn_batch = create_modern_button(pipeline_frame, "批量处理", lambda: batch_process_all_inputs(log_text, status_bar), "primary", px_width=150, px_height=32)
|
||||
btn_batch.pack(anchor='w', pady=3)
|
||||
ToolTip(btn_batch.winfo_children()[0], "扫描 data/input 文件夹,处理所有未识别的图片")
|
||||
|
||||
# OCR处理区
|
||||
core_section = tk.LabelFrame(
|
||||
@@ -220,7 +227,7 @@ def _create_recent_files_section(parent, theme, log_text):
|
||||
create_modern_button(rf_btns, "清理无效", purge_invalid, "primary", px_width=72, px_height=32).pack(side=tk.LEFT, padx=(3, 0))
|
||||
|
||||
|
||||
def _create_right_panel(content_frame, theme, log_text, root):
|
||||
def _create_right_panel(content_frame, theme, log_text, root, status_bar, config):
|
||||
"""创建右侧面板:快捷操作、系统设置"""
|
||||
right_panel = create_card_frame(content_frame)
|
||||
right_panel.pack(side=tk.RIGHT, fill=tk.BOTH, expand=False, padx=(5, 0), pady=5)
|
||||
@@ -240,12 +247,13 @@ def _create_right_panel(content_frame, theme, log_text, root):
|
||||
tk.Frame(tools_buttons_frame, bg=theme["card_bg"]).pack(fill=tk.X, pady=3)
|
||||
|
||||
create_modern_button(tools_buttons_frame, "打开结果目录", lambda: open_result_directory(), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "打开输出目录", lambda: os.startfile(ConfigManager().get_path('Paths', 'output_folder', fallback='data/output', create=True)), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "打开输入目录", lambda: os.startfile(ConfigManager().get_path('Paths', 'input_folder', fallback='data/input', create=True)), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "合并订单", lambda: merge_orders_with_status(log_text, StatusBar(root)), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "打开输出目录", lambda: os.startfile(config.get_path('Paths', 'output_folder', fallback='data/output', create=True)), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "打开输入目录", lambda: os.startfile(config.get_path('Paths', 'input_folder', fallback='data/input', create=True)), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "合并订单", lambda: merge_orders_with_status(log_text, status_bar), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "数据库内容", lambda: show_db_viewer(root, config=config), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "清除缓存", lambda: clean_cache(log_text), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "清理input/out文件", lambda: clean_data_files(log_text), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "清理result文件", lambda: clean_result_files(log_text), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(tools_buttons_frame, "清理结果文件", lambda: clean_result_files(log_text), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
|
||||
# 系统设置区
|
||||
settings_section = tk.LabelFrame(
|
||||
@@ -255,7 +263,7 @@ def _create_right_panel(content_frame, theme, log_text, root):
|
||||
settings_section.pack(fill=tk.X, pady=(0, 8))
|
||||
settings_buttons_frame = tk.Frame(settings_section, bg=theme["card_bg"])
|
||||
settings_buttons_frame.pack(fill=tk.X, padx=8, pady=6)
|
||||
create_modern_button(settings_buttons_frame, "系统设置", lambda: show_config_dialog(root, ConfigManager()), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(settings_buttons_frame, "系统设置", lambda: show_config_dialog(root, config), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(settings_buttons_frame, "条码映射", lambda: edit_barcode_mappings(log_text), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(settings_buttons_frame, "云端同步", lambda: show_cloud_sync_dialog(root), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
create_modern_button(settings_buttons_frame, "商品记忆库", lambda: show_memory_editor(root), "primary", px_width=132, px_height=32).pack(anchor='w', pady=3)
|
||||
@@ -448,6 +456,7 @@ def main():
|
||||
"""主函数"""
|
||||
try:
|
||||
root, theme, settings, dnd_supported = _init_window()
|
||||
config = ConfigManager()
|
||||
|
||||
# 主容器
|
||||
main_container = tk.Frame(root, bg=theme["bg"])
|
||||
@@ -469,7 +478,7 @@ def main():
|
||||
_create_left_panel(content_frame, theme, log_text, status_bar)
|
||||
|
||||
# 右侧面板
|
||||
_create_right_panel(content_frame, theme, log_text, root)
|
||||
_create_right_panel(content_frame, theme, log_text, root, status_bar, config)
|
||||
|
||||
# 拖拽区域
|
||||
_setup_drag_area(mid_container, theme, dnd_supported, log_text, status_bar)
|
||||
|
||||
Reference in New Issue
Block a user