위젯 추가 팝업 수정

This commit is contained in:
Macbook
2026-06-15 17:17:06 +09:00
parent 271392bc49
commit 51fdcf40e5
16 changed files with 435 additions and 238 deletions
+38 -3
View File
@@ -41,7 +41,7 @@ function writeUpdateLoopGuard(guard: UpdateLoopGuard) {
}
}
function clearUpdateLoopGuard() {
export function clearUpdateLoopGuard() {
try {
localStorage.removeItem(UPDATE_LOOP_GUARD_KEY);
} catch {
@@ -49,6 +49,27 @@ function clearUpdateLoopGuard() {
}
}
export interface DesktopUpdateOptions {
/** 수동 업데이트·재시도 시 반복 실패 가드 무시 */
bypassLoopGuard?: boolean;
}
const RELAUNCH_TIMEOUT_MS = 12_000;
async function relaunchWithTimeout(): Promise<boolean> {
try {
await Promise.race([
relaunch(),
new Promise<never>((_, reject) => {
window.setTimeout(() => reject(new Error('relaunch timeout')), RELAUNCH_TIMEOUT_MS);
}),
]);
return true;
} catch {
return false;
}
}
function shouldBlockUpdateLoop(currentVersion: string, targetVersion: string): boolean {
const guard = readUpdateLoopGuard();
if (!guard) return false;
@@ -231,6 +252,7 @@ export async function runStartupAutoUpdate(
export async function runDesktopUpdate(
onProgress?: (p: DesktopUpdateProgress) => void,
options?: DesktopUpdateOptions,
): Promise<DesktopUpdateResult> {
let currentVersion = '';
try {
@@ -261,7 +283,7 @@ export async function runDesktopUpdate(
return { ok: true, phase: 'uptodate', message, currentVersion };
}
if (shouldBlockUpdateLoop(currentVersion, update.version)) {
if (!options?.bypassLoopGuard && shouldBlockUpdateLoop(currentVersion, update.version)) {
const message =
`v${update.version} 업데이트가 반복 실패했습니다. 서버 패키지와 버전이 맞지 않을 수 있습니다. ` +
'PC 프로그램 탭에서 설치 파일을 받아 다시 설치해 주세요.';
@@ -269,6 +291,10 @@ export async function runDesktopUpdate(
return { ok: false, phase: 'error', message, currentVersion, newVersion: update.version };
}
if (options?.bypassLoopGuard) {
clearUpdateLoopGuard();
}
recordUpdateLoopAttempt(currentVersion, update.version);
emit(onProgress, {
@@ -323,7 +349,16 @@ export async function runDesktopUpdate(
currentVersion,
newVersion: update.version,
});
await relaunch();
const relaunched = await relaunchWithTimeout();
if (!relaunched) {
clearUpdateLoopGuard();
const message =
'업데이트는 설치됐지만 앱을 자동으로 다시 시작하지 못했습니다. GoldenChart를 직접 종료한 뒤 다시 실행해 주세요.';
emit(onProgress, { phase: 'error', message, currentVersion, newVersion: update.version });
return { ok: false, phase: 'error', message, currentVersion, newVersion: update.version };
}
return {
ok: true,
phase: 'relaunching',