; ============================================================
; ServerManager - Inno Setup 安装包脚本
; 用于生成外层安装包、卸载程序，支持静默更新
; ============================================================

; 本地测试包：使用 scripts\package\pack_local_test.bat 或 ISCC /DLOCAL_TEST=1
; 输出到 build\output_local\ServerManager_Setup_LOCAL.exe，独立 AppId，与正式安装并存、不覆盖 build\output\
#ifdef LOCAL_TEST
#define MyAppName "ServerManager (本地测试)"
#define MyAppId "{{B2C3D4E5-F6A7-8901-BCDE-F123456789ABC}"
#define MyOutputDir "..\..\build\output_local"
#define MyOutputBase "ServerManager_Setup_LOCAL"
#else
#define MyAppName "ServerManager"
#define MyAppId "{{A1B2C3D4-E5F6-7890-ABCD-EF1234567890}"
#define MyOutputDir "..\..\build\output"
#define MyOutputBase "ServerManager_Setup"
#endif

#define MyAppVersion "1.1.3"
#define MyAppExeName "main.exe"
#define MyAppPublisher "ServerManager"
#define MyAppURL "http://your-server.com/"

[Setup]
; 基础信息
AppId={#MyAppId}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DefaultGroupName={#MyAppName}
DisableProgramGroupPage=yes
; 输出（正式：build\output\；本地测试：build\output_local\）
OutputDir={#MyOutputDir}
OutputBaseFilename={#MyOutputBase}
SetupIconFile=
Compression=lzma2/ultra64
SolidCompression=yes
; 静默安装由命令行参数控制：/VERYSILENT /SUPPRESSMSGBOXES /FORCECLOSEAPPLICATIONS
UninstallDisplayIcon={app}\{#MyAppExeName}
; 控制面板中显示
UninstallDisplayName={#MyAppName} {#MyAppVersion}
; 安装完成后运行主程序
CloseApplications=force
RestartApplications=no

; 静默参数说明：
; /VERYSILENT    - 完全静默，不显示安装向导
; /SUPPRESSMSGBOXES - 抑制消息框
; /FORCECLOSEAPPLICATIONS - 强制关闭正在运行的程序

[Languages]
Name: "default"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "创建桌面快捷方式"; GroupDescription: "附加图标:"; Flags: unchecked
Name: "quicklaunchicon"; Description: "创建快速启动栏快捷方式"; GroupDescription: "附加图标:"; Flags: unchecked

[Files]
; 主程序目录模式（src\dist\main\ 含 main.exe 与 _internal 等依赖，无 _MEI 解压，避免 DLL 加载失败）
Source: "..\..\src\dist\main\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; 独立进程外更新器：与 main.exe 同目录
Source: "..\..\src\dist\mini_updater.exe"; DestDir: "{app}"; Flags: ignoreversion
; 版本与更新配置
Source: "..\..\resources\version.json"; DestDir: "{app}"; Flags: ignoreversion
; 默认配置模板（default.kv、sys_*.config.example 等，与 resources\config 同源；build.bat 会同步拷入 dist\main\config）
Source: "..\..\resources\config\*"; DestDir: "{app}\config"; Flags: ignoreversion recursesubdirs createallsubdirs

[Dirs]
; 安装后展开软件所需目录：配置与日志
Name: "{app}\config"; Flags: uninsneveruninstall
Name: "{app}\logs"; Flags: uninsneveruninstall

[Icons]
; 开始菜单
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\卸载 {#MyAppName}"; Filename: "{uninstallexe}"
; 桌面（根据用户选择）
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
; 快速启动栏
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon

[Run]
; 安装完成后自动运行主程序（含静默更新后也启动，实现“退出并重启”）
Filename: "{app}\{#MyAppExeName}"; Description: "运行 {#MyAppName}"; Flags: nowait postinstall

[UninstallDelete]
; 删除安装目录下的所有内容（Inno 默认会删除 {app}，此处列出以防需要额外清理）
Type: filesandordirs; Name: "{app}"
; 彻底清理应用产生的缓存目录
Type: filesandordirs; Name: "{localappdata}\{#MyAppName}"
