refactor(app): 重构图片压缩功能并优化类型注解
- 使用 Path 对象替换字符串表示文件路径,提高代码可读性和功能 - 优化类型注解,包括函数参数和返回值- 重构 ImageUtils.compress_image_if_needed 方法,简化逻辑并提高性能 - 更新 notification.py 中使用该方法的代码,直接返回压缩后的 Path 对象
This commit is contained in:
@@ -273,12 +273,11 @@ class Notification(QObject):
|
||||
)
|
||||
return f"使用企业微信群机器人推送通知时出错:{err}"
|
||||
|
||||
def CompanyWebHookBotPushImage(self, image_path: str, webhook_url: str) -> bool:
|
||||
def CompanyWebHookBotPushImage(self, image_path: Path, webhook_url: str) -> bool:
|
||||
"""使用企业微信群机器人推送图片通知"""
|
||||
try:
|
||||
# 压缩图片
|
||||
final_image_path = ImageUtils.compress_image_if_needed(str(image_path))
|
||||
final_image_path = Path(final_image_path)
|
||||
final_image_path = ImageUtils.compress_image_if_needed(image_path)
|
||||
|
||||
# 检查图片是否存在
|
||||
if not final_image_path.exists():
|
||||
|
||||
Reference in New Issue
Block a user