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();
}
相关推荐
金銀銅鐵2 分钟前
带您看懂字节码指令(Web 版):第一帧在浏览器里跑一遍
java·jvm·后端
Regulus-Moon8 分钟前
纠删码:用代数换存储
服务器·数据库·分布式
阿策小和尚10 分钟前
把 Python 3.14 + FastAPI + Nuxt 4 压成 164MB 单包迁进 Dopame OS:4 个坑和一份真实体积账单
前端·人工智能·前端框架
ai_xiaogui18 分钟前
Ubuntu Server 安装避坑实录:服务器装成桌面版、网卡驱动缺失怎么办?
linux·服务器·ubuntu·ubuntu server·ubuntu 网卡驱动安装·服务器装机避坑·服务器装机
z2014z34 分钟前
信息安全工程师 第9章 虚拟专用网 技术原理与应用 笔记
服务器·网络
飞花漫卷,情随岁迁38 分钟前
命令进阶与 Playbook 快速入门
java·linux·运维·服务器·网络·数据库·智能路由器
map_3d_vis41 分钟前
百度地图画圆 Circle 和矩形 Rectangle(JSAPI 4.0)
前端·javascript·gis·地图·百度地图
hookserver42 分钟前
企业微信 iPad 协议全功能接入效果实测
java·http·微信·企业微信·ipad
IT枫斗者43 分钟前
缓存和数据库一致性:先更库还是先删缓存,延迟双删怎么落地
java·开发语言·数据库·人工智能·缓存·gateway
播播资源1 小时前
MiniMax-M4 API 选型指南:接入、思考参数与缓存避坑(含实测数据)
java·spring·缓存