W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
接下來(lái),我們將添加必要的項(xiàng),將我們的Cargo項(xiàng)目轉(zhuǎn)換為Tauri項(xiàng)目。首先,我們需要在Cargo清單(Cargo.toml
)中添加依賴項(xiàng),以便Cargo在構(gòu)建時(shí)知道拉取這些依賴項(xiàng)。
?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)注意到的,我們添加了一個(gè)[build-dependency]。為了使用構(gòu)建依賴項(xiàng),我們必須在構(gòu)建腳本中使用它。我們將在`build.rs`中創(chuàng)建一個(gè)構(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項(xiàng)目已經(jīng)知道如何使用所有這些設(shè)置來(lái)引入和構(gòu)建Tauri的依賴項(xiàng)。讓我們通過(guò)在實(shí)際項(xiàng)目代碼中設(shè)置Tauri來(lái)完成這個(gè)極簡(jiǎn)示例的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)簡(jiǎn)單,對(duì)吧?
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: