Skip to content

Commit 0712824

Browse files
authored
Merge pull request #52 from ljzloser/master
增加打包安装包脚本文件,需要需要打包的文件夹和脚本同一目录,需要安装Inno Setup,打包时请详细阅读脚本前几行注释
2 parents a594a99 + 903a75b commit 0712824

4 files changed

Lines changed: 251 additions & 51 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ wheels/
2626
OCRModel/
2727
pip-wheel-metadata/
2828
share/python-wheels/
29+
Metaminesweeper-v3.1.11/
30+
Output/
2931
*.egg-info/
3032
.installed.cfg
3133
*.egg

Metaminesweeper.iss

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
;由 Inno Setup Script Wizard 生成的脚本。
2+
;有关创建 INNO SETUP 脚本文件的详细信息,请参阅文档
3+
; 将Inno Setup 的安装目录添加到环境变量中 在命令行使用 ISCC "{xxx.iss}" 全路径 进行编译
4+
; 或者 cd 到Inno Setup 的安装目录,然后在命令行中使用 iscc "{xxx.iss}" 进行编译
5+
; 安装程序生成在该脚本的根目录下的Output目录下
6+
; 程序名称
7+
#define MyAppName "Metaminesweeper"
8+
; 程序版本
9+
#define MyAppVersion "3.1.11"
10+
; 发行商
11+
#define MyAppPublisher "eee555"
12+
; 官网
13+
#define MyAppURL "https://github.com/eee555/Solvable-Minesweeper"
14+
; 运行主程序名称
15+
#define MyAppExeName "metaminesweeper.exe"
16+
; 程序目录
17+
#define AppPath "metaminesweeper"
18+
; 根目录
19+
#define RootPath "Metaminesweeper-v3.1.11"
20+
; 图标
21+
#define IconPath "Metaminesweeper-v3.1.11\media\cat.ico"
22+
[Setup]
23+
;注意:AppId 的值唯一标识此应用程序。不要在其他应用程序的安装程序中使用相同的 AppId 值。
24+
;(要生成新的 GUID,请单击 Tools |在 IDE 中生成 GUID
25+
AppId={{A5BFCE55-30E5-4A1D-8849-E6372D2CF9D4}
26+
AppName={#MyAppName}
27+
AppVersion={#MyAppVersion}
28+
;AppVerName={#MyAppName} {#MyAppVersion}
29+
AppPublisher={#MyAppPublisher}
30+
AppPublisherURL={#MyAppURL}
31+
AppSupportURL={#MyAppURL}
32+
AppUpdatesURL={#MyAppURL}
33+
;默认按照路径
34+
DefaultDirName={autopf}\{#MyAppName}
35+
;“ArchitecturesAllowed=x64compatible” 指定安装程序无法运行
36+
;在 Arm 上的 x64 和 Windows 11 以外的任何设备上。
37+
ArchitecturesAllowed=x64compatible
38+
;“ArchitecturesInstallIn64BitMode=x64compatible” 请求
39+
;在 x64 或 Arm 上的 Windows 11 上以“64 位模式”完成安装,
40+
;这意味着它应该使用本机 64 位 Program Files 目录和
41+
;注册表的 64 位视图。
42+
ArchitecturesInstallIn64BitMode=x64compatible
43+
DisableProgramGroupPage=yes
44+
;取消注释以下行以在非管理安装模式下运行(仅为当前用户安装)。
45+
PrivilegesRequired=admin
46+
OutputBaseFilename=Metaminesweeper-{#MyAppVersion}
47+
Compression=lzma
48+
SolidCompression=yes
49+
WizardStyle=modern
50+
SetupIconFile={#IconPath}
51+
UninstallDisplayIcon={#IconPath}
52+
53+
[Languages]
54+
Name: "english"; MessagesFile: "compiler:Default.isl"
55+
; 中文语言包,需要下载对应的中文.isl文件放到InnoSetup目录下的languages目录下
56+
Name: "chinese"; MessagesFile: "compiler:Languages\Chinese.isl"
57+
58+
[Tasks]
59+
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
60+
61+
[Files]
62+
Source: {#RootPath}\{#AppPath}\{#MyAppExeName}; DestDir: "{app}\{#AppPath}"; Flags: ignoreversion
63+
Source: {#RootPath}\*; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
64+
;注意:不要在任何共享系统文件上使用 “Flags: ignoreversion”
65+
66+
[Icons]
67+
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#AppPath}\{#MyAppExeName}"
68+
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#AppPath}\{#MyAppExeName}"; Tasks: desktopicon;
69+
70+
[Run]
71+
Filename: "{app}\{#AppPath}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent runascurrentuser
72+

src/CheckUpdateGui.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
QSizePolicy, QPushButton, QFrame, QMessageBox, QFormLayout, QProgressDialog, QTextEdit, QComboBox
33
from githubApi import GitHub, Release, SourceManager, PingThread
44
from PyQt5.QtCore import QObject, pyqtSlot, Qt, pyqtSignal, QUrl, QPropertyAnimation, \
5-
QRect, QSize, pyqtProperty, QVariantAnimation
5+
QRect, QSize, pyqtProperty, QVariantAnimation,QDateTime
66
from PyQt5.QtGui import QDesktopServices, QFont, QIcon, QPainter, QPixmap, QPaintEvent
77

88

@@ -53,6 +53,7 @@ def __init__(self, release: Release, mode=">", parent=None):
5353
self.showButton = AnimationButton()
5454
self.showButton.setCheckable(True)
5555
self.showButton.pixmap = QPixmap("media/unfold.png")
56+
self.dateTimeLabel = QLabel()
5657
self.titleWidget = QWidget()
5758
self.formWidget = QWidget()
5859
self.downloadButton = QPushButton(QObject.tr(self, "Download"))
@@ -70,6 +71,10 @@ def initUi(self):
7071
row1 = QHBoxLayout()
7172
row1.addWidget(self.showButton)
7273
row1.addWidget(QLabel(self.release.tag_name))
74+
row1.addItem(QSpacerItem(
75+
20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
76+
self.dateTimeLabel.setText(QDateTime.fromString(self.release.assets_created_at, "yyyy-MM-ddThh:mm:ssZ").toString("yyyy-MM-dd hh:mm:ss"))
77+
row1.addWidget(self.dateTimeLabel)
7378
row1.addItem(QSpacerItem(
7479
20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
7580
self.downloadButton.setEnabled(self.mode == ">")
@@ -93,7 +98,7 @@ def initUi(self):
9398
formLayout.addRow(QObject.tr(self, "download_count"),
9499
QLabel(str(self.release.assets_download_count)))
95100
formLayout.addRow(QObject.tr(self, "created_at"),
96-
QLabel(self.release.assets_created_at))
101+
QLabel(QDateTime.fromString(self.release.assets_created_at, "yyyy-MM-ddThh:mm:ssZ").toString("yyyy-MM-dd hh:mm:ss")))
97102
downloadUrlLabel = QLabel()
98103
downloadUrlLabel.setText("<a href='" + self.release.assets_browser_download_url +
99104
"'>" + QObject.tr(self, "open download links") + "</a>")
@@ -236,6 +241,8 @@ def changeSource(self, source: str):
236241
self.sourceSpeedLabel.setText("---ms")
237242
self.pingThread.pingSignal.connect(lambda x,y: self.sourceSpeedLabel.setText(f"{int(y)}ms"))
238243
self.pingThread.start()
244+
self.github.sourceManager.currentSource = source
245+
self.checkUpdateButton.click()
239246
@pyqtSlot(list)
240247
def checkUpdate(self, releases: list):
241248
widget = self.releaseArea.widget()
@@ -266,6 +273,10 @@ def showDownloadDialog(self, release: Release):
266273
if self.processDialog is not None:
267274
self.processDialog.close()
268275
self.processDialog = QProgressDialog(self)
276+
# 取消信号
277+
self.processDialog.canceled.connect(
278+
self.downloadCancel
279+
)
269280
self.processDialog.setWindowTitle(QObject.tr(
270281
self, f"{release.tag_name} Downloading..."))
271282

@@ -283,6 +294,11 @@ def hideDownloadDialog(self, path: str):
283294
# 使用系统默认方式打开文件
284295
QDesktopServices.openUrl(QUrl.fromLocalFile(path))
285296

297+
def downloadCancel(self):
298+
self.github.closeAllRequest()
299+
if self.processDialog is not None:
300+
self.processDialog.close()
301+
self.processDialog = None
286302

287303
if __name__ == '__main__':
288304
import sys

0 commit comments

Comments
 (0)