- 273 名前:デフォルトの名無しさん mailto:sage [2022/05/21(土) 23:40:28.85 ID:GKlgLxBR.net]
- 今流行のアプリをweb-viewのテストで作ってみたがこんな感じなのか
const HTML: &str = r#" なぜかHTML部分はセキュリティうんぬん言われて貼れないので略 "#; fn main() { struct Fibonacci { index: usize, cur: usize, pre: usize } let fibonacci = std::sync::Mutex::new(Fibonacci { index: 0, cur: 0, pre: 1 }); let webview = web_view::builder() .content(web_view::Content::Html(HTML)) .invoke_handler(|webview, arg| { match arg { "next" => { let mut f = fibonacci.lock().unwrap(); (f.index, f.cur, f.pre) = (f.index + 1, f.cur + f.pre, f.cur); webview.eval(&format!("show({}, {})", f.index, f.cur))?; }, "exit" => webview.exit(), _ => unimplemented!(), }; Ok(()) }) .user_data(()).build().unwrap().run().unwrap(); }
|

|