Skip to content

Commit

Permalink
fix: correct usage of tauri-plugin-window-state (#147)
Browse files Browse the repository at this point in the history
Signed-off-by: 1111mp <[email protected]>
  • Loading branch information
1111mp committed Dec 5, 2024
1 parent be05253 commit e3cd040
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src-tauri/src/cmds.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Result;
use std::{path::PathBuf, process::Command};
use tauri_plugin_window_state::{AppHandleExt, StateFlags};

use crate::{
config::{Config, Group, ISettings, NVersion, Project},
Expand Down Expand Up @@ -188,6 +189,7 @@ pub fn open_dir(dir: String) -> CmdResult<()> {
/// restart app
#[tauri::command]
pub fn restart(app_handle: tauri::AppHandle) {
let _ = app_handle.save_window_state(StateFlags::default());
app_handle.restart()
}

Expand Down
7 changes: 2 additions & 5 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn main() -> tauri::Result<()> {
cmds::group_list,
cmds::update_groups,
cmds::update_group_version,
// configration
// configuration
cmds::configration_export,
cmds::configration_import,
// app
Expand Down Expand Up @@ -97,10 +97,7 @@ fn main() -> tauri::Result<()> {

let app = builder.build(tauri::generate_context!())?;

app.run(|app_handle, err| match err {
tauri::RunEvent::ExitRequested { .. } => {
let _ = app_handle.save_window_state(StateFlags::default());
}
app.run(|_, err| match err {
tauri::RunEvent::WindowEvent { label, event, .. } => {
if label == "main" {
match event {
Expand Down
8 changes: 3 additions & 5 deletions src-tauri/src/utils/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ pub fn create_window() -> Result<()> {
.visible(false)
.fullscreen(false)
.inner_size(1024.0, 728.0)
.min_inner_size(1024.0, 728.0)
.resizable(false)
.center();

Expand All @@ -67,11 +68,8 @@ pub fn create_window() -> Result<()> {
#[cfg(target_os = "linux")]
let window = builder.decorations(false).transparent(true).build()?;

if tauri::is_dev() {
window.open_devtools();
}

let _ = window.restore_state(StateFlags::all());
#[cfg(debug_assertions)]
window.open_devtools();

Ok(())
}

0 comments on commit e3cd040

Please sign in to comment.