2016-06-23 4 views
3

전자를 사용하여 앱을 만들고 파일에 electron-builder으로 묶었습니다.전자 앱이 설치되었지만 시작 메뉴에 표시되지 않음

생성 된 실행 파일을 실행하면 응용 프로그램은 electron-builder에 의해 사용되는 기본 설치 GIF에서 예상대로 시작됩니다.

Default installation GIF

있는 GIF 완료 후

, 응용 프로그램이 다시 시작되고 제대로 작동합니다. 심지어 은 제어판의 프로그램 목록에 나타납니다.

그러나 시작 메뉴 응용 프로그램에서 찾으면 해당 파일이 없습니다 (이름으로 검색하면 앞에서 설명한 .exe 설치 프로그램 만 반환됩니다).
이 때문에 앱을 닫으면 다시 열 수있는 유일한 방법은 설치 프로그램을 다시 실행하는 것입니다.

왜 이런 일이 발생합니까? 다른 프로그램과 함께 표시 할 수있는 방법이 있습니까?

답변

1

전자 빌더 설치 프로그램 (및 electron-windows-installer)은 설치를 처리하기 위해 Squirrel을 사용합니다. 다람쥐는 당신이 처리해야하는 인수를 가지고 설치시 응용 프로그램을 시작합니다. 예는 windows installer github docs

처리 다람쥐 이벤트

에서 찾을 수 있습니다

다람쥐를 처음 실행, 업데이트에 명령 줄 플래그를 사용하여 응용 프로그램을 산란하고 제거합니다. 앱에서 이러한 이벤트를 가능한 한 빨리 처리하고 처리 한 후 즉시 종료하는 것이 매우 중요합니다. 다람쥐는 앱에 이러한 작업을 적용하고 종료 할 수있는 짧은 시간 (~ 15 초)을줍니다.

전자 다람쥐 시작 모듈은 바탕 화면 바로 가기 관리와 같이 가장 일반적인 이벤트를 처리합니다. 그냥 당신의 main.js의 상단에 다음을 추가하고 갈 수 있어요 :

if (require('electron-squirrel-startup')) return; 

당신은 당신의 응용 프로그램의 주 진입 점에서 이러한 이벤트를 처리해야 뭔가 같은 :

const app = require('app'); 

// this should be placed at top of main.js to handle setup events quickly 
if (handleSquirrelEvent()) { 
    // squirrel event handled and app will exit in 1000ms, so don't do anything else 
    return; 
} 

function handleSquirrelEvent() { 
    if (process.argv.length === 1) { 
    return false; 
    } 

    const ChildProcess = require('child_process'); 
    const path = require('path'); 

    const appFolder = path.resolve(process.execPath, '..'); 
    const rootAtomFolder = path.resolve(appFolder, '..'); 
    const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe')); 
    const exeName = path.basename(process.execPath); 

    const spawn = function(command, args) { 
    let spawnedProcess, error; 

    try { 
     spawnedProcess = ChildProcess.spawn(command, args, {detached: true}); 
    } catch (error) {} 

    return spawnedProcess; 
    }; 

    const spawnUpdate = function(args) { 
    return spawn(updateDotExe, args); 
    }; 

    const squirrelEvent = process.argv[1]; 
    switch (squirrelEvent) { 
    case '--squirrel-install': 
    case '--squirrel-updated': 
     // Optionally do things such as: 
     // - Add your .exe to the PATH 
     // - Write to the registry for things like file associations and 
     // explorer context menus 

     // Install desktop and start menu shortcuts 
     spawnUpdate(['--createShortcut', exeName]); 

     setTimeout(app.quit, 1000); 
     return true; 

    case '--squirrel-uninstall': 
     // Undo anything you did in the --squirrel-install and 
     // --squirrel-updated handlers 

     // Remove desktop and start menu shortcuts 
     spawnUpdate(['--removeShortcut', exeName]); 

     setTimeout(app.quit, 1000); 
     return true; 

    case '--squirrel-obsolete': 
     // This is called on the outgoing version of your app before 
     // we update to the new version - it's the opposite of 
     // --squirrel-updated 

     app.quit(); 
     return true; 
    } 
}; 

설치 프로그램이 처음으로 앱을 실행하면 앱에 --squirrel-firstrun 플래그가 표시됩니다. 스플래시 화면을 표시하거나 설정 UI를 표시하는 등의 작업을 수행 할 수 있습니다. 또 하나주의해야 할 점은, 앱이 다람쥐에 의해 스폰되고 다람쥐가 설치 중에 파일 잠금을 획득하기 때문에 다람쥐가 잠금을 해제 할 때까지 앱 업데이트를 성공적으로 확인할 수 없다는 것입니다. 당신이 메뉴와 바탕 화면 바로 가기를 시작 추가 인수 --create-바로 가기와 함께 Update.exe를 (다람쥐 실행 파일)를 실행 볼 수 있습니다이 예에서

.

관련 문제