W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
接下來,我們將添加必要的項,將我們的Cargo項目轉(zhuǎn)換為Tauri項目。首先,我們需要在Cargo清單(Cargo.toml
)中添加依賴項,以便Cargo在構(gòu)建時知道拉取這些依賴項。
?Cargo.toml
?:
[package]
name = "hello-tauri-webdriver"
version = "0.1.0"
edition = "2021"
rust-version = "1.56"
# Needed to set up some things for Tauri at build time
[build-dependencies]
tauri-build = "1"
# The actual Tauri dependency, along with `custom-protocol` to serve the pages.
[dependencies]
tauri = { version = "1", features = ["custom-protocol"] }
# Make --release build a binary that is small (opt-level = "s") and fast (lto = true).
# This is completely optional, but shows that testing the application as close to the
# typical release settings is possible. Note: this will slow down compilation.
[profile.release]
incremental = false
codegen-units = 1
panic = "abort"
opt-level = "s"
lto = true
正如你可能已經(jīng)注意到的,我們添加了一個[build-dependency]。為了使用構(gòu)建依賴項,我們必須在構(gòu)建腳本中使用它。我們將在`build.rs`中創(chuàng)建一個構(gòu)建腳本。
?build.rs
?:
fn main() {
// Only watch the `dist/` directory for recompiling, preventing unnecessary
// changes when we change files in other project subdirectories.
println!("cargo:rerun-if-changed=dist");
// Run the Tauri build-time helpers
tauri_build::build()
}
現(xiàn)在,我們的Cargo項目已經(jīng)知道如何使用所有這些設(shè)置來引入和構(gòu)建Tauri的依賴項。讓我們通過在實際項目代碼中設(shè)置Tauri來完成這個極簡示例的Tauri應(yīng)用程序。我們將編輯src/main.rs
文件,以添加Tauri功能。
?src/main.rs
?:
fn main() {
tauri::Builder::default()
.run(tauri::generate_context!())
.expect("unable to run Tauri application");
}
相當(dāng)簡單,對吧?
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: