use std::{fs, path::PathBuf};
fn main() -> wry::Result<()> {
use wry::{
application::{
event::{Event, StartCause, WindowEvent},
event_loop::{ControlFlow, EventLoop},
window::WindowBuilder,
},
webview::{WebContext, WebViewBuilder},
};
let mut test_path = PathBuf::from("./target/webview_data");
fs::create_dir_all(&test_path)?;
test_path = fs::canonicalize(&test_path)?;
println!("Webview storage path: {:#?}", &test_path);
let event_loop = EventLoop::new();
let web_context = WebContext::new(Some(test_path));
let window = WindowBuilder::new()
.with_title("Hello World")
.build(&event_loop)
.unwrap();
let _webview = WebViewBuilder::new(window)
.unwrap()
.with_url("https://tauri.studio")?
.with_web_context(&web_context)
.build()?;
event_loop.run(move |event, _, control_flow| {
*control_flow = ControlFlow::Wait;
match event {
Event::NewEvents(StartCause::Init) => println!("Wry application started!"),
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
} => *control_flow = ControlFlow::Exit,
_ => (),
}
});
}