Skip to content

Commit

Permalink
实现打开时公告弹窗功能
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzaphkiel committed Jan 18, 2024
1 parent 39ca097 commit 5966e7e
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 59 deletions.
2 changes: 1 addition & 1 deletion Seraphine.pro
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SOURCES += app/view/main_window.py \
app/components/loose_switch_setting_card.py \
app/components/summoner_name_button.py \
app/components/mode_filter_widget.py \
app/components/update_message_box.py \
app/components/message_box.py \
app/lol/tools.py \

TRANSLATIONS += app/resource/i18n/Seraphine.zh_CN.ts
2 changes: 2 additions & 0 deletions app/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ class Config(QConfig):

autoSelectChampion = ConfigItem("Functions",
"AutoSelectChampion", "")

lastNoticeSha = ConfigItem("Other", "LastNoticeSha", "")

lockConfig = ConfigItem("Functions", "LockConfig", False, BoolValidator())

Expand Down
21 changes: 19 additions & 2 deletions app/common/util.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
import requests
import base64

from app.common.config import cfg, VERSION


class Github:
def __init__(self, user="Zzaphkiel", repositories="Seraphine"):
self.API = "http://api.github.com"
self.githubApi = "http://api.github.com"
self.giteeApi = "http://gitee.com/api"

self.user = user
self.repositories = repositories
self.sess = requests.session()

def getReleasesInfo(self):
url = f"{self.API}/repos/{self.user}/{self.repositories}/releases/latest"
url = f"{self.githubApi}/repos/{self.user}/{self.repositories}/releases/latest"
return self.sess.get(url, verify=False).json()

def checkUpdate(self):
Expand All @@ -25,6 +27,21 @@ def checkUpdate(self):
if info.get("tag_name")[1:] != VERSION:
return info
return None

def getNotice(self):
url = f'{self.githubApi}/repos/{self.user}/{self.repositories}/contents/document/notice.md'
res = self.sess.get(url, verify=False).json()

print(res)

content = str(base64.b64decode(res['content']), encoding='utf-8')

return {
'sha': res['sha'],
'content': content,
}




github = Github()
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from PyQt5.QtWidgets import QLabel
from qfluentwidgets import (MessageBox, MessageBoxBase, SmoothScrollArea, SubtitleLabel, BodyLabel, TextEdit, TitleLabel,
from PyQt5.QtWidgets import QLabel, QTextBrowser
from qfluentwidgets import (MessageBox, MessageBoxBase, SmoothScrollArea,
SubtitleLabel, BodyLabel, TextEdit, TitleLabel,
CheckBox)

from app.common.config import VERSION, cfg
Expand Down Expand Up @@ -33,3 +34,28 @@ def __init__(self, info, parent=None):

self.yesButton.setText(self.tr("Download"))
self.cancelButton.setText(self.tr("Ok"))


class NoticeMessageBox(MessageBoxBase):
def __init__(self, msg, parent=None):
super().__init__(parent=parent)
self.titleLabel = TitleLabel(self.tr('Notice'), self)
self.titleLabel.setContentsMargins(5, 0, 5, 0)

textEdit = TextEdit(self)
textEdit.setFixedWidth(int(self.width() * .6))
textEdit.setMarkdown(msg)
textEdit.setReadOnly(True)

# checkBox = CheckBox()
# checkBox.setText(self.tr("Don't remind me again"))
# checkBox.clicked.connect(lambda: cfg.set(
# cfg.enableCheckUpdate, not checkBox.isChecked(), True))

self.viewLayout.addWidget(self.titleLabel)
self.viewLayout.addWidget(textEdit)
# self.viewLayout.addWidget(checkBox)

self.hideCancelButton()

self.yesButton.setText(self.tr("Ok"))
Binary file modified app/resource/i18n/Seraphine.zh_CN.qm
Binary file not shown.
Loading

0 comments on commit 5966e7e

Please sign in to comment.