앱 버전표시

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
+40
View File
@@ -0,0 +1,40 @@
import { getVersion } from '@tauri-apps/api/app';
import { getCurrentWindow } from '@tauri-apps/api/window';
const APP_NAME = 'GoldenChart';
export function formatDesktopWindowTitle(version: string): string {
const v = version.trim();
return v ? `${APP_NAME} (v${v})` : APP_NAME;
}
/** macOS/Windows 네이티브 창 타이틀 — GoldenChart (vX.Y.Z) */
export async function syncMainWindowTitle(): Promise<string> {
try {
const version = await getVersion();
const title = formatDesktopWindowTitle(version);
await getCurrentWindow().setTitle(title);
if (typeof document !== 'undefined') {
document.title = title;
}
return title;
} catch (e) {
console.warn('[desktop] syncMainWindowTitle failed:', e);
throw e;
}
}
/** WebView 로드 후 macOS가 document.title로 타이틀을 덮어쓸 수 있어 재시도 */
export function scheduleMainWindowTitleSync(): void {
const delays = [0, 150, 600, 2000];
for (const ms of delays) {
window.setTimeout(() => {
void syncMainWindowTitle().catch(() => {});
}, ms);
}
void getCurrentWindow()
.listen('tauri://focus', () => {
void syncMainWindowTitle().catch(() => {});
})
.catch(() => {});
}