Skip to content

Commit 1856413

Browse files
author
bayashi
authored
Merge pull request #172 from bayashi/const-window-name
const window name
2 parents 6602b7c + 0c7f1ac commit 1856413

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src-tauri/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ use tauri::Config;
66

77
const IS_DEV: bool = tauri::is_dev();
88

9+
const WINDOW_NAME: &str = "main";
10+
911
#[derive(Serialize, Deserialize, Debug)]
1012
struct Clock {
1113
#[serde(default)]
@@ -161,7 +163,7 @@ pub fn run() {
161163
let mut tbr = tauri::Builder::default();
162164
if IS_DEV {
163165
tbr = tbr.setup(|app| {
164-
let _window = app.get_webview_window("main").unwrap();
166+
let _window = app.get_webview_window(WINDOW_NAME).unwrap();
165167
#[cfg(debug_assertions)]
166168
{
167169
_window.open_devtools();
@@ -171,8 +173,8 @@ pub fn run() {
171173
} else {
172174
tbr = tbr.plugin(tauri_plugin_single_instance::init(|_app, _args, _cwd| {
173175
let _ = _app
174-
.get_webview_window("main")
175-
.expect("execute only main window")
176+
.get_webview_window(WINDOW_NAME)
177+
.expect(&format!("execute only {} window", WINDOW_NAME))
176178
.set_focus();
177179
}))
178180
}

0 commit comments

Comments
 (0)