-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/ allow webview2 (windows) to use optional user_data folder provi…
…ded by the attributes. (#120) * WIP: Allow webview2 to use optional user_data folder. Actually only supported on Windows. Attention the folder need to exist or webview will failed to run. * Use `./target/webview_data` as sample directory for `user_data_path` example. * Use canonicalized path as we require an absolute path for the webview * Make sure to create the directory before we can canonicalize * fmt
- Loading branch information
Showing
7 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::{fs, path::PathBuf}; | ||
use wry::{Application, Attributes, Result}; | ||
|
||
fn main() -> Result<()> { | ||
let mut app = Application::new()?; | ||
|
||
// Use a sample directory at the root of the project | ||
let mut test_path = PathBuf::from("./target/webview_data"); | ||
// The directory need to exist or the Webview will panic | ||
fs::create_dir_all(&test_path)?; | ||
// We need an absoulte path for the webview | ||
test_path = fs::canonicalize(&test_path)?; | ||
// The directory need to exist or the Webview will panic | ||
println!("Webview storage path: {:#?}", &test_path); | ||
|
||
let attributes = Attributes { | ||
url: Some("https://tauri.studio/".to_string()), | ||
title: String::from("Hello World!"), | ||
// Currently supported only on Windows | ||
user_data_path: Some(test_path), | ||
..Default::default() | ||
}; | ||
|
||
app.add_window(attributes)?; | ||
app.run(); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters