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();
}
相关推荐
雪隐12 分钟前
用Flutter做背单词APP-01服务器?不存在的,我家里就有
前端·人工智能·后端
2601_9623413031 分钟前
计算机毕业设计之jsp考研在线复习平台
java·大数据·开发语言·hadoop·python·考研·课程设计
Qimooidea32 分钟前
祁木 CAD Translator 全套功能 & 官网入口汇总
运维·服务器
huangjiazhi_38 分钟前
纯C++实现ini文件操作
java·后端·spring
用户2204603958681 小时前
ES模块和commonJS两种标准下中实现__dirname?一篇文章教你理清楚
前端
zhixingheyi_tian1 小时前
JVM 之 GCLocker
java·jvm
码哥字节1 小时前
把 Cursor 的烂输出变成好代码,这 10 个 Prompt 改造让我省了 80% 改稿时间
java·ai编程工具·cursor 配置·prompt 技巧
2503_931712481 小时前
10m/s超高速电梯:西奥XO-NEWIII如何树立行业速度标杆
java·大数据·数据库
犹豫的大炮1 小时前
jQuery最核心的基础设施之一——数据缓存模块进化史
前端·缓存·jquery