2021-10-05 18:16:50 +08:00
#!/usr/bin/env python3
import os
2022-07-23 12:44:33 +08:00
import sys
2021-10-05 18:16:50 +08:00
import json
import base64
import requests
import traceback
import webbrowser
2023-01-01 12:16:31 +08:00
import updatekiller
2021-10-05 18:16:50 +08:00
import urllib.parse as parse
2022-07-23 12:44:33 +08:00
import PyQt5.QtGui as QtGui
import PyQt5.QtWidgets as QtWidgets
2023-01-18 15:42:49 +08:00
print("""过零丁洋
辛苦遭逢起一经,干戈寥落四周星。山河破碎风飘絮,身世浮沉雨打萍。
惶恐滩头说惶恐,零丁洋里叹零丁。人生自古谁无死?留取丹心照汗青。""")
print("")
print("译文:回想我早年由科举入仕历尽辛苦,如今战火消歇已熬过了四个年头。国家危在旦夕恰如狂风中的柳絮,个人又哪堪言说似骤雨里的浮萍。惶恐滩的惨败让我至今依然惶恐,零丁洋身陷元虏可叹我孤苦零丁。人生自古以来有谁能够长生不死?我要留一片爱国的丹心映照史册。")
print("================================")
2021-10-05 18:16:50 +08:00
# 读取文本文档
def readtxt(path: "路径")->"读取文本文档":
f = open(path, "r") # 设置文件对象
str = f.read() # 获取内容
f.close() # 关闭文本对象
return str # 返回结果
def Update(name, stars, contact, things, version):
# post 内容
data = {
"Name": name,
"Starts": stars,
"Contact": contact,
"Things": things,
"Version": version
}
try:
2023-07-09 06:41:43 +08:00
QtWidgets.QMessageBox.information(widget, "提示", requests.post(parse.unquote(base64.b64decode("aHR0cDovLzEyMC4yNS4xNTMuMTQ0L3VlbmdpbmUtcnVubmVyL2J1Zy91cGxvYWQucGhw").decode("utf-8")), data=data).text)
2022-07-23 12:44:33 +08:00
print(data)
2021-10-05 18:16:50 +08:00
except:
traceback.print_exc()
2022-07-23 12:44:33 +08:00
QtWidgets.QMessageBox.critical(widget, "错误", f"服务器疑似出现错误,可以进行以下尝试:①多尝试几次;②使用其他反馈途径\n错误信息: {traceback.format_exc()}")
2021-10-05 18:16:50 +08:00
def UpdateButtonClick():
#判断是否为空
2022-07-23 12:44:33 +08:00
if nameThings.text() == "" or starMenu.currentText() == "" or contactThings.text() == "" or updateThings.toPlainText().replace(" ", "").replace("\n", "") == "":
QtWidgets.QMessageBox.critical(widget, "错误", "反馈信息未填写完整!")
2021-10-05 18:16:50 +08:00
return
2022-07-23 12:44:33 +08:00
Update(name=nameThings.text(), stars=starMenu.currentText(), contact=contactThings.text(), things=updateThings.toPlainText(), version=version)
2021-10-05 18:16:50 +08:00
def OpenGiteeIssues():
webbrowser.open_new_tab("https://gitee.com/gfdgd-xi/uengine-runner/issues")
def OpenGithubIssues():
webbrowser.open_new_tab("https://github.com/gfdgd-xi/uengine-runner/issues")
2022-07-07 14:35:44 +08:00
# 获取用户主目录
def get_home()->"获取用户主目录":
return os.path.expanduser('~')
2021-10-05 18:16:50 +08:00
###########################
# 程序信息
###########################
2022-07-23 12:44:33 +08:00
iconPath = "{}/runner.svg".format(os.path.split(os.path.realpath(__file__))[0])
2021-10-05 18:16:50 +08:00
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(programPath + "/information.json"))
version = information["Version"]
###########################
# 窗口创建
###########################
2022-07-23 12:44:33 +08:00
app = QtWidgets.QApplication(sys.argv)
window = QtWidgets.QMainWindow()
widget = QtWidgets.QWidget()
widgetLayout = QtWidgets.QGridLayout()
nameThings = QtWidgets.QLineEdit()
contactThings = QtWidgets.QLineEdit()
starMenu = QtWidgets.QComboBox()
updateThings = QtWidgets.QTextEdit()
updateButton = QtWidgets.QPushButton("提交")
otherUpload = QtWidgets.QHBoxLayout()
giteeButton = QtWidgets.QPushButton("Gitee Issues")
githubButton = QtWidgets.QPushButton("Github Issues")
otherUpload.addWidget(QtWidgets.QLabel("如果无法正常反馈,可以用其他方式反馈:"))
otherUpload.addWidget(giteeButton)
otherUpload.addWidget(githubButton)
2023-05-13 13:14:30 +08:00
#otherUpload.addWidget(gitlinkButton)
#otherUpload.addWidget(forumButton)
2022-07-23 12:44:33 +08:00
otherUpload.addSpacerItem(QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum))
starMenu.addItems(["5分", "4分", "3分", "2分", "1分"])
widgetLayout.addWidget(QtWidgets.QLabel("你的昵称:"), 0, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("联系方式(电子邮箱):"), 0, 2, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("评分:"), 0, 4, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("反馈内容(支持 Markdown 格式):"), 1, 0, 1, 2)
widgetLayout.addWidget(nameThings, 0, 1, 1, 1)
widgetLayout.addWidget(contactThings, 0, 3, 1, 1)
widgetLayout.addWidget(starMenu, 0, 5, 1, 1)
widgetLayout.addWidget(updateThings, 2, 0, 1, 6)
widgetLayout.addLayout(otherUpload, 3, 0, 1, 5)
widgetLayout.addWidget(updateButton, 3, 5, 1, 1)
giteeButton.clicked.connect(OpenGiteeIssues)
githubButton.clicked.connect(OpenGithubIssues)
updateButton.clicked.connect(UpdateButtonClick)
widget.setLayout(widgetLayout)
window.setCentralWidget(widget)
window.setWindowTitle(f"UEngine 运行器 {version} 问题/建议反馈")
window.setWindowIcon(QtGui.QIcon(iconPath))
window.show()
2023-08-14 16:55:12 +08:00
starMenu.setDisabled(True)
contactThings.setDisabled(True)
#otherUpload.setDisabled(True)
nameThings.setDisabled(True)
updateButton.setDisabled(True)
updateThings.setDisabled(True)
updateThings.setText("请移步到 Gitee 或 Github 提交 Bug( 推荐使用 Gitee) ")
2023-01-01 12:16:31 +08:00
sys.exit(app.exec_())