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();
}
相关推荐
特立独行的猫A4 小时前
别再用 nohup 了:让应用在后台常驻的正确姿势与 systemd 服务详解
java·后端·python
一起_java5 小时前
技术文章-基于Dify-Agent的智能问答系统设计与实现
java·spring boot·后端·agent·dify
Flynn Liang6 小时前
I/O 密集型高并发实战:Java 服务 10 维优化,从线程打满到 10 万 QPS
java·spring boot·性能优化·高并发·系统设计·虚拟线程·io密集型
吃我一窝jio7 小时前
Python与Go线程模型深度对比
java·开发语言·python
这个昵称不容易7 小时前
SpringBoot 购物推荐网站的设计与实现:120 个 Java 文件、147 个接口、13 张表,附真实运行截图
java·springboot·毕设
文丑颜不良啊7 小时前
LeetCode3041~3060题目解析
java·leetcode
文丑颜不良啊9 小时前
LeetCode3101~3120题目解析
java·leetcode
Resean02239 小时前
SpringMVC 6+源码分析(十一)视图渲染与异步请求(收尾篇)
java·spring·springmvc
靠沿10 小时前
MySQL数据库进阶——存储过程和触发器
java·数据库·mysql
IT_陈寒10 小时前
Redis那个过期删除策略,差点让我线上崩了
前端·人工智能·后端