desktop 앱 적용
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { isDesktop } from './platform';
|
||||
|
||||
export interface DesktopBridge {
|
||||
openWidgetWindow: (instance: import('../types/floatingWidget').FloatingWidgetInstance) => Promise<void>;
|
||||
closeWidgetWindow: (id: string) => Promise<void>;
|
||||
focusWidgetWindow: (id: string) => Promise<void>;
|
||||
showNativeNotification: (title: string, body: string) => Promise<void>;
|
||||
checkForUpdates: () => Promise<{ available: boolean; version?: string; message?: string }>;
|
||||
getAppVersion: () => Promise<string>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__goldenDesktopBridge?: DesktopBridge;
|
||||
}
|
||||
}
|
||||
|
||||
export function getDesktopBridge(): DesktopBridge | null {
|
||||
if (!isDesktop()) return null;
|
||||
return window.__goldenDesktopBridge ?? null;
|
||||
}
|
||||
|
||||
export async function showDesktopNativeNotification(title: string, body: string): Promise<void> {
|
||||
const bridge = getDesktopBridge();
|
||||
if (!bridge) return;
|
||||
try {
|
||||
await bridge.showNativeNotification(title, body);
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
export async function checkDesktopUpdates(): Promise<{ available: boolean; version?: string; message?: string }> {
|
||||
const bridge = getDesktopBridge();
|
||||
if (!bridge) return { available: false, message: '데스크톱 앱에서만 사용 가능합니다.' };
|
||||
return bridge.checkForUpdates();
|
||||
}
|
||||
|
||||
export async function getDesktopAppVersion(): Promise<string | null> {
|
||||
const bridge = getDesktopBridge();
|
||||
if (!bridge) return null;
|
||||
try {
|
||||
return await bridge.getAppVersion();
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user