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();
}
相关推荐
Euato_Key30 分钟前
全栈视野学习Cookie——理解 Cookie 的本质
前端
前端开发呀31 分钟前
我的 AI 终端配置清单
前端
敲代码的玉米C1 小时前
测试一直在写你的真实数据根
前端·人工智能·架构
真上帝的左手1 小时前
10. 软件设计&架构-Spring Security 7 整合CAS SSO 单点登录
java·spring·架构·sso
执子念的飞鱼1 小时前
File Viewer 进入 2K 节点后,我更在意这 3 条回归
前端·typescript
richdata1 小时前
动态OTB vs 静态OTB:鞋服零售该选哪种管理模式?
前端·html·零售
Jodie同志1 小时前
第16~23天:持久化、HITL、流式、MCP与安全
前端·后端·agent
Jodie同志1 小时前
第1~15天:原生Agent、RAG与LangGraph基础(完整代码实操)
前端·后端·agent
sunly_1 小时前
React useActionState 的用法详解
前端·javascript·react.js
今日无bug1 小时前
RESTful + Interface:从 todos 项目理解后端接口设计
前端·restful