进程
这个插件提供了访问当前进程的 API。要生成子进程,请参阅 shell 插件。
Supported Platforms
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 process
yarn run tauri add process
pnpm tauri add process
bun tauri add process
cargo 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-process
yarn add @tauri-apps/plugin-process
pnpm add @tauri-apps/plugin-process
bun 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