Skip to content
Tauri 中文网

剪贴板

使用剪贴板插件读取和写入系统剪贴板。

¥Read and write to the system clipboard using the clipboard plugin.

支持的平台

¥Supported Platforms

This plugin requires a Rust version of at least 1.77.2

Platform Level Notes
windows
linux
macos
android

Only plain-text content support

ios

Only plain-text content support

设置

¥Setup

安装剪贴板插件即可开始使用。

¥Install the clipboard plugin to get started.

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

¥Use your project’s package manager to add the dependency:

npm run tauri add clipboard-manager

使用

¥Usage

剪贴板插件在 JavaScript 和 Rust 中均可用。

¥The clipboard plugin is available in both JavaScript and Rust.

import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';
// when using `"withGlobalTauri": true`, you may use
// const { writeText, readText } = window.__TAURI__.clipboardManager;
// Write content to clipboard
await writeText('Tauri is awesome!');
// Read content from clipboard
const content = await readText();
console.log(content);
// Prints "Tauri is awesome!" to the console

Default Permission

No features are enabled by default, as we believe the clipboard can be inherently dangerous and it is application specific if read and/or write access is needed.

Clipboard interaction needs to be explicitly enabled.

Permission Table

Identifier Description

clipboard-manager:allow-clear

Enables the clear command without any pre-configured scope.

clipboard-manager:deny-clear

Denies the clear command without any pre-configured scope.

clipboard-manager:allow-read-image

Enables the read_image command without any pre-configured scope.

clipboard-manager:deny-read-image

Denies the read_image command without any pre-configured scope.

clipboard-manager:allow-read-text

Enables the read_text command without any pre-configured scope.

clipboard-manager:deny-read-text

Denies the read_text command without any pre-configured scope.

clipboard-manager:allow-write-html

Enables the write_html command without any pre-configured scope.

clipboard-manager:deny-write-html

Denies the write_html command without any pre-configured scope.

clipboard-manager:allow-write-image

Enables the write_image command without any pre-configured scope.

clipboard-manager:deny-write-image

Denies the write_image command without any pre-configured scope.

clipboard-manager:allow-write-text

Enables the write_text command without any pre-configured scope.

clipboard-manager:deny-write-text

Denies the write_text command without any pre-configured scope.


Tauri 中文网 - 粤ICP备13048890号