From e9a42a5aaf9c69adbbd8eafa9de405fc6720f8ff Mon Sep 17 00:00:00 2001 From: beyondkmp Date: Fri, 13 Jun 2025 10:52:25 +0800 Subject: [PATCH] feat: Enhance AppUpdater for Windows installation directory support (#7135) - Added support for setting the installation directory for the autoUpdater on Windows using NsisUpdater. - Imported the 'path' module to dynamically determine the installation path based on the executable location. - This change improves the updater's functionality and ensures a smoother installation experience for Windows users. Co-authored-by: beyondkmp --- src/main/services/AppUpdater.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/services/AppUpdater.ts b/src/main/services/AppUpdater.ts index 772c885a01..bb87480a64 100644 --- a/src/main/services/AppUpdater.ts +++ b/src/main/services/AppUpdater.ts @@ -5,7 +5,8 @@ import { FeedUrl } from '@shared/config/constant' import { UpdateInfo } from 'builder-util-runtime' import { app, BrowserWindow, dialog } from 'electron' import logger from 'electron-log' -import { AppUpdater as _AppUpdater, autoUpdater } from 'electron-updater' +import { AppUpdater as _AppUpdater, autoUpdater, NsisUpdater } from 'electron-updater' +import path from 'path' import icon from '../../../build/icon.png?asset' import { configManager } from './ConfigManager' @@ -56,6 +57,10 @@ export default class AppUpdater { logger.info('下载完成', releaseInfo) }) + if (isWin) { + ;(autoUpdater as NsisUpdater).installDirectory = path.dirname(app.getPath('exe')) + } + this.autoUpdater = autoUpdater }