앱 버전표시
This commit is contained in:
@@ -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(() => {});
|
||||
}
|
||||
Reference in New Issue
Block a user