mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
19 lines
595 B
TypeScript
19 lines
595 B
TypeScript
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import {getMainWindow} from '@electron/main/Window';
|
|
|
|
export type TaskbarProgressMode = 'normal' | 'indeterminate' | 'error' | 'paused' | 'none';
|
|
|
|
export function setTaskbarProgress(fraction: number, mode: TaskbarProgressMode = 'normal'): void {
|
|
const mainWindow = getMainWindow();
|
|
if (!mainWindow || mainWindow.isDestroyed()) return;
|
|
try {
|
|
if (mode === 'none' || fraction < 0) {
|
|
mainWindow.setProgressBar(-1);
|
|
return;
|
|
}
|
|
const clamped = Math.max(0, Math.min(1, fraction));
|
|
mainWindow.setProgressBar(clamped, {mode});
|
|
} catch {}
|
|
}
|