简体   繁体   中英

how to change webview2 user data folder in tauri?

Is there anyway to change user data folder in edge webview2 in tauri? I have to change environenment variable WEBVIEW2_USER_DATA_FOLDER before tauri initialization. but it does work in sometime, so that it is better change it via some interface.

here is my code:

    let udf = xxxxxx; //some folder generated for each user.
    env::set_var("WEBVIEW2_USER_DATA_FOLDER", udf);

Try this:

use tauri::WebView2;
fn main() {
    let mut webview = WebView2::new();
    let udf = xxxxxx; //some folder generated for each user.
    webview.set_user_data_folder(udf);
    webview.run().unwrap();
    }

You can call this method before calling the run method of the WebView2 struct to set the user data folder before the webview is initialized.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2025 STACKOOM.COM