前言
在tauri的官网,有这篇blog
Experimental Tauri Verso Integration | Taurihttps://v2.tauri.app/blog/tauri-verso-integration/实验性地将Tauri和Verso整合起来,这篇就来尝试一下,看看效果
正文
配置
Verso是什么
简单地说
Verso is a web browser built on top of the Servo web engine.
说白了,就是一个浏览器,废话不多说。
需要依赖tauri-runtime-verso
versotile-org/tauri-runtime-versohttps://github.com/versotile-org/tauri-runtime-verso/ 笔者新建一个项目
根据tauri-runtime-verso修改配置文件
"externalBin": [
"versoview/versoview"
],
运行的时候会自动下载需要的二进制文件。
修改cargo.toml文件,内容如下
[package]
name = "tv"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2024"
[build-dependencies]
tauri-build = "2"
tauri-runtime-verso-build = { git = "https://github.com/versotile-org/tauri-runtime-verso.git" }
[dependencies]
tauri = { version = "2", default-features = false, features = ["common-controls-v6"] }
tauri-runtime-verso={git = "https://github.com/versotile-org/tauri-runtime-verso/"}
serde = { version = "1", features = ["derive"] }
serde_json = "1"
笔者删除lib.rs,修改main.rs
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use tauri::command;
use tauri_runtime_verso::{INVOKE_SYSTEM_SCRIPTS};
#[command]
fn greet(name: &str) -> String {
format!("Hello {name}, You have been greeted from Rust!")
}
fn main() {
tauri_runtime_verso::set_verso_devtools_port(5555);
tauri_runtime_verso::builder()
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.unwrap();
}
再修改build.rs
fn main() {
tauri_runtime_verso_build::get_verso_as_external_bin().unwrap();
tauri_build::build();
}
运行
安装需要的依赖后
pnpm run tauri dev
结果如下
运行还是没有问题的,就图标好像没显示出来,不知道内部加载的情况。
大致应该是如下
笔者运行官网的案例,比如api
运行没有问题。颜色什么都有
这个窗口的样式好像不一样,可能是自定义的。
debugger
要想debugger需要借助firxfox,笔者专门去下了一个
在more tool中,选择Remote debuggering
添加对应的端口号,笔者是5555
结果如下
其他浏览器应该也可以,但是笔者不知道怎么操作。
总结
截止到目前,这个Verso,还处于开发状态,本身没有开发者工具,不好调试。
图标也加载不了,有待改进。