From 5a2ef3a696ddccbc1faef1e2e90f5b535ec24a0d Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 11 一月 2024 10:06:14 +0800
Subject: [PATCH] 看盘网页修改/接口本地化代理

---
 main.py |   40 ++++++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/main.py b/main.py
index 7f9572b..625e8d7 100644
--- a/main.py
+++ b/main.py
@@ -6,6 +6,8 @@
 import time
 from multiprocessing import freeze_support
 import sys
+from urllib.parse import urlparse, parse_qs
+
 import torch
 import win32gui
 from PyQt5.QtGui import QFont, QPalette, QColor, QTextOption
@@ -19,10 +21,14 @@
 
 import constant
 import gui_wx
-import network_util
+from network_delegate_manager import LocalKanPanNetworkDelegate
+from utils import network_util
 import setting
-import tool
+from utils  import tool
 import win32_util
+from juejin_core import JueJinApi
+from kpl import kpl_util, kpl_api
+from kpl.kpl_data_manager import KPLLimitUpDataManager
 
 freeze_support()
 
@@ -41,9 +47,23 @@
         self.__webview = webview
         self.signal_request.connect(self.__request_result_callback)
 
+
+
     def __http_request(self, url, callback_info):
         try:
-            result = network_util.http_get(url)
+            # 浠g悊璇锋眰缁撴灉
+            result, need_delegate = LocalKanPanNetworkDelegate.http_delegate_request(url)
+            if not need_delegate:
+                result = network_util.http_get(url)
+            print("璇锋眰缁撴灉锛�", result)
+            self.signal_request.emit(callback_info[0], callback_info[1], result)
+            return result
+        except Exception as e:
+            logging.exception(e)
+
+    def __socket_request(self, text, callback_info):
+        try:
+            result = network_util.socket_request(text)
             print("璇锋眰缁撴灉锛�", result)
             self.signal_request.emit(callback_info[0], callback_info[1], result)
             return result
@@ -62,10 +82,13 @@
         t1.setDaemon(True)
         t1.start()
 
-    @pyqtSlot(str, result=str)
-    def socket_request(self, text):
+    @pyqtSlot(str, str)
+    def socket_request(self, text, callback_info):
         print("socket_request", text)
-        return network_util.socket_request(json.loads(text))
+        callback_info = json.loads(callback_info)
+        t1 = threading.Thread(target=lambda: self.__socket_request(text, callback_info))
+        t1.setDaemon(True)
+        t1.start()
 
     # 鑾峰彇瀹㈡埛绔疘D
     @pyqtSlot(result=str)
@@ -236,7 +259,8 @@
         self.signal_update_kpl.emit(datas)
 
     def set_target_code(self, code):
-        print("set_target_code")
+        print("set_target_code", code)
+        # 娴嬭瘯
         self.webview.page().runJavaScript(f"app.set_target_code('{code}')")
 
     def closeEvent(self, event):
@@ -382,7 +406,6 @@
         view_ = menubar.addMenu('&鎵撳紑鍒嗘椂')
         view_.aboutToShow.connect(__show_main_callback)
 
-
     def __init__(self, wx_pipe):
         super().__init__()
         self.wx_pipe = wx_pipe
@@ -431,6 +454,7 @@
         # 鍚庡彴杩愯
         t1.setDaemon(True)
         t1.start()
+        threading.Thread(target=KPLLimitUpDataManager().run, daemon=True).start()
 
     def closeEvent(self, event):
         event.accept()

--
Gitblit v1.8.0