增加登陆日志留存模块
Showing
2 changed files
with
74 additions
and
2 deletions
| ... | @@ -5,7 +5,11 @@ a = Analysis( | ... | @@ -5,7 +5,11 @@ a = Analysis( |
| 5 | ['image_generator.py'], | 5 | ['image_generator.py'], |
| 6 | pathex=[], | 6 | pathex=[], |
| 7 | binaries=[], | 7 | binaries=[], |
| 8 | datas=[('config.json', '.')], | 8 | datas=[ |
| 9 | ('config.json', '.'), | ||
| 10 | ('zb100_windows.ico', '.'), | ||
| 11 | ('zb100_mac.icns', '.') | ||
| 12 | ], | ||
| 9 | hiddenimports=[], | 13 | hiddenimports=[], |
| 10 | hookspath=[], | 14 | hookspath=[], |
| 11 | hooksconfig={}, | 15 | hooksconfig={}, | ... | ... |
| ... | @@ -95,9 +95,32 @@ class LoginDialog(QDialog): | ... | @@ -95,9 +95,32 @@ class LoginDialog(QDialog): |
| 95 | self.password_changed = False | 95 | self.password_changed = False |
| 96 | self.current_password_hash = "" | 96 | self.current_password_hash = "" |
| 97 | 97 | ||
| 98 | self.set_window_icon() | ||
| 98 | self.setup_ui() | 99 | self.setup_ui() |
| 99 | self.apply_styles() | 100 | self.apply_styles() |
| 100 | 101 | ||
| 102 | def set_window_icon(self): | ||
| 103 | """Set window icon based on platform""" | ||
| 104 | if getattr(sys, 'frozen', False): | ||
| 105 | # Running as compiled executable | ||
| 106 | if platform.system() == 'Windows': | ||
| 107 | icon_path = os.path.join(sys._MEIPASS, 'zb100_windows.ico') | ||
| 108 | elif platform.system() == 'Darwin': | ||
| 109 | icon_path = os.path.join(sys._MEIPASS, 'zb100_mac.icns') | ||
| 110 | else: | ||
| 111 | icon_path = None | ||
| 112 | else: | ||
| 113 | # Running as script | ||
| 114 | if platform.system() == 'Windows': | ||
| 115 | icon_path = 'zb100_windows.ico' | ||
| 116 | elif platform.system() == 'Darwin': | ||
| 117 | icon_path = 'zb100_mac.icns' | ||
| 118 | else: | ||
| 119 | icon_path = None | ||
| 120 | |||
| 121 | if icon_path and os.path.exists(icon_path): | ||
| 122 | self.setWindowIcon(QIcon(icon_path)) | ||
| 123 | |||
| 101 | def setup_ui(self): | 124 | def setup_ui(self): |
| 102 | """Build login dialog UI""" | 125 | """Build login dialog UI""" |
| 103 | self.setWindowTitle("登录 - AI 图像生成器") | 126 | self.setWindowTitle("登录 - AI 图像生成器") |
| ... | @@ -434,9 +457,32 @@ class ImageGeneratorWindow(QMainWindow): | ... | @@ -434,9 +457,32 @@ class ImageGeneratorWindow(QMainWindow): |
| 434 | self.saved_password_hash = "" | 457 | self.saved_password_hash = "" |
| 435 | 458 | ||
| 436 | self.load_config() | 459 | self.load_config() |
| 460 | self.set_window_icon() | ||
| 437 | self.setup_ui() | 461 | self.setup_ui() |
| 438 | self.apply_styles() | 462 | self.apply_styles() |
| 439 | 463 | ||
| 464 | def set_window_icon(self): | ||
| 465 | """Set window icon based on platform""" | ||
| 466 | if getattr(sys, 'frozen', False): | ||
| 467 | # Running as compiled executable | ||
| 468 | if platform.system() == 'Windows': | ||
| 469 | icon_path = os.path.join(sys._MEIPASS, 'zb100_windows.ico') | ||
| 470 | elif platform.system() == 'Darwin': | ||
| 471 | icon_path = os.path.join(sys._MEIPASS, 'zb100_mac.icns') | ||
| 472 | else: | ||
| 473 | icon_path = None | ||
| 474 | else: | ||
| 475 | # Running as script | ||
| 476 | if platform.system() == 'Windows': | ||
| 477 | icon_path = 'zb100_windows.ico' | ||
| 478 | elif platform.system() == 'Darwin': | ||
| 479 | icon_path = 'zb100_mac.icns' | ||
| 480 | else: | ||
| 481 | icon_path = None | ||
| 482 | |||
| 483 | if icon_path and os.path.exists(icon_path): | ||
| 484 | self.setWindowIcon(QIcon(icon_path)) | ||
| 485 | |||
| 440 | def get_config_dir(self): | 486 | def get_config_dir(self): |
| 441 | """Get the appropriate directory for config files based on platform and mode""" | 487 | """Get the appropriate directory for config files based on platform and mode""" |
| 442 | if getattr(sys, 'frozen', False): | 488 | if getattr(sys, 'frozen', False): |
| ... | @@ -555,7 +601,7 @@ class ImageGeneratorWindow(QMainWindow): | ... | @@ -555,7 +601,7 @@ class ImageGeneratorWindow(QMainWindow): |
| 555 | self.img_scroll.setWidgetResizable(True) | 601 | self.img_scroll.setWidgetResizable(True) |
| 556 | self.img_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) | 602 | self.img_scroll.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) |
| 557 | self.img_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) | 603 | self.img_scroll.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff) |
| 558 | self.img_scroll.setFixedHeight(140) | 604 | self.img_scroll.setFixedHeight(160) |
| 559 | 605 | ||
| 560 | self.img_container = QWidget() | 606 | self.img_container = QWidget() |
| 561 | self.img_layout = QHBoxLayout() | 607 | self.img_layout = QHBoxLayout() |
| ... | @@ -1118,6 +1164,28 @@ def main(): | ... | @@ -1118,6 +1164,28 @@ def main(): |
| 1118 | # Create QApplication | 1164 | # Create QApplication |
| 1119 | app = QApplication(sys.argv) | 1165 | app = QApplication(sys.argv) |
| 1120 | 1166 | ||
| 1167 | # Set application icon | ||
| 1168 | if getattr(sys, 'frozen', False): | ||
| 1169 | # Running as compiled executable | ||
| 1170 | if platform.system() == 'Windows': | ||
| 1171 | icon_path = os.path.join(sys._MEIPASS, 'zb100_windows.ico') | ||
| 1172 | elif platform.system() == 'Darwin': | ||
| 1173 | icon_path = os.path.join(sys._MEIPASS, 'zb100_mac.icns') | ||
| 1174 | else: | ||
| 1175 | icon_path = None | ||
| 1176 | else: | ||
| 1177 | # Running as script | ||
| 1178 | if platform.system() == 'Windows': | ||
| 1179 | icon_path = 'zb100_windows.ico' | ||
| 1180 | elif platform.system() == 'Darwin': | ||
| 1181 | icon_path = 'zb100_mac.icns' | ||
| 1182 | else: | ||
| 1183 | icon_path = None | ||
| 1184 | |||
| 1185 | if icon_path and os.path.exists(icon_path): | ||
| 1186 | app_icon = QIcon(icon_path) | ||
| 1187 | app.setWindowIcon(app_icon) | ||
| 1188 | |||
| 1121 | # Check database config | 1189 | # Check database config |
| 1122 | if not db_config: | 1190 | if not db_config: |
| 1123 | QMessageBox.critical(None, "配置错误", | 1191 | QMessageBox.critical(None, "配置错误", | ... | ... |
-
Please register or sign in to post a comment