From 7fa16dfe511d6c0803061cba29965b6be2e3d953 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 06 八月 2024 16:34:34 +0800
Subject: [PATCH] 页面修改

---
 main.py |   35 ++++++++++++++++++++++++++++++++++-
 1 files changed, 34 insertions(+), 1 deletions(-)

diff --git a/main.py b/main.py
index dace682..192fca7 100644
--- a/main.py
+++ b/main.py
@@ -1,4 +1,5 @@
 import base64
+import ctypes
 import hashlib
 import json
 import logging
@@ -7,9 +8,12 @@
 import threading
 import time
 import sys
+from functools import partial
 from multiprocessing import Pipe, Process, freeze_support
 
 import torch
+import win32api
+import win32con
 import win32gui
 from PyQt5.QtGui import QFont, QPalette, QColor, QTextOption
 
@@ -22,7 +26,7 @@
 import constant
 import gui_wx
 from network_delegate_manager import LocalKanPanNetworkDelegate
-from utils import network_util, xgb_api, ths_util
+from utils import network_util, xgb_api, ths_util, ths_ocr_util
 import setting
 from utils import tool
 import win32_util
@@ -258,11 +262,29 @@
         self.python_bridge = SecondWindowBridgeClass(self.webview)
         channel.registerObject("Bridge", self.python_bridge)
 
+        # win32gui.SetWindowLong(self.winId(), win32con.GWL_WNDPROC, self.handleCustomMessage)
+
         # self.signal_update_kpl.connect(self.set_kpl_data)
 
         # t1 = threading.Thread(target=self.update_kpl_func)
         # t1.setDaemon(True)
         # t1.start()
+
+    # 鑷畾涔夋秷鎭鐞嗗嚱鏁�
+    def handleCustomMessage(self, hwnd, msg, wparam, lparam):
+        if msg == win32con.WM_USER + 1024:
+            # 瑙f瀽鏁版嵁
+            # try:
+            #     code = ctypes.cast(lparam, ctypes.py_object).value
+            #     print(code)
+            # except:
+            #     pass
+            pass
+
+            # 澶勭悊鏁版嵁
+            # self.dataReceived.emit(intValue, stringValue)
+
+        return win32gui.DefWindowProc(hwnd, msg, wparam, lparam)
 
     def loadUrl(self, url):
         self.webview.load(QUrl(url))
@@ -348,6 +370,13 @@
         def __juejin_tick_download():
             self.wx_pipe.send(json.dumps({"type": "juejin_tick_download"}))
 
+        def __ths_ocr_code():
+            try:
+                code = ths_ocr_util.ocr_ths_code(always_save=True)
+                self.show_info(f"璇嗗埆鍒扮殑浠g爜锛歿code}")
+            except Exception as e:
+                self.show_warning(f"璇嗗埆鍑洪敊锛歿str(e)}")
+
         def __download_codes():
             try:
                 result = self.__request("", 72)
@@ -423,6 +452,10 @@
         action.triggered.connect(__juejin_tick_download)
         setting_.addAction(action)
 
+        action = QAction("&鍚岃姳椤轰唬鐮佽瘑鍒�", self)
+        action.triggered.connect(__ths_ocr_code)
+        setting_.addAction(action)
+
         auto_ = menubar.addMenu('&鑷姩鍖�')
         action = QAction("&鍚岃姳椤鸿缃�", self)
         action.triggered.connect(__manage_ths_pos)

--
Gitblit v1.8.0