tauri2中创建新的窗口方式,和tauri1不一样了哦

看官方javascript的api文档:window | Tauri

tauri中的rust文档:https://docs.rs/tauri/latest/tauri/index.html

tauri.config.json定义文档:Configuration | Tauri

tauri可用插件:tauri-apps repositories · GitHub

在前端页面创建窗口示例:

javascript 复制代码
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

示例代码:

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();
}
相关推荐
摸鱼的老谭21 小时前
构建Agent该选Python还是Java ?
java·python·agent
lang2015092821 小时前
Spring Boot 官方文档精解:构建与依赖管理
java·spring boot·后端
昔人'21 小时前
css使用 :where() 来简化大型 CSS 选择器列表
前端·css
昔人'21 小时前
css `dorp-shadow`
前端·css
夫唯不争,故无尤也1 天前
Tomcat 启动后只显示 index.jsp,没有进入你的 Servlet 逻辑
java·servlet·tomcat
流***陌1 天前
扭蛋机 Roll 福利房小程序前端功能设计:融合趣味互动与福利适配
前端·小程序
zz-zjx1 天前
Tomcat核心组件全解析
java·tomcat
Deschen1 天前
设计模式-外观模式
java·设计模式·外观模式
Andya_net1 天前
网络安全 | 深入了解 X.509 证书及其应用
服务器·安全·web安全
烛阴1 天前
用 Python 揭秘 IP 地址背后的地理位置和信息
前端·python