55from flask import Flask , render_template , jsonify , request
66from .logic import FolderManager
77
8+ import sys
9+
810# Use APPDATA for persistent config storage
911def get_config_dir ():
1012 if os .name == 'nt' :
@@ -24,10 +26,18 @@ def get_config_dir():
2426
2527CONFIG_FILE = os .path .join (APPDATA_DIR , 'config.json' )
2628
27- # Templates are now inside the package
28- TEMPLATE_FOLDER = os .path .join (os .path .dirname (__file__ ), 'templates' )
29+ # Define paths for templates and static files
30+ if getattr (sys , 'frozen' , False ):
31+ # Running in PyInstaller bundle
32+ BASE_DIR = os .path .join (sys ._MEIPASS , 'manager' )
33+ else :
34+ # Running in normal Python environment
35+ BASE_DIR = os .path .dirname (__file__ )
36+
37+ TEMPLATE_FOLDER = os .path .join (BASE_DIR , 'templates' )
38+ STATIC_FOLDER = os .path .join (BASE_DIR , 'static' )
2939
30- app = Flask (__name__ , template_folder = TEMPLATE_FOLDER )
40+ app = Flask (__name__ , template_folder = TEMPLATE_FOLDER , static_folder = STATIC_FOLDER )
3141
3242# 初始化逻辑类
3343folder_logic = FolderManager (CONFIG_FILE )
@@ -74,6 +84,12 @@ def select_folder_dialog():
7484 # Create a hidden root window
7585 root = tk .Tk ()
7686 root .withdraw () # Hide the main window
87+
88+ # Set custom icon if exists
89+ icon_path = os .path .join (STATIC_FOLDER , 'favicon.ico' )
90+ if os .path .exists (icon_path ):
91+ root .iconbitmap (icon_path )
92+
7793 root .attributes ('-topmost' , True ) # Make it appear on top
7894
7995 # Open directory picker
0 commit comments