@@ -446,7 +446,9 @@ let mainWindow: BrowserWindow | null = null;
446446let lastPercent = 0 ; // Track last progress to prevent regression
447447// 跟踪上次进度,防止进度回退
448448
449- const isMac = process . platform === "darwin" ;
449+ function isMacPlatform ( ) : boolean {
450+ return process . platform === "darwin" ;
451+ }
450452
451453function normalizeRealPath ( inputPath : string ) : string {
452454 try {
@@ -457,7 +459,7 @@ function normalizeRealPath(inputPath: string): string {
457459}
458460
459461export function detectMacInstallSource ( executablePath : string = process . execPath ) : MacInstallSource {
460- if ( ! isMac ) {
462+ if ( ! isMacPlatform ( ) ) {
461463 return "unknown" ;
462464 }
463465
@@ -593,7 +595,7 @@ export function initUpdater(win: BrowserWindow) {
593595 console . info ( "Update available:" , info . version ) ;
594596 // macOS: store update info for later DMG download
595597 // macOS: 保存更新信息,供后续 DMG 下载使用
596- if ( isMac ) {
598+ if ( isMacPlatform ( ) ) {
597599 lastUpdateInfo = info ;
598600 console . log (
599601 `[Updater/macDMG] Stored update info: v${ info . version } , files:` ,
@@ -962,7 +964,7 @@ export function registerUpdaterIPC() {
962964 } ) ;
963965
964966 ipcMain . handle ( "updater:installSource" , ( ) => {
965- return isMac ? getMacInstallSource ( ) : "unknown" ;
967+ return isMacPlatform ( ) ? getMacInstallSource ( ) : "unknown" ;
966968 } ) ;
967969
968970 // 检查更新
@@ -1055,7 +1057,7 @@ export function registerUpdaterIPC() {
10551057
10561058 // macOS: bypass Squirrel, download DMG directly to ~/Downloads
10571059 // macOS: 绕过 Squirrel,直接下载 DMG 到 ~/Downloads
1058- if ( isMac ) {
1060+ if ( isMacPlatform ( ) ) {
10591061 if ( getMacInstallSource ( ) === "homebrew" ) {
10601062 return {
10611063 success : false ,
@@ -1122,7 +1124,7 @@ export function registerUpdaterIPC() {
11221124 fromVersion : app . getVersion ( ) ,
11231125 } ) ;
11241126
1125- if ( isMac ) {
1127+ if ( isMacPlatform ( ) ) {
11261128 if ( getMacInstallSource ( ) === "homebrew" ) {
11271129 return {
11281130 success : false ,
@@ -1187,7 +1189,7 @@ export function registerUpdaterIPC() {
11871189 ipcMain . handle ( "updater:openDownloadedUpdate" , async ( ) => {
11881190 // macOS: show the downloaded DMG in Finder
11891191 // macOS: 在 Finder 中显示已下载的 DMG
1190- if ( isMac && macDownloadedDmgPath && fs . existsSync ( macDownloadedDmgPath ) ) {
1192+ if ( isMacPlatform ( ) && macDownloadedDmgPath && fs . existsSync ( macDownloadedDmgPath ) ) {
11911193 shell . showItemInFolder ( macDownloadedDmgPath ) ;
11921194 return { success : true , path : macDownloadedDmgPath } ;
11931195 }
0 commit comments