앱 버전표시
This commit is contained in:
@@ -4,12 +4,24 @@ use tauri::{
|
||||
AppHandle, Manager, RunEvent,
|
||||
};
|
||||
|
||||
fn format_main_window_title(version: &str) -> String {
|
||||
format!("GoldenChart (v{version})")
|
||||
}
|
||||
|
||||
fn apply_main_window_title(app: &AppHandle) {
|
||||
let title = format_main_window_title(&app.package_info().version.to_string());
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
let _ = w.set_title(&title);
|
||||
}
|
||||
}
|
||||
|
||||
fn show_main_window(app: &AppHandle) {
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
let _ = w.show();
|
||||
let _ = w.unminimize();
|
||||
let _ = w.set_focus();
|
||||
}
|
||||
apply_main_window_title(app);
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
@@ -21,11 +33,7 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.setup(|app| {
|
||||
let version = app.package_info().version.to_string();
|
||||
let main_title = format!("GoldenChart (v{version})");
|
||||
if let Some(w) = app.get_webview_window("main") {
|
||||
let _ = w.set_title(&main_title);
|
||||
}
|
||||
apply_main_window_title(app.handle());
|
||||
|
||||
let show_i = MenuItemBuilder::with_id("show", "GoldenChart 열기").build(app)?;
|
||||
let quit_i = MenuItemBuilder::with_id("quit", "종료").build(app)?;
|
||||
@@ -63,10 +71,19 @@ pub fn run() {
|
||||
show_main_window(app.handle());
|
||||
Ok(())
|
||||
})
|
||||
.on_page_load(|webview, _payload| {
|
||||
if webview.label() != "main" {
|
||||
return;
|
||||
}
|
||||
apply_main_window_title(webview.app_handle());
|
||||
})
|
||||
.on_window_event(|window, event| {
|
||||
if window.label() != "main" {
|
||||
return;
|
||||
}
|
||||
if matches!(event, tauri::WindowEvent::Focused(true)) {
|
||||
apply_main_window_title(window.app_handle());
|
||||
}
|
||||
if let tauri::WindowEvent::CloseRequested { api, .. } = event {
|
||||
api.prevent_close();
|
||||
let _ = window.hide();
|
||||
@@ -75,6 +92,7 @@ pub fn run() {
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while building tauri application")
|
||||
.run(|app_handle, event| match event {
|
||||
RunEvent::Ready => apply_main_window_title(&app_handle),
|
||||
#[cfg(target_os = "macos")]
|
||||
RunEvent::Reopen { .. } => show_main_window(&app_handle),
|
||||
RunEvent::ExitRequested { api, .. } => {
|
||||
|
||||
Reference in New Issue
Block a user