进程
这个插件提供了访问当前进程的 API。要生成子进程,请参阅 shell 插件。
This plugin requires a Rust version of at least 1.77.2
| Platform | Level | Notes |
|---|---|---|
| windows | ||
| linux | ||
| macos | ||
| android | | |
| ios | |
从安装 plugin-process 开始使用。
使用项目的包管理器来添加依赖:
npm run tauri add processyarn run tauri add processpnpm tauri add processbun tauri add processcargo tauri add process-
运行
cargo add tauri-plugin-process命令,将插件添加到项目的Cargo.toml依赖中。 -
修改
lib.rs来初始化插件。
#[cfg_attr(mobile, tauri::mobile_entry_point)]pub fn run() { tauri::Builder::default() // Initialize the plugin .plugin(tauri_plugin_process::init()) .run(tauri::generate_context!()) .expect("error while running tauri application");}- 如果你想在 JavaScript 中使用这个插件,还需要安装 npm 包。
npm install @tauri-apps/plugin-processyarn add @tauri-apps/plugin-processpnpm add @tauri-apps/plugin-processbun add @tauri-apps/plugin-process这个插件有 JavaScript 和 Rust 两种版本。
import { exit, relaunch } from '@tauri-apps/plugin-process';
// exits the app with the given status codeawait exit(0);
// restarts the appawait relaunch();请注意,app 是 AppHandle 的一个实例。
// exits the app with the given status codeapp.exit(0);
// restarts the appapp.restart();© 2025 Tauri Contributors. CC-BY / MIT