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();
}
相关推荐
陆枫Larry1 分钟前
用 Git 别名(Alias)简化日常操作
前端
IT观测1 分钟前
深度分析俩款主流移动统计工具Appvue和openinstall
android·java·数据库
华科易迅2 分钟前
Spring AOP(注解前置+后置通知)
java·后端·spring
阿泽·黑核4 分钟前
Easy Vibe Coding 学习心得(三):前端之美——从设计稿到精美界面
前端·vibe coding·easy vibe
堕2747 分钟前
JavaEE初阶——《计算机是如何工作的》
java·java-ee
code_pgf12 分钟前
Jetson 上 OpenClaw + Ollama + llama.cpp 的联动配置模板部署大模型
服务器·数据库·人工智能·llama
无心水13 分钟前
【时间利器】4、JavaScript时间处理全解:Date/moment/dayjs/Temporal
开发语言·前端·javascript·状态模式·openclaw·date/moment·dayjs/temporal
0xDevNull14 分钟前
Apache RocketMQ 完全指南
java·rocketmq
骇客野人17 分钟前
用python实现一个查询当天天气的MCP服务器
服务器·开发语言·python
XiaoLeisj18 分钟前
Android 文件存储实战:从应用私有目录读写到网络文件落盘与公共存储接入
android·java·网络·文件操作