앱 버전표시

This commit is contained in:
Macbook
2026-06-14 18:38:42 +09:00
parent 0aeea1634c
commit b2c6650cd5
15 changed files with 142 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
import { useEffect, useState } from 'react';
import { isDesktop } from '../utils/platform';
import { getDesktopAppVersion, syncDesktopMainWindowTitle } from '../utils/desktopBridge';
declare const __DESKTOP_APP_VERSION__: string | undefined;
function readBakedDesktopVersion(): string | null {
if (typeof __DESKTOP_APP_VERSION__ === 'undefined') return null;
const v = __DESKTOP_APP_VERSION__.trim();
return v || null;
}
/** Desktop — 네이티브 창 타이틀·document.title을 GoldenChart (vX.Y.Z) 로 맞춤 */
export function useDesktopAppTitle(): string | null {
const [version, setVersion] = useState<string | null>(() =>
isDesktop() ? readBakedDesktopVersion() : null,
);
useEffect(() => {
if (!isDesktop()) return;
let cancelled = false;
void (async () => {
const v = (await getDesktopAppVersion()) ?? readBakedDesktopVersion();
if (cancelled || !v) return;
setVersion(v);
await syncDesktopMainWindowTitle();
})();
return () => { cancelled = true; };
}, []);
return version;
}
export function formatDesktopAppLabel(version: string | null | undefined): string {
if (!version?.trim()) return 'GoldenChart';
return `GoldenChart (v${version.trim()})`;
}