跳到内容
Tauri

进程

此插件提供访问当前进程的 API。要生成子进程,请参阅 shell 插件。

支持的平台

此插件需要 Rust 版本至少为 1.77.2

平台 级别 注释
windows
linux
macos
android
ios

设置

安装 plugin-process 即可开始使用。

使用项目的包管理器添加依赖项

npm run tauri add process

用法

进程插件在 JavaScript 和 Rust 中都可用。

import { exit, relaunch } from '@tauri-apps/plugin-process';
// when using `"withGlobalTauri": true`, you may use
// const { exit, relaunch } = window.__TAURI__.process;
// exits the app with the given status code
await exit(0);
// restarts the app
await relaunch();

权限

默认情况下,所有潜在危险的插件命令和作用域都被阻止,无法访问。您必须修改 capabilities 配置中的权限才能启用这些。

有关更多信息,请参阅功能概述,并参阅使用插件权限的分步指南

src-tauri/capabilities/default.json
{
"permissions": [
...,
"process:default",
]
}

默认权限

此权限集配置默认情况下公开哪些进程功能。

已授予的权限

这允许通过 allow-exit 退出并通过 allow-restart 重启应用程序。

此默认权限集包括以下内容

  • allow-exit
  • allow-restart

权限表

标识符 描述

process:allow-exit

启用 exit 命令,无需任何预配置的作用域。

process:deny-exit

拒绝 exit 命令,无需任何预配置的作用域。

process:allow-restart

启用 restart 命令,无需任何预配置的作用域。

process:deny-restart

拒绝 restart 命令,无需任何预配置的作用域。


© 2025 Tauri 贡献者。 CC-BY / MIT