desktop 앱 적용
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
/** 런타임 플랫폼 — web · desktop(Tauri) · mobile */
|
||||
export type RuntimePlatform = 'web' | 'desktop' | 'mobile';
|
||||
|
||||
export function isDesktop(): boolean {
|
||||
return typeof window !== 'undefined' && '__TAURI__' in window;
|
||||
}
|
||||
|
||||
export function isMobileCapacitor(): boolean {
|
||||
if (typeof window === 'undefined') return false;
|
||||
try {
|
||||
const cap = (window as Window & { Capacitor?: { isNativePlatform?: () => boolean } }).Capacitor;
|
||||
return cap?.isNativePlatform?.() === true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function getRuntimePlatform(): RuntimePlatform {
|
||||
if (isDesktop()) return 'desktop';
|
||||
if (isMobileCapacitor()) return 'mobile';
|
||||
return 'web';
|
||||
}
|
||||
|
||||
export function isWeb(): boolean {
|
||||
return getRuntimePlatform() === 'web';
|
||||
}
|
||||
Reference in New Issue
Block a user