From f28ac0166536a2a4b68cac685a41ea667f60f7e9 Mon Sep 17 00:00:00 2001
From: yj <2077506045@qq.com>
Date: 星期三, 03 九月 2025 14:43:03 +0800
Subject: [PATCH] 兼容企业微信

---
 startup.py |   63 +++++++++++++------------------
 1 files changed, 26 insertions(+), 37 deletions(-)

diff --git a/startup.py b/startup.py
index dad9b0e..2f02c8d 100644
--- a/startup.py
+++ b/startup.py
@@ -11,7 +11,7 @@
 
 def get_exe_dir():
     """鑾峰彇exe鏂囦欢鎵�鍦ㄧ洰褰�"""
-    if getattr(sys, 'frozen', False):
+    if getattr(sys, "frozen", False):
         # 濡傛灉鏄墦鍖呭悗鐨別xe鏂囦欢
         return os.path.dirname(sys.executable)
     else:
@@ -22,26 +22,26 @@
 def ensure_directories():
     """纭繚蹇呰鐨勭洰褰曞瓨鍦�"""
     exe_dir = get_exe_dir()
-    
+
     # 鍒涘缓鏃ュ織鐩綍
-    logs_dir = os.path.join(exe_dir, 'logs')
+    logs_dir = os.path.join(exe_dir, "logs")
     if not os.path.exists(logs_dir):
         os.makedirs(logs_dir)
         print(f"鍒涘缓鏃ュ織鐩綍: {logs_dir}")
-    
+
     return exe_dir
 
 
 def ensure_config_file():
     """纭繚閰嶇疆鏂囦欢瀛樺湪"""
     exe_dir = get_exe_dir()
-    config_file = os.path.join(exe_dir, 'config.json')
-    
+    config_file = os.path.join(exe_dir, "config.json")
+
     if not os.path.exists(config_file):
         # 濡傛灉config.json涓嶅瓨鍦紝灏濊瘯澶嶅埗鐢熶骇閰嶇疆妯℃澘
-        production_config = os.path.join(exe_dir, 'config.production.json')
-        example_config = os.path.join(exe_dir, 'config.example.json')
-        
+        production_config = os.path.join(exe_dir, "config.production.json")
+        example_config = os.path.join(exe_dir, "config.example.json")
+
         if os.path.exists(production_config):
             shutil.copy2(production_config, config_file)
             print(f"澶嶅埗鐢熶骇閰嶇疆鏂囦欢: {production_config} -> {config_file}")
@@ -54,41 +54,30 @@
                 "database": {
                     "url": "mysql+pymysql://root:password@localhost:3306/ecloud_dify"
                 },
-                "redis": {
-                    "url": "redis://localhost:6379/0"
-                },
+                "redis": {"url": "redis://localhost:6379/0"},
                 "ecloud": {
                     "base_url": "http://125.122.152.142:9899",
                     "authorization": "your_ecloud_authorization_token",
-                    "w_id": "your_ecloud_w_id"
+                    "w_id": "your_ecloud_w_id",
                 },
                 "dify": {
                     "base_url": "https://api.dify.ai/v1",
-                    "api_key": "your_dify_api_key"
+                    "api_key": "your_dify_api_key",
                 },
-                "server": {
-                    "host": "0.0.0.0",
-                    "port": 7979,
-                    "debug": False
-                },
-                "logging": {
-                    "level": "INFO",
-                    "file": "logs/app.log"
-                },
+                "server": {"host": "0.0.0.0", "port": 7979, "debug": False},
+                "logging": {"level": "INFO", "file": "logs/app.log"},
                 "message_processing": {
                     "max_retry_count": 3,
                     "retry_delay": 5,
-                    "queue_timeout": 300
+                    "queue_timeout": 300,
                 },
-                "customer_service": {
-                    "names": ["瀹㈡湇1", "瀹㈡湇2"]
-                }
+                "customer_service": {"names": ["瀹㈡湇1", "瀹㈡湇2"]},
             }
-            
-            with open(config_file, 'w', encoding='utf-8') as f:
+
+            with open(config_file, "w", encoding="utf-8") as f:
                 json.dump(default_config, f, indent=2, ensure_ascii=False)
             print(f"鍒涘缓榛樿閰嶇疆鏂囦欢: {config_file}")
-    
+
     return config_file
 
 
@@ -96,24 +85,24 @@
     """璁剧疆杩愯鐜"""
     exe_dir = ensure_directories()
     config_file = ensure_config_file()
-    
+
     # 璁剧疆宸ヤ綔鐩綍涓篹xe鎵�鍦ㄧ洰褰�
     os.chdir(exe_dir)
     print(f"璁剧疆宸ヤ綔鐩綍: {exe_dir}")
-    
+
     return exe_dir, config_file
 
 
 if __name__ == "__main__":
     setup_environment()
-    
+
     # 瀵煎叆骞跺惎鍔ㄤ富搴旂敤
     try:
         from main import app
         import uvicorn
         from config import settings
         from loguru import logger
-        
+
         # 閰嶇疆鏃ュ織
         logger.add(
             settings.log_file,
@@ -122,9 +111,9 @@
             level=settings.log_level,
             format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {name}:{function}:{line} - {message}",
         )
-        
+
         logger.info("鍚姩E浜戠瀹�-DifyAI瀵规帴鏈嶅姟")
-        
+
         # 鍚姩鏈嶅姟
         uvicorn.run(
             app,
@@ -132,7 +121,7 @@
             port=settings.server_port,
             log_level=settings.log_level.lower(),
         )
-        
+
     except Exception as e:
         print(f"鍚姩澶辫触: {e}")
         input("鎸変换鎰忛敭閫�鍑�...")

--
Gitblit v1.9.1