看官方javascript的api文档:window | Tauri
tauri中的rust文档:https://docs.rs/tauri/latest/tauri/index.html
tauri.config.json定义文档:Configuration | Tauri
tauri可用插件:tauri-apps repositories · GitHub
在前端页面创建窗口示例:
import { Window } from "@tauri-apps/api/window"const appWindow = new Window('theUniqueLabel');appWindow.once('tauri://created', function () {// window successfully created
});
appWindow.once('tauri://error', function (e) {// an error happened creating the window
});// emit an event to the backend
await appWindow.emit("some-event", "data");
// listen to an event from the backend
const unlisten = await appWindow.listen("event-name", e => {});
unlisten();
在tauri后端rust创建窗口文档:WebviewWindowBuilder in tauri::webview - Rust
示例代码:
#[tauri::command]
async fn create_window(app: tauri::AppHandle) {let webview_window = tauri::WebviewWindowBuilder::new(&app, "label", tauri::WebviewUrl::App("index.html".into())).build().unwrap();
}