MCPcopy Create free account
hub / github.com/GCWing/BitFun / with_export_webview

Function with_export_webview

src/apps/desktop/src/api/miniapp_export_api.rs:92–121  ·  view source on GitHub ↗
(
    app: &AppHandle<R>,
    html: String,
    width: u32,
    height: u32,
    task: F,
)

Source from the content-addressed store, hash-verified

90}
91
92async fn with_export_webview<R: tauri::Runtime, F, Fut, T>(
93 app: &AppHandle<R>,
94 html: String,
95 width: u32,
96 height: u32,
97 task: F,
98) -> Result<T, String>
99where
100 F: FnOnce(tauri::Webview<R>) -> Fut,
101 Fut: std::future::Future<Output = Result<T, String>>,
102{
103 let window = ensure_export_host_window(app, width, height)?;
104 let wrapped = wrap_slide_html(&html, width, height);
105 let (url, temp_html) = file_url_for_export_html(app, &wrapped)?;
106
107 window
108 .navigate(url)
109 .map_err(|error| format!("Failed to navigate export webview: {error}"))?;
110
111 tokio::time::sleep(Duration::from_millis(RENDER_SETTLE_MS)).await;
112
113 let webview = app
114 .get_webview(EXPORT_HOST_LABEL)
115 .ok_or_else(|| format!("Export webview is not ready: {EXPORT_HOST_LABEL}"))?;
116
117 let result = task(webview).await;
118 let _ = std::fs::remove_file(&temp_html);
119 let _ = window.hide();
120 result
121}
122
123#[tauri::command]
124pub async fn miniapp_render_slide_page(

Callers 1

Calls 5

wrap_slide_htmlFunction · 0.85
file_url_for_export_htmlFunction · 0.85
navigateMethod · 0.80
hideMethod · 0.45

Tested by

no test coverage detected