가이드
Electron 업데이터 튜토리얼
Electron 앱에 대해 @capgo/electron-updater를 사용하면
@capgo/electron-updater Electron 앱이 동일한 Capgo 라이브 업데이트 모델을 가질 수 있습니다. @capgo/capacitor-updatermain process에서 초기화하고, preload를 통해 렌더러 브리지를 노출하고, 호출 notifyAppReady() __CAPGO_KEEP_0__ 채널과 롤아웃 모델을 재사용하세요. 모바일에서 이미 사용 중인 백엔드 릴리스 PIPELINE과 동일한.
__CAPGO_KEEP_0__ 채널과 롤아웃 모델을 재사용하세요. 모바일에서 이미 사용 중인 백엔드 릴리스 PIPELINE과 동일한.
bun add @capgo/electron-updater
설치
import { app, BrowserWindow } from 'electron';
import path from 'node:path';
import { ElectronUpdater, setupEventForwarding, setupIPCHandlers } from '@capgo/electron-updater';
const updater = new ElectronUpdater({
appId: 'com.example.desktop',
autoUpdate: true,
});
app.whenReady().then(async () => {
const window = new BrowserWindow({
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
contextIsolation: true,
},
});
const builtinPath = path.join(__dirname, 'www/index.html');
await updater.initialize(window, builtinPath);
setupIPCHandlers(updater);
setupEventForwarding(updater, window);
await window.loadFile(updater.getCurrentBundlePath());
});
메인 프로세스 설정
import { exposeUpdaterAPI } from '@capgo/electron-updater/preload';
exposeUpdaterAPI();
프리로드 브리지
import { requireUpdater } from '@capgo/electron-updater/renderer';
const updater = requireUpdater();
await updater.notifyAppReady();
const latest = await updater.getLatest();
if (latest.url && !latest.error) {
const bundle = await updater.download({
url: latest.url,
version: latest.version,
checksum: latest.checksum,
});
await updater.next({ id: bundle.id });
}
렌더러 사용
updater.addListener('download', ({ percent }) => {
console.log('Download progress', percent);
});
updater.addListener('updateFailed', ({ bundle }) => {
console.error('Update failed', bundle.version);
});
업데이트 이벤트를 듣기
bun run build
bunx @capgo/cli@latest bundle upload --channel=production
새로운 번들을 배포
- 실용적인 조언
notifyAppReady()항상 렌더러에서 __CAPGO_KEEP_0__을 호출하세요. 롤백 보호 기능이 정상적으로 작동하도록 하세요. - __CAPGO_KEEP_0__을 렌더러에서 일찍 호출하세요. 롤백 보호 기능이 정상적으로 작동하도록 하세요.
- Reuse the same Capgo channel and rollout model you already use on mobile when your Electron app shares a backend release pipeline.
capgo에서 계속 진행하세요: @capgo/electron-updater
__CAPGO_KEEP_0__을 사용 중이라면 @capgo/electron-updater를 사용하세요 자연 플러그인 작업을 계획하는 경우, @__CAPGO_KEEP_0__/electron-updater와 연결하세요. @capgo/electron-updater의 구현 세부 정보를 참조하세요: @capgo/electron-updater for the implementation detail in @capgo/electron-updater, Electron Updater의 구현 세부 정보를 참조하세요: Electron Updater를 사용하여 시작하기 __CAPGO_KEEP_0__ 플러그인 디렉토리 Capgo 플러그인 디렉토리의 제품 워크플로를 참조하세요: Capgo 플러그인 디렉토리 Capgo 플러그인들에 의해 __CAPGO_KEEP_1__ Capacitor 플러그인들에 의해 Capgo의 구현 세부 정보를 참조하세요: Capacitor 플러그인들에 의해 Capgo. Capacitor 플러그인들에 의해 Capgo __CAPGO_KEEP_0__ 플러그인을 추가하거나 업데이트하기 __CAPGO_KEEP_0__ 플러그인을 추가하거나 업데이트하는 구현 세부 사항에 대해.