Skip to content

Commit

Permalink
优化import,减少依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
LC044 committed Nov 22, 2023
1 parent 4bd0e1a commit 4340556
Show file tree
Hide file tree
Showing 12 changed files with 150 additions and 121 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ app/DataBase/Msg/*
*.db
*.pyc
*.log
*.spec
test*
68 changes: 38 additions & 30 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
description = [
'1. 支持获取个人信息\n',
'2. 支持显示聊天界面\n',
'3. 支持导出scv格式的聊天记录\n',
'3. 支持导出聊天记录\n * csv\n * html\n',
'4. 查找联系人\n',
]
20 changes: 16 additions & 4 deletions app/decrypt/get_wx_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,25 @@ def read_info(version_list, is_logging=False):
return result


import os
import sys


def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path)


@log
def get_info():
VERSION_LIST_PATH = "app/decrypt/version_list.json"

with open(VERSION_LIST_PATH, "r", encoding="utf-8") as f:
VERSION_LIST = json.load(f)

try:
with open(VERSION_LIST_PATH, "r", encoding="utf-8") as f:
VERSION_LIST = json.load(f)
except:
with open(resource_path(VERSION_LIST_PATH), "r", encoding="utf-8") as f:
VERSION_LIST = json.load(f)
result = read_info(VERSION_LIST, True) # 读取微信信息
return result

Expand Down
12 changes: 7 additions & 5 deletions app/log/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
from functools import wraps

filename = time.strftime("%Y-%m-%d", time.localtime(time.time()))
if not os.path.exists('./app/log/logs'):
os.mkdir('./app/log/logs')
logger = logging.getLogger('test')
logger.setLevel(level=logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(filename)s[line:%(lineno)d] - %(levelname)s: %(message)s')
file_handler = logging.FileHandler(f'./app/log/logs/{filename}-log.log')
try:
if not os.path.exists('./app/log/logs'):
os.mkdir('./app/log/logs')
file_handler = logging.FileHandler(f'./app/log/logs/{filename}-log.log')
except:
file_handler = logging.FileHandler(f'{filename}-log.log')

file_handler.setLevel(level=logging.INFO)
file_handler.setFormatter(formatter)

stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
stream_handler.setFormatter(formatter)

logger.addHandler(file_handler)
logger.addHandler(stream_handler)

Expand Down
3 changes: 0 additions & 3 deletions app/ui_pc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from . import mainview

__all__ = ['mainview']
16 changes: 5 additions & 11 deletions app/ui_pc/mainview.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
"""
import json
import os.path
from random import randint

from PyQt5.QtCore import *
from PyQt5.QtGui import QPixmap
from PyQt5.QtGui import QPixmap, QFont
from PyQt5.QtWidgets import *

from app import config
Expand All @@ -21,7 +20,7 @@
from . import mainwindow
from .chat import ChatWindow
from .contact import ContactWindow
from .tool import ToolWindow
from .tool.tool_window import ToolWindow
from ..person import MePC

# 美化样式表
Expand Down Expand Up @@ -78,6 +77,7 @@ def __init__(self, username, parent=None):
self.load_data()
self.load_num = 0
self.label = QLabel(self)

self.label.setGeometry((self.width() - 300) // 2, (self.height() - 100) // 2, 300, 100)
self.label.setPixmap(QPixmap('./app/data/icons/loading.svg'))

Expand Down Expand Up @@ -120,19 +120,13 @@ def init_ui(self):
self.stackedWidget.addWidget(self.chat_window)
self.contact_window = ContactWindow()
self.stackedWidget.addWidget(self.contact_window)
label = QLabel('我是页面')
label = QLabel('该功能暂不支持哦')
label.setFont(QFont("微软雅黑", 50))
label.setAlignment(Qt.AlignCenter)
# 设置label的背景颜色(这里随机)
# 这里加了一个margin边距(方便区分QStackedWidget和QLabel的颜色)
label.setStyleSheet('background: rgb(%d, %d, %d);margin: 50px;' % (
randint(0, 255), randint(0, 255), randint(0, 255)))
self.stackedWidget.addWidget(label)
tool_window.load_finish_signal.connect(self.loading)
self.contact_window.load_finish_signal.connect(self.loading)
self.chat_window.load_finish_signal.connect(self.loading)
# self.load_thread = LoadWindowThread()
# self.load_thread.okSignal.connect(self.load_window)
# self.load_thread.start()

def setCurrentIndex(self, row):
self.stackedWidget.setCurrentIndex(row)
Expand Down
2 changes: 0 additions & 2 deletions app/ui_pc/tool/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from .tool_window import ToolWindow

__all__ = ['ToolWindow']
Loading

0 comments on commit 4340556

Please sign in to comment.