Tauri 插件共享Kit
在Android,iOS,macOS和Windows上通过本土共享接口与其他应用程序共享内容.
安装
此插件至少需要一个 Rust 版本 1.65 国家
我们可以建议三种一般的安装方法.
- 使用箱子.io和npm(最轻松,需要你相信我们的出版管道工作)
- 使用 git 标记/ 修订版散列( 最安全) 从 Github 直接取出源头
- Git 子模块在您 Tauri 项目中安装此重播, 然后使用文件协议来摄取源( 最安全但使用不便)
安装核心插件,将以下内容添加到您的 Cargo.toml 文件 :
src-tauri/Cargo.toml
[dependencies]
tauri-plugin-sharekit = "0.4"
# alternatively with Git:
tauri-plugin-sharekit = { git = "https://github.com/Choochmeque/tauri-plugin-sharekit" }
您可以使用您的首选 JavaScript 软件包管理器安装 JavaScript Guest 绑定 :
pnpm add @choochmeque/tauri-plugin-sharekit-api
# or
npm add @choochmeque/tauri-plugin-sharekit-api
# or
yarn add @choochmeque/tauri-plugin-sharekit-api
# alternatively with Git:
pnpm add https://github.com/Choochmeque/tauri-plugin-sharekit
# or
npm add https://github.com/Choochmeque/tauri-plugin-sharekit
# or
yarn add https://github.com/Choochmeque/tauri-plugin-sharekit
使用量
首先您需要用 Tauri 注册核心插件 :
src-tauri/src/main.rs
fn main() {
tauri::Builder::default()
.plugin(tauri_plugin_sharekit::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
之后所有插件的API都可以通过JavaScript来宾绑定:
import { shareText, shareFile } from "@choochmeque/tauri-plugin-sharekit-api";
// Share text
await shareText('Tauri is great!');
// Share a file
await shareFile('file:///path/to/document.pdf', {
mimeType: 'application/pdf',
title: 'My Document'
});
// Share with position (iPad/macOS only)
// x and y are in webview coordinates (pixels from top-left)
await shareText('Hello!', {
position: { x: 100, y: 200, preferredEdge: 'bottom' }
});
捐款
公关接受。 请在提出拉动请求前阅读《贡献指南》.
许可证
麻省理工学院