Skip to content

Commit

Permalink
⚗️ Try to create multiple windows by own.
Browse files Browse the repository at this point in the history
  • Loading branch information
langyo committed Nov 24, 2023
1 parent a77448c commit 6b2c9f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
30 changes: 18 additions & 12 deletions packages/app/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
windows_subsystem = "windows"
)]

use tauri::Manager;
use anyhow::Result;

#[tauri::command]
fn my_custom_command(window: tauri::Window, app_handle: tauri::AppHandle) -> String {
Expand All @@ -25,18 +25,24 @@ fn my_custom_command(window: tauri::Window, app_handle: tauri::AppHandle) -> Str
}

#[async_std::main]
async fn main() {
tauri::Builder::default()
async fn main() -> Result<()> {
let app = tauri::Builder::default()
.invoke_handler(tauri::generate_handler![my_custom_command])
.setup(|app| {
let window = app.get_window("main").unwrap();
window.center().unwrap();
.setup(|_app| Ok(()))
.build(tauri::generate_context!("./tauri.conf.json"))?;

#[cfg(feature = "devtools")]
window.open_devtools();
for id in 1..=3 {
tauri::WindowBuilder::new(
&app,
format!("local{id}"),
tauri::WindowUrl::App("index.html".into()),
)
.transparent(true)
.decorations(false)
.build()?;
}

Ok(())
})
.run(tauri::generate_context!("./tauri.conf.json"))
.unwrap();
app.run(|_, _| {});

Ok(())
}
12 changes: 1 addition & 11 deletions packages/app/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@
"startDragging": true
}
},
"windows": [
{
"title": "Hikari",
"width": 800,
"height": 600,
"resizable": true,
"fullscreen": false,
"transparent": true,
"decorations": false
}
]
"windows": []
}
}

0 comments on commit 6b2c9f6

Please sign in to comment.