feat(core): 邮箱推送功能调整,改由用户提供发信邮箱
This commit is contained in:
@@ -44,14 +44,15 @@ from qfluentwidgets import (
|
||||
TimeEdit,
|
||||
OptionsConfigItem,
|
||||
)
|
||||
|
||||
from typing import Union, List
|
||||
|
||||
from app.services import Crypto
|
||||
|
||||
class InputMessageBox(MessageBoxBase):
|
||||
|
||||
class LineEditMessageBox(MessageBoxBase):
|
||||
"""输入对话框"""
|
||||
|
||||
def __init__(self, parent, title: str, content: str, mode: str, list: list = None):
|
||||
def __init__(self, parent, title: str, content: str, mode: str):
|
||||
super().__init__(parent)
|
||||
self.title = SubtitleLabel(title)
|
||||
|
||||
@@ -60,10 +61,6 @@ class InputMessageBox(MessageBoxBase):
|
||||
self.input.setClearButtonEnabled(True)
|
||||
elif mode == "密码":
|
||||
self.input = PasswordLineEdit()
|
||||
elif mode == "选择":
|
||||
self.input = ComboBox()
|
||||
self.input.addItems(list)
|
||||
self.input.setCurrentIndex(-1)
|
||||
|
||||
self.input.setPlaceholderText(content)
|
||||
|
||||
@@ -72,8 +69,8 @@ class InputMessageBox(MessageBoxBase):
|
||||
self.viewLayout.addWidget(self.input)
|
||||
|
||||
|
||||
class SetMessageBox(MessageBoxBase):
|
||||
"""输入对话框"""
|
||||
class ComboBoxMessageBox(MessageBoxBase):
|
||||
"""选择对话框"""
|
||||
|
||||
def __init__(self, parent, title: str, content: List[str], list: List[List[str]]):
|
||||
super().__init__(parent)
|
||||
@@ -98,7 +95,7 @@ class SetMessageBox(MessageBoxBase):
|
||||
|
||||
|
||||
class LineEditSettingCard(SettingCard):
|
||||
"""Setting card with switch button"""
|
||||
"""Setting card with LineEdit"""
|
||||
|
||||
textChanged = Signal(str)
|
||||
|
||||
@@ -138,7 +135,49 @@ class LineEditSettingCard(SettingCard):
|
||||
self.LineEdit.setText(content)
|
||||
|
||||
|
||||
class PasswordLineEditSettingCard(SettingCard):
|
||||
"""Setting card with PasswordLineEdit"""
|
||||
|
||||
textChanged = Signal(str)
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
text,
|
||||
icon: Union[str, QIcon, FluentIconBase],
|
||||
title,
|
||||
content=None,
|
||||
configItem: ConfigItem = None,
|
||||
parent=None,
|
||||
):
|
||||
|
||||
super().__init__(icon, title, content, parent)
|
||||
self.configItem = configItem
|
||||
self.LineEdit = PasswordLineEdit(self)
|
||||
self.LineEdit.setMinimumWidth(250)
|
||||
self.LineEdit.setPlaceholderText(text)
|
||||
|
||||
if configItem:
|
||||
self.setValue(qconfig.get(configItem))
|
||||
configItem.valueChanged.connect(self.setValue)
|
||||
|
||||
self.hBoxLayout.addWidget(self.LineEdit, 0, Qt.AlignRight)
|
||||
self.hBoxLayout.addSpacing(16)
|
||||
|
||||
self.LineEdit.textChanged.connect(self.__textChanged)
|
||||
|
||||
def __textChanged(self, content: str):
|
||||
self.setValue(Crypto.win_encryptor(content))
|
||||
self.textChanged.emit(content)
|
||||
|
||||
def setValue(self, content: str):
|
||||
if self.configItem:
|
||||
qconfig.set(self.configItem, content)
|
||||
|
||||
self.LineEdit.setText(Crypto.win_decryptor(content))
|
||||
|
||||
|
||||
class SpinBoxSettingCard(SettingCard):
|
||||
"""Setting card with SpinBox"""
|
||||
|
||||
textChanged = Signal(int)
|
||||
|
||||
|
||||
@@ -59,10 +59,10 @@ import shutil
|
||||
from app.core import Config, MainInfoBar, Task_manager
|
||||
from app.services import Crypto
|
||||
from .Widget import (
|
||||
InputMessageBox,
|
||||
LineEditMessageBox,
|
||||
LineEditSettingCard,
|
||||
SpinBoxSettingCard,
|
||||
SetMessageBox,
|
||||
ComboBoxMessageBox,
|
||||
)
|
||||
|
||||
|
||||
@@ -123,16 +123,15 @@ class MemberManager(QWidget):
|
||||
def add_setting_box(self):
|
||||
"""添加一个脚本实例"""
|
||||
|
||||
choice = InputMessageBox(
|
||||
choice = ComboBoxMessageBox(
|
||||
self.window(),
|
||||
"选择一个脚本类型并添加相应脚本实例",
|
||||
"选择脚本类型",
|
||||
"选择",
|
||||
["MAA"],
|
||||
"选择一个脚本类型以添加相应脚本实例",
|
||||
["选择脚本类型"],
|
||||
[["MAA"]],
|
||||
)
|
||||
if choice.exec() and choice.input.currentIndex() != -1:
|
||||
if choice.exec() and choice.input[0].currentIndex() != -1:
|
||||
|
||||
if choice.input.currentText() == "MAA":
|
||||
if choice.input[0].currentText() == "MAA":
|
||||
|
||||
index = len(self.member_manager.search_member()) + 1
|
||||
|
||||
@@ -295,7 +294,7 @@ class MemberManager(QWidget):
|
||||
def show_password(self):
|
||||
|
||||
if Config.PASSWORD == "":
|
||||
choice = InputMessageBox(
|
||||
choice = LineEditMessageBox(
|
||||
self.window(),
|
||||
"请输入管理密钥",
|
||||
"管理密钥",
|
||||
@@ -694,7 +693,7 @@ class MaaSettingBox(QWidget):
|
||||
user_list = [_[0] for _ in data if _[15] == "simple"]
|
||||
set_list = ["自定义基建"]
|
||||
|
||||
choice = SetMessageBox(
|
||||
choice = ComboBoxMessageBox(
|
||||
self.window(),
|
||||
"用户选项配置",
|
||||
["选择要配置的用户", "选择要配置的选项"],
|
||||
@@ -734,7 +733,7 @@ class MaaSettingBox(QWidget):
|
||||
user_list = [_[0] for _ in data if _[15] == "beta"]
|
||||
set_list = ["MAA日常配置", "MAA剿灭配置"]
|
||||
|
||||
choice = SetMessageBox(
|
||||
choice = ComboBoxMessageBox(
|
||||
self.window(),
|
||||
"用户选项配置",
|
||||
["选择要配置的用户", "选择要配置的选项"],
|
||||
@@ -989,7 +988,7 @@ class MaaSettingBox(QWidget):
|
||||
item = QTableWidgetItem("******")
|
||||
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
||||
else:
|
||||
result = Crypto.decryptx(value, Config.PASSWORD)
|
||||
result = Crypto.AUTO_decryptor(value, Config.PASSWORD)
|
||||
item = QTableWidgetItem(result)
|
||||
if result == "管理密钥错误":
|
||||
item.setFlags(
|
||||
@@ -1056,7 +1055,7 @@ class MaaSettingBox(QWidget):
|
||||
item = QTableWidgetItem("******")
|
||||
item.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEnabled)
|
||||
else:
|
||||
result = Crypto.decryptx(value, Config.PASSWORD)
|
||||
result = Crypto.AUTO_decryptor(value, Config.PASSWORD)
|
||||
item = QTableWidgetItem(result)
|
||||
if result == "管理密钥错误":
|
||||
item.setFlags(
|
||||
@@ -1127,7 +1126,7 @@ class MaaSettingBox(QWidget):
|
||||
games[game_in.strip()] = game_out.strip()
|
||||
text = games.get(text, text)
|
||||
if item.column() == 11: # 密码
|
||||
text = Crypto.encryptx(text)
|
||||
text = Crypto.AUTO_encryptor(text)
|
||||
|
||||
# 保存至本地数据库
|
||||
if text != "":
|
||||
@@ -1145,7 +1144,7 @@ class MaaSettingBox(QWidget):
|
||||
self.update_user_info("normal")
|
||||
return None
|
||||
if item.column() == 6: # 密码
|
||||
text = Crypto.encryptx(text)
|
||||
text = Crypto.AUTO_encryptor(text)
|
||||
|
||||
# 保存至本地数据库
|
||||
if text != "":
|
||||
@@ -1227,7 +1226,7 @@ class MaaSettingBox(QWidget):
|
||||
Config.cur.execute(
|
||||
"INSERT INTO adminx VALUES('新用户','手机号码(官服)/B站ID(B服)','Official',-1,'y','2000-01-01','1-7','-','-','n','n','n',?,'无',0,?,?)",
|
||||
(
|
||||
Crypto.encryptx("未设置"),
|
||||
Crypto.AUTO_encryptor("未设置"),
|
||||
set_book[0],
|
||||
set_book[1],
|
||||
),
|
||||
|
||||
@@ -53,7 +53,7 @@ import requests
|
||||
from app.core import Config, MainInfoBar
|
||||
from app.services import Crypto, System
|
||||
from app.utils import Updater
|
||||
from .Widget import InputMessageBox, LineEditSettingCard
|
||||
from .Widget import LineEditMessageBox, LineEditSettingCard, PasswordLineEditSettingCard
|
||||
|
||||
|
||||
class Setting(QWidget):
|
||||
@@ -136,7 +136,7 @@ class Setting(QWidget):
|
||||
|
||||
while True:
|
||||
|
||||
choice = InputMessageBox(
|
||||
choice = LineEditMessageBox(
|
||||
self.window(),
|
||||
"未检测到管理密钥,请设置您的管理密钥",
|
||||
"管理密钥",
|
||||
@@ -162,7 +162,7 @@ class Setting(QWidget):
|
||||
|
||||
while if_change:
|
||||
|
||||
choice = InputMessageBox(
|
||||
choice = LineEditMessageBox(
|
||||
self.window(),
|
||||
"请输入旧的管理密钥",
|
||||
"旧管理密钥",
|
||||
@@ -177,7 +177,7 @@ class Setting(QWidget):
|
||||
# 获取新的管理密钥
|
||||
while True:
|
||||
|
||||
choice = InputMessageBox(
|
||||
choice = LineEditMessageBox(
|
||||
self.window(),
|
||||
"请输入新的管理密钥",
|
||||
"新管理密钥",
|
||||
@@ -557,7 +557,7 @@ class NotifySettingCard(HeaderCardWidget):
|
||||
super().__init__(
|
||||
FluentIcon.SETTING,
|
||||
"推送邮件通知",
|
||||
"通过AUTO_MAA官方通知服务邮箱推送任务结果",
|
||||
"通过电子邮箱推送任务结果",
|
||||
parent,
|
||||
)
|
||||
|
||||
@@ -567,18 +567,42 @@ class NotifySettingCard(HeaderCardWidget):
|
||||
content="是否启用邮件通知功能",
|
||||
configItem=Config.global_config.notify_IfSendMail,
|
||||
)
|
||||
self.card_MailAddress = LineEditSettingCard(
|
||||
text="请输入邮箱地址",
|
||||
self.card_SMTPServerAddress = LineEditSettingCard(
|
||||
text="请输入SMTP服务器地址",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="邮箱地址",
|
||||
title="SMTP服务器地址",
|
||||
content="发信邮箱的SMTP服务器地址",
|
||||
configItem=Config.global_config.notify_SMTPServerAddress,
|
||||
)
|
||||
self.card_FromAddress = LineEditSettingCard(
|
||||
text="请输入发信邮箱地址",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="发信邮箱地址",
|
||||
content="发送通知的邮箱地址",
|
||||
configItem=Config.global_config.notify_FromAddress,
|
||||
)
|
||||
self.card_AuthorizationCode = PasswordLineEditSettingCard(
|
||||
text="请输入发信邮箱授权码",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="发信邮箱授权码",
|
||||
content="发送通知的邮箱授权码",
|
||||
configItem=Config.global_config.notify_AuthorizationCode,
|
||||
)
|
||||
self.card_ToAddress = LineEditSettingCard(
|
||||
text="请输入收信邮箱地址",
|
||||
icon=FluentIcon.PAGE_RIGHT,
|
||||
title="收信邮箱地址",
|
||||
content="接收通知的邮箱地址",
|
||||
configItem=Config.global_config.notify_MailAddress,
|
||||
configItem=Config.global_config.notify_ToAddress,
|
||||
)
|
||||
|
||||
widget = QWidget()
|
||||
Layout = QVBoxLayout(widget)
|
||||
Layout.addWidget(self.card_IfSendMail)
|
||||
Layout.addWidget(self.card_MailAddress)
|
||||
Layout.addWidget(self.card_SMTPServerAddress)
|
||||
Layout.addWidget(self.card_FromAddress)
|
||||
Layout.addWidget(self.card_AuthorizationCode)
|
||||
Layout.addWidget(self.card_ToAddress)
|
||||
self.viewLayout.setContentsMargins(0, 0, 0, 0)
|
||||
self.viewLayout.setSpacing(0)
|
||||
self.addGroupWidget(widget)
|
||||
|
||||
Reference in New Issue
Block a user