From 0c23b591c43aa15c0a91f4982c252134c84805c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ACT=E4=B8=B6=E6=B5=81=E6=98=9F=E9=9B=A8?= <1340145680@qq.com> Date: Fri, 3 Apr 2026 22:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=8E=AF=E5=A2=83vc++?= =?UTF-8?q?=E4=BF=AE=E8=A1=A5=E7=A8=8B=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron-builder.yml | 1 + scripts/installer.nsh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 scripts/installer.nsh diff --git a/electron-builder.yml b/electron-builder.yml index c13ea1a..66d87d0 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -47,6 +47,7 @@ nsis: artifactName: ${productName}-${version}-win-${arch}-setup.${ext} installerIcon: './scripts/logo.ico' uninstallerIcon: './scripts/logo.ico' + include: ./scripts/installer.nsh mac: target: diff --git a/scripts/installer.nsh b/scripts/installer.nsh new file mode 100644 index 0000000..c1e6e59 --- /dev/null +++ b/scripts/installer.nsh @@ -0,0 +1,25 @@ +!macro customInstall + ; Check if VC++ Redistributable is already installed + ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\X64" "Installed" + ${If} $0 != 1 + DetailPrint "Downloading Visual C++ Redistributable..." + ${If} ${RunningX64} + inetc::get "https://aka.ms/vs/17/release/vc_redist.x64.exe" "$TEMP\vc_redist.exe" /END + ${Else} + inetc::get "https://aka.ms/vs/17/release/vc_redist.arm64.exe" "$TEMP\vc_redist.exe" /END + ${EndIf} + Pop $0 + ${If} $0 == "OK" + DetailPrint "Installing Visual C++ Redistributable..." + nsExec::ExecToLog '"$TEMP\vc_redist.exe" /install /quiet /norestart' + Pop $0 + DetailPrint "VC++ Redistributable install returned: $0" + ${Else} + DetailPrint "VC++ Redistributable download failed: $0" + MessageBox MB_OK|MB_ICONEXCLAMATION "Visual C++ Redistributable download failed. Please install it manually from https://aka.ms/vs/17/release/vc_redist.x64.exe" + ${EndIf} + Delete "$TEMP\vc_redist.exe" + ${Else} + DetailPrint "Visual C++ Redistributable is already installed." + ${EndIf} +!macroend