mirror of
https://github.com/tauri-apps/tauri-docs.git
synced 2026-01-31 00:35:16 +01:00
i18n(ja): Japanese Texts for first 6 files in Plugins Section (#3500)
Co-authored-by: Ayres Vitor <gitkey@virtuaires.com.br>
This commit is contained in:
committed by
GitHub
parent
eef42a2d1c
commit
85db46925f
169
src/content/docs/ja/plugin/autostart.mdx
Normal file
169
src/content/docs/ja/plugin/autostart.mdx
Normal file
@@ -0,0 +1,169 @@
|
||||
---
|
||||
title: Autostart(自動起動)
|
||||
description: システム起動時にアプリを自動的に起動します。
|
||||
plugin: autostart
|
||||
i18nReady: true
|
||||
---
|
||||
|
||||
import PluginLinks from '@components/PluginLinks.astro';
|
||||
import Compatibility from '@components/plugins/Compatibility.astro';
|
||||
|
||||
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
||||
import CommandTabs from '@components/CommandTabs.astro';
|
||||
import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
<PluginLinks plugin={frontmatter.plugin} />
|
||||
|
||||
システム起動時にアプリを自動的に起動します。
|
||||
|
||||
## 対応プラットフォーム
|
||||
|
||||
<Compatibility plugin={frontmatter.plugin} />
|
||||
|
||||
## セットアップ
|
||||
|
||||
はじめに、「Autostart(自動起動)」プラグインをインストールしてください。
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="自動で設定">
|
||||
|
||||
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
|
||||
|
||||
{' '}
|
||||
|
||||
<CommandTabs
|
||||
npm="npm run tauri add autostart"
|
||||
yarn="yarn run tauri add autostart"
|
||||
pnpm="pnpm tauri add autostart"
|
||||
deno="deno task tauri add autostart"
|
||||
bun="bun tauri add autostart"
|
||||
cargo="cargo tauri add autostart"
|
||||
/>
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="手動で設定">
|
||||
<Steps>
|
||||
|
||||
1. `src-tauri` フォルダで次のコマンドを実行して、`Cargo.toml` 内のプロジェクトの依存関係にこのプラグインを追加します:
|
||||
|
||||
```sh frame=none
|
||||
cargo add tauri-plugin-autostart --target 'cfg(any(target_os = "macos", windows, target_os = "linux"))'
|
||||
```
|
||||
|
||||
2. 追加したプラグインを初期化するために `lib.rs` を修正します:
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" ins={5-6}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
#[cfg(desktop)]
|
||||
app.handle().plugin(tauri_plugin_autostart::init(tauri_plugin_autostart::MacosLauncher::LaunchAgent, Some(vec!["--flag1", "--flag2"]) /* アプリに渡す任意の数の引数 */));
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
3. お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guest」バインディングをインストールします:
|
||||
|
||||
<CommandTabs
|
||||
npm="npm install @tauri-apps/plugin-autostart"
|
||||
yarn="yarn add @tauri-apps/plugin-autostart"
|
||||
pnpm="pnpm add @tauri-apps/plugin-autostart"
|
||||
deno="deno add npm:@tauri-apps/plugin-autostart"
|
||||
bun="bun add @tauri-apps/plugin-autostart"
|
||||
/>
|
||||
|
||||
</Steps>
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
|
||||
## 使用法
|
||||
|
||||
「Autostart(自動起動)」プラグインは、JavaScript と Rust の両方で利用できます。
|
||||
|
||||
<Tabs syncKey="lang">
|
||||
<TabItem label="JavaScript">
|
||||
|
||||
```javascript
|
||||
import { enable, isEnabled, disable } from '@tauri-apps/plugin-autostart';
|
||||
// `"withGlobalTauri": true` を使用する場合は、
|
||||
// const { enable, isEnabled, disable } = window.__TAURI__.autostart; を使用できます;
|
||||
|
||||
// autostart を有効化
|
||||
await enable();
|
||||
// 有効化状態を確認
|
||||
console.log(`registered for autostart? ${await isEnabled()}`);
|
||||
// autostart を無効化
|
||||
disable();
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="Rust">
|
||||
|
||||
```rust
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
#[cfg(desktop)]
|
||||
{
|
||||
use tauri_plugin_autostart::MacosLauncher;
|
||||
use tauri_plugin_autostart::ManagerExt;
|
||||
|
||||
app.handle().plugin(tauri_plugin_autostart::init(
|
||||
MacosLauncher::LaunchAgent,
|
||||
Some(vec!["--flag1", "--flag2"]),
|
||||
));
|
||||
|
||||
// 「autostart マネージャー」を入手
|
||||
let autostart_manager = app.autolaunch();
|
||||
// autostart を有効化
|
||||
let _ = autostart_manager.enable();
|
||||
// 有効化状態を確認
|
||||
println!("registered for autostart? {}", autostart_manager.is_enabled().unwrap());
|
||||
// autostart を無効化
|
||||
let _ = autostart_manager.disable();
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## アクセス権の設定
|
||||
|
||||
デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、`capabilities` 設定でアクセス権限を変更する必要があります。
|
||||
|
||||
詳細については「[セキュリティ・レベル Capabilities](/ja/security/capabilities/)」の章を参照してください。また、プラグインのアクセス権限を設定するには「[プライグン・アクセス権の使用](/ja/learn/security/using-plugin-permissions/)」の章のステップ・バイ・ステップ・ガイドを参照してください。
|
||||
|
||||
```json title="src-tauri/capabilities/default.json"
|
||||
{
|
||||
"permissions": [
|
||||
...,
|
||||
"autostart:allow-enable",
|
||||
"autostart:allow-disable",
|
||||
"autostart:allow-is-enabled"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
<PluginPermissions plugin={frontmatter.plugin} />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】
|
||||
</div>
|
||||
149
src/content/docs/ja/plugin/barcode-scanner.mdx
Normal file
149
src/content/docs/ja/plugin/barcode-scanner.mdx
Normal file
@@ -0,0 +1,149 @@
|
||||
---
|
||||
title: Barcode Scanner(バーコード・スキャナー)
|
||||
description: モバイル・アプリでカメラを使用し、QR コード、EAN-13、その他のバーコードをスキャン可能にします。
|
||||
plugin: barcode-scanner
|
||||
i18nReady: true
|
||||
---
|
||||
|
||||
import PluginLinks from '@components/PluginLinks.astro';
|
||||
import Compatibility from '@components/plugins/Compatibility.astro';
|
||||
|
||||
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
||||
import CommandTabs from '@components/CommandTabs.astro';
|
||||
import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
<PluginLinks plugin={frontmatter.plugin} />
|
||||
|
||||
モバイル・アプリでカメラを使用し、QR コード、EAN-13、その他のバーコードをスキャン可能にします。
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**EAN-13** European Article Number: 商品識別コード/バーコード規格のひとつで、13 桁の「欧州商品番号」の意味。日本で最も普及している商品識別コードである「JAN コード」と同等のもの。《[Wikipedia](https://ja.wikipedia.org/wiki/EANコード)》
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
## 対応プラットフォーム
|
||||
|
||||
<Compatibility plugin={frontmatter.plugin} />
|
||||
|
||||
## セットアップ
|
||||
|
||||
はじめに、「Barcode Scanner(バーコード・スキャナー)」プラグインをインストールしてください。
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="自動で設定">
|
||||
|
||||
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
|
||||
|
||||
{' '}
|
||||
|
||||
<CommandTabs
|
||||
npm="npm run tauri add barcode-scanner"
|
||||
yarn="yarn run tauri add barcode-scanner"
|
||||
pnpm="pnpm tauri add barcode-scanner"
|
||||
deno="deno task tauri add barcode-scanner"
|
||||
bun="bun tauri add barcode-scanner"
|
||||
cargo="cargo tauri add barcode-scanner"
|
||||
/>
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="手動で設定">
|
||||
<Steps>
|
||||
|
||||
1. `src-tauri` フォルダで次のコマンドを実行して、`Cargo.toml` 内のプロジェクトの依存関係にこのプラグインを追加します:
|
||||
|
||||
```sh frame=none
|
||||
cargo add tauri-plugin-barcode-scanner --target 'cfg(any(target_os = "android", target_os = "ios"))'
|
||||
```
|
||||
|
||||
2. 追加したプラグインを初期化するために `lib.rs` を修正します:
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" ins={5-6}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
#[cfg(mobile)]
|
||||
app.handle().plugin(tauri_plugin_barcode_scanner::init());
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
3. お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guest」バインディングをインストールします:
|
||||
|
||||
<CommandTabs
|
||||
npm="npm install @tauri-apps/plugin-barcode-scanner"
|
||||
yarn="yarn add @tauri-apps/plugin-barcode-scanner"
|
||||
pnpm="pnpm add @tauri-apps/plugin-barcode-scanner"
|
||||
deno="deno add npm:@tauri-apps/plugin-barcode-scanner"
|
||||
bun="bun add @tauri-apps/plugin-barcode-scanner"
|
||||
/>
|
||||
|
||||
</Steps>
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 設定
|
||||
|
||||
iOS では、「Barcode Scanner」プラグインに、あなたのアプリがカメラを使用する理由を説明する `NSCameraUsageDescription` 情報プロパティ・リストの値が必要です。
|
||||
|
||||
`src-tauri/Info.ios.plist` ファイルには、以下のスニペット(内容)を追加してください。
|
||||
|
||||
```xml title=src-tauri/Info.ios.plist
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSCameraUsageDescription</key>
|
||||
<string>Read QR codes</string>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
## 使用法
|
||||
|
||||
「Barcode Scanner」プラグインは JavaScript で利用できます。
|
||||
|
||||
```javascript
|
||||
import { scan, Format } from '@tauri-apps/plugin-barcode-scanner';
|
||||
// `"withGlobalTauri": true` を使用する場合は、
|
||||
// const { scan, Format } = window.__TAURI__.barcodeScanner; を使用できます;
|
||||
|
||||
// `windowed: true` は、カメラ用に別のビューを開くのではなく、
|
||||
// 実際には Webview を透明に設定します
|
||||
// 要素の透明化により下にあるものが表示されるように、ユーザーインターフェースを設定しておいてください
|
||||
scan({ windowed: true, formats: [Format.QRCode] });
|
||||
```
|
||||
|
||||
## アクセス権の設定
|
||||
|
||||
デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、`capabilities` 設定でアクセス権限を変更する必要があります。
|
||||
|
||||
詳細については「[セキュリティ・レベル Capabilities](/ja/security/capabilities/)」の章を参照してください。また、プラグインのアクセス権限を設定するには「[プライグン・アクセス権の使用](/ja/learn/security/using-plugin-permissions/)」の章のステップ・バイ・ステップ・ガイドを参照してください。
|
||||
|
||||
```json title="src-tauri/capabilities/mobile.json"
|
||||
{
|
||||
"$schema": "../gen/schemas/mobile-schema.json",
|
||||
"identifier": "mobile-capability",
|
||||
"windows": ["main"],
|
||||
"platforms": ["iOS", "android"],
|
||||
"permissions": ["barcode-scanner:allow-scan", "barcode-scanner:allow-cancel"]
|
||||
}
|
||||
```
|
||||
|
||||
<PluginPermissions plugin={frontmatter.plugin} />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Jul 1, 2025 英語版」に基づいています】
|
||||
</div>
|
||||
239
src/content/docs/ja/plugin/biometric.mdx
Normal file
239
src/content/docs/ja/plugin/biometric.mdx
Normal file
@@ -0,0 +1,239 @@
|
||||
---
|
||||
title: Biometric(生体認証)
|
||||
description: Android および iOS で、ユーザーに生体認証を要求します。
|
||||
plugin: biometric
|
||||
i18nReady: true
|
||||
---
|
||||
|
||||
import PluginLinks from '@components/PluginLinks.astro';
|
||||
import Compatibility from '@components/plugins/Compatibility.astro';
|
||||
|
||||
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
||||
import CommandTabs from '@components/CommandTabs.astro';
|
||||
import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
<PluginLinks plugin={frontmatter.plugin} />
|
||||
|
||||
Android および iOS で、ユーザーに「生体認証 biometric authentication」を要求します。
|
||||
|
||||
## 対応プラットフォーム
|
||||
|
||||
<Compatibility plugin={frontmatter.plugin} />
|
||||
|
||||
## セットアップ
|
||||
|
||||
はじめに、「Biometric(生体認証)」プラグインをインストールしてください。
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="自動で設定">
|
||||
|
||||
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
|
||||
|
||||
<CommandTabs npm="npm run tauri add biometric"
|
||||
yarn="yarn run tauri add biometric"
|
||||
pnpm="pnpm tauri add biometric"
|
||||
deno="deno task tauri add biometric"
|
||||
bun="bun tauri add biometric"
|
||||
cargo="cargo tauri add biometric" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="手動で設定">
|
||||
<Steps>
|
||||
1. `src-tauri` フォルダで次のコマンドを実行して、`Cargo.toml` 内のプロジェクトの依存関係にこのプラグインを追加します:
|
||||
|
||||
```sh frame=none
|
||||
cargo add tauri-plugin-biometric --target 'cfg(any(target_os = "android", target_os = "ios"))'
|
||||
```
|
||||
|
||||
2. 追加したプラグインを初期化するために `lib.rs` を修正します:
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" ins={5-6}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
#[cfg(mobile)]
|
||||
app.handle().plugin(tauri_plugin_biometric::Builder::new().build());
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
3. お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guide」バインディングをインストールします:
|
||||
|
||||
<CommandTabs
|
||||
npm = "npm install @tauri-apps/plugin-biometric"
|
||||
yarn = "yarn add @tauri-apps/plugin-biometric"
|
||||
pnpm = "pnpm add @tauri-apps/plugin-biometric"
|
||||
deno = "deno add npm:@tauri-apps/plugin-biometric"
|
||||
bun = "bun add @tauri-apps/plugin-biometric"
|
||||
/>
|
||||
</Steps>
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
|
||||
## 設定
|
||||
|
||||
iOS では、「Biometric(生体認証)」プラグインに、あなたのアプリが「生体認証」を使用する理由を説明する `NSFaceIDUsageDescription` 情報プロパティ・リストの値が必要です。
|
||||
|
||||
`src-tauri/Info.ios.plist` ファイルには、以下のスニペット(内容)を追加してください:
|
||||
|
||||
```xml title=src-tauri/Info.ios.plist
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSFaceIDUsageDescription</key>
|
||||
<string>Authenticate with biometric</string>
|
||||
</dict>
|
||||
</plist>
|
||||
```
|
||||
|
||||
## 使用法
|
||||
|
||||
このプラグインを使用すると、デバイス上で生体認証が利用可能かどうかを確認し、ユーザーに生体認証を要求し、その結果を検証して認証が成功したかどうかを判断できるようになります。
|
||||
|
||||
### プラグインの状態確認
|
||||
|
||||
生体認証が利用可能か、どのタイプの生体認証方法がサポートされているのか、などをはじめとして、「生体認証」の状態(ステータス)を確認できます。
|
||||
|
||||
<Tabs syncKey="lang">
|
||||
<TabItem label="JavaScript">
|
||||
|
||||
```javascript
|
||||
import { checkStatus } from '@tauri-apps/plugin-biometric';
|
||||
|
||||
const status = await checkStatus();
|
||||
if (status.isAvailable) {
|
||||
console.log('Yes! Biometric Authentication is available');
|
||||
} else {
|
||||
console.log(
|
||||
'No! Biometric Authentication is not available due to ' + status.error
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="Rust">
|
||||
|
||||
```rust
|
||||
use tauri_plugin_biometric::BiometricExt;
|
||||
|
||||
fn check_biometric(app_handle: tauri::AppHandle) {
|
||||
let status = app_handle.biometric().status().unwrap();
|
||||
if status.is_available {
|
||||
println!("Yes! Biometric Authentication is available");
|
||||
} else {
|
||||
println!("No! Biometric Authentication is not available due to: {}", status.error.unwrap());
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### 認証
|
||||
|
||||
ユーザーに「生体認証」を要求するには、`authenticate()` メソッドを使用します。
|
||||
|
||||
<Tabs syncKey="lang">
|
||||
|
||||
<TabItem label="JavaScript">
|
||||
|
||||
```javascript ins={18}
|
||||
import { authenticate } from '@tauri-apps/plugin-biometric';
|
||||
|
||||
const options = {
|
||||
// ユーザーが「電話のパスワード」を使用して認証できるようにするには、true に設定します
|
||||
allowDeviceCredential: false,
|
||||
cancelTitle: "Feature won't work if Canceled",
|
||||
|
||||
// iOS のみの機能
|
||||
fallbackTitle: 'Sorry, authentication failed',
|
||||
|
||||
// Android のみの機能
|
||||
title: 'Tauri feature',
|
||||
subtitle: 'Authenticate to access the locked Tauri function',
|
||||
confirmationRequired: true,
|
||||
};
|
||||
|
||||
try {
|
||||
await authenticate('This feature is locked', options);
|
||||
console.log(
|
||||
'Hooray! Successfully Authenticated! We can now perform the locked Tauri function!'
|
||||
);
|
||||
} catch (err) {
|
||||
console.log('Oh no! Authentication failed because ' + err.message);
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Rust">
|
||||
|
||||
```rust ins={21}
|
||||
use tauri_plugin_biometric::{BiometricExt, AuthOptions};
|
||||
|
||||
fn bio_auth(app_handle: tauri::AppHandle) {
|
||||
|
||||
let options = AuthOptions {
|
||||
// ユーザーが「電話のパスワード」を使用して認証できるようにするには、true に設定します
|
||||
allow_device_credential:false,
|
||||
cancel_title: Some("Feature won't work if Canceled".to_string()),
|
||||
|
||||
// iOS のみの機能
|
||||
fallback_title: Some("Sorry, authentication failed".to_string()),
|
||||
|
||||
// Android のみの機能
|
||||
title: Some("Tauri feature".to_string()),
|
||||
subtitle: Some("Authenticate to access the locked Tauri function".to_string()),
|
||||
confirmation_required: Some(true),
|
||||
};
|
||||
|
||||
// 認証が成功した場合には、関数が Result::Ok() を、
|
||||
// それ以外の場合には Result::Error() を返します。
|
||||
match app_handle.biometric().authenticate("This feature is locked".to_string(), options) {
|
||||
Ok(_) => {
|
||||
println!("Hooray! Successfully Authenticated! We can now perform the locked Tauri function!");
|
||||
}
|
||||
Err(e) => {
|
||||
println!("Oh no! Authentication failed because : {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## アクセス権の設定
|
||||
|
||||
デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、`capabilities` 設定でアクセス権限を変更する必要があります。
|
||||
|
||||
詳細については「[セキュリティ・レベル Capabilities](/ja/security/capabilities/)」の章を参照してください。また、プラグインのアクセス権限を設定するには「[プライグン・アクセス権の使用](/ja/learn/security/using-plugin-permissions/)」の章のステップ・バイ・ステップ・ガイドを参照してください。
|
||||
|
||||
```json title="src-tauri/capabilities/default.json" ins={6}
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "main-capability",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": ["biometric:default"]
|
||||
}
|
||||
```
|
||||
|
||||
<PluginPermissions plugin={frontmatter.plugin} />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Jul 1, 2025 英語版」に基づいています】
|
||||
</div>
|
||||
298
src/content/docs/ja/plugin/cli.mdx
Normal file
298
src/content/docs/ja/plugin/cli.mdx
Normal file
@@ -0,0 +1,298 @@
|
||||
---
|
||||
title: CLI(コマンドライン・インターフェイス)
|
||||
description: コマンドライン・インターフェイスから引数を解析します。
|
||||
plugin: cli
|
||||
i18nReady: true
|
||||
---
|
||||
|
||||
import PluginLinks from '@components/PluginLinks.astro';
|
||||
import Compatibility from '@components/plugins/Compatibility.astro';
|
||||
|
||||
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
||||
import CommandTabs from '@components/CommandTabs.astro';
|
||||
import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
<PluginLinks plugin={frontmatter.plugin} />
|
||||
|
||||
Tauriは、堅牢なコマンドライン引数パーサー(構文解析ツール)である [clap](https://github.com/clap-rs/clap)(英語版)を用いて、あなたのアプリに CLI 機能を追加できます。`tauri.conf.json` ファイルに簡単な CLI 定義を記述するだけで、インターフェースを定義し、JavaScript や Rust 上の引数照合マップを読み取ることが可能になります。
|
||||
|
||||
## 対応プラットフォーム
|
||||
|
||||
<Compatibility plugin={frontmatter.plugin} />
|
||||
|
||||
- Windows
|
||||
- OSの制限により、本番環境アプリでは、デフォルトでは呼び出しコンソールにテキストを書き戻すことができません。この回避策については、[tauri#8305](https://github.com/tauri-apps/tauri/issues/8305#issuecomment-1826871949) をご確認ください。{/* TODO: Inline the instructions into this guide */}
|
||||
|
||||
## セットアップ
|
||||
|
||||
はじめに、「CLI(コマンドライン・インターフェイス)」プラグインをインストールしてください。
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="自動で設定">
|
||||
|
||||
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
|
||||
|
||||
<CommandTabs
|
||||
npm="npm run tauri add cli"
|
||||
yarn="yarn run tauri add cli"
|
||||
pnpm="pnpm tauri add cli"
|
||||
deno="deno task tauri add cli"
|
||||
bun="bun tauri add cli"
|
||||
cargo="cargo tauri add cli"
|
||||
/>
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="手動で設定">
|
||||
<Steps>
|
||||
|
||||
1. `src-tauri` フォルダで次のコマンドを実行して、`Cargo.toml` 内のプロジェクトの依存関係にプラグインを追加します:
|
||||
|
||||
```sh frame=none
|
||||
cargo add tauri-plugin-cli --target 'cfg(any(target_os = "macos", windows, target_os = "linux"))'
|
||||
```
|
||||
|
||||
2. 追加したプラグインを初期化するために `lib.rs` を修正します:
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" ins={5-6}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.setup(|app| {
|
||||
#[cfg(desktop)]
|
||||
app.handle().plugin(tauri_plugin_cli::init());
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
3. お好みの JavaScript パッケージ・マネージャーを使用して、「JavaScript Guest」バインディングをインストールします:
|
||||
|
||||
<CommandTabs
|
||||
npm="npm install @tauri-apps/plugin-cli"
|
||||
yarn="yarn add @tauri-apps/plugin-cli"
|
||||
pnpm="pnpm add @tauri-apps/plugin-cli"
|
||||
deno="deno add npm:@tauri-apps/plugin-cli"
|
||||
bun="bun add @tauri-apps/plugin-cli"
|
||||
/>
|
||||
|
||||
</Steps>
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
|
||||
## 基本設定
|
||||
|
||||
`tauri.conf.json` の中には、インターフェースを設定するための以下の項目があります:
|
||||
|
||||
```json title="src-tauri/tauri.conf.json"
|
||||
{
|
||||
"plugins": {
|
||||
"cli": {
|
||||
"description": "Tauri CLI Plugin Example" /* プラグインの説明 */,
|
||||
"args": [
|
||||
/* 引数 */
|
||||
{
|
||||
"short": "v",
|
||||
"name": "verbose" /* 出力レベル(この場合は「詳細表示」) */,
|
||||
"description": "Verbosity level"
|
||||
}
|
||||
],
|
||||
"subcommands": {
|
||||
"run": {
|
||||
"description": "Run the application" /* コマンドの内容(この場合は「アプリの実行」) */,
|
||||
"args": [
|
||||
{
|
||||
"name": "debug",
|
||||
"description": "Run application in debug mode" /* 「デバッグ・モードでのアプリ実行」 */
|
||||
},
|
||||
{
|
||||
"name": "release",
|
||||
"description": "Run application in release mode" /* 「リリース・モードでのアプリ実行」 */
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
:::note
|
||||
|
||||
ここに記載されている JSON の設定内容はすべて単なる「サンプル」であり、わかりやすくするために他の多くのフィールド項目は省略されています。
|
||||
|
||||
:::
|
||||
|
||||
## 引数の追加
|
||||
|
||||
`args` 配列は、コマンドまたはサブコマンドによって受け入れられる引数のリストを表します。
|
||||
|
||||
{/* TODO: List available configuration */}
|
||||
|
||||
### 位置引数 Positional Argument
|
||||
|
||||
「位置引数」は、引数リスト内の位置によって識別が行なわれます。以下の設定では:
|
||||
|
||||
```json title="src-tauri/tauri.conf.json"
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"name": "source",
|
||||
"index": 1,
|
||||
"takesValue": true
|
||||
},
|
||||
{
|
||||
"name": "destination",
|
||||
"index": 2,
|
||||
"takesValue": true
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
ユーザーはアプリを `./app tauri.txt dest.txt` として実行でき、引数照合マップには `source` を `"tauri.txt"` として、`destination` を `"dest.txt"` として定義します。
|
||||
|
||||
### 名前付き引数 Named Arguments
|
||||
|
||||
「名前付き引数」は[キーと値]のペアで、キーが値を表します。以下の設定では:
|
||||
|
||||
```json title="tauri-src/tauri.conf.json"
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"name": "type",
|
||||
"short": "t",
|
||||
"takesValue": true,
|
||||
"multiple": true,
|
||||
"possibleValues": ["foo", "bar"]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
ユーザーはアプリを `./app --type foo bar`、`./app -t foo -t bar`、または `./app --type=foo,bar` として実行でき、引数照合マップには `type` を `["foo", "bar"]` として定義します。
|
||||
|
||||
### フラグ引数 Flag Arguments
|
||||
|
||||
「フラグ引数」は、独立動作型(スタンドアロン)のキーで、その値の真偽によってアプリケーションに情報を提供します。以下の設定では:
|
||||
|
||||
```json title="tauri-src/tauri.conf.json"
|
||||
{
|
||||
"args": [
|
||||
{
|
||||
"name": "verbose",
|
||||
"short": "v"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
ユーザーはアプリを `./app -v -v -v`、`./app --verbose --verbose --verbose`、または `./app -vvv` として実行でき、引数照合マップには `verbose` を `true`、`occurrences = 3` として定義します。
|
||||
|
||||
## サブコマンド
|
||||
|
||||
一部の CLI アプリケーションには、サブコマンドとしての追加インターフェースがあります。例えば、`git` CLI には `git branch`、`git commit`、`git push`があり、また、`subcommands` 配列を使用すれば、ネストされたインターフェースを追加定義できます:
|
||||
|
||||
```json title="tauri-src/tauri.conf.json"
|
||||
{
|
||||
"cli": {
|
||||
...
|
||||
"subcommands": {
|
||||
"branch": {
|
||||
"args": []
|
||||
},
|
||||
"push": {
|
||||
"args": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
その構成はルート・アプリケーションの構成と同じで、`description`、`longDescription`、`args` などがあります。
|
||||
|
||||
## 使用法
|
||||
|
||||
「CLI(コマンドライン・インターフェイス)」プラグインは、JavaScript と Rust の両方で利用できます。
|
||||
|
||||
<Tabs syncKey="lang">
|
||||
<TabItem label="JavaScript">
|
||||
|
||||
```javascript
|
||||
import { getMatches } from '@tauri-apps/plugin-cli';
|
||||
// `"withGlobalTauri": true` を使用する場合は、
|
||||
// const { getMatches } = window.__TAURI__.cli; を使用できます;
|
||||
|
||||
const matches = await getMatches();
|
||||
if (matches.subcommand?.name === 'run') {
|
||||
// `./your-app run $ARGS` が実行されました
|
||||
const args = matches.subcommand.matches.args;
|
||||
if (args.debug?.value === true) {
|
||||
// `./your-app run --debug` が実行されました
|
||||
}
|
||||
if (args.release?.value === true) {
|
||||
// `./your-app run --release` が実行されました
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="Rust">
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" {1, 6-18}
|
||||
use tauri_plugin_cli::CliExt;
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_cli::init())
|
||||
.setup(|app| {
|
||||
match app.cli().matches() {
|
||||
// ここでの `matches` は { args, subcommand } を持つ構造体です。
|
||||
// 構造体のメンバー `args` は `HashMap<String, ArgData>` であり、`ArgData` は { value, occurrences } を持つ構造体です。
|
||||
// もう一方の構造体メンバー `subcommand` は `Option<Box<SubcommandMatches>>` であり、`SubcommandMatches` は { name, matches } を持つ構造体です。
|
||||
Ok(matches) => {
|
||||
println!("{:?}", matches)
|
||||
}
|
||||
Err(_) => {}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## アクセス権の設定
|
||||
|
||||
デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、`capabilities` 設定でアクセス権限を変更する必要があります。
|
||||
|
||||
詳細については「[セキュリティ・レベル Capabilities](/ja/security/capabilities/)」の章を参照してください。また、プラグインのアクセス権限を設定するには「[プライグン・アクセス権の使用](/ja/learn/security/using-plugin-permissions/)」の章のステップ・バイ・ステップ・ガイドを参照してください。
|
||||
|
||||
```json title="src-tauri/capabilities/default.json" ins={6}
|
||||
{
|
||||
"$schema": "../gen/schemas/desktop-schema.json",
|
||||
"identifier": "main-capability",
|
||||
"description": "Capability for the main window",
|
||||
"windows": ["main"],
|
||||
"permissions": ["cli:default"]
|
||||
}
|
||||
```
|
||||
|
||||
<PluginPermissions plugin={frontmatter.plugin} />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】
|
||||
</div>
|
||||
129
src/content/docs/ja/plugin/clipboard.mdx
Normal file
129
src/content/docs/ja/plugin/clipboard.mdx
Normal file
@@ -0,0 +1,129 @@
|
||||
---
|
||||
title: Clipboard(クリップボード)
|
||||
description: システム・クリップボードの読み取りと書き込みを行ないます。
|
||||
plugin: clipboard-manager
|
||||
i18nReady: true
|
||||
---
|
||||
|
||||
import Stub from '@components/Stub.astro';
|
||||
import PluginLinks from '@components/PluginLinks.astro';
|
||||
import Compatibility from '@components/plugins/Compatibility.astro';
|
||||
|
||||
import { Tabs, TabItem, Steps } from '@astrojs/starlight/components';
|
||||
import CommandTabs from '@components/CommandTabs.astro';
|
||||
import PluginPermissions from '@components/PluginPermissions.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
<PluginLinks plugin={frontmatter.plugin} />
|
||||
|
||||
「clipboard(クリップボード)」プラグインを使用してシステム・クリップボードの読み取りと書き込みを行ないます。
|
||||
|
||||
## 対応プラットフォーム
|
||||
|
||||
<Compatibility plugin={frontmatter.plugin} />
|
||||
|
||||
## セットアップ
|
||||
|
||||
はじめに、「clipboard(クリップボード)」プラグインをインストールしてください。
|
||||
|
||||
<Tabs>
|
||||
<TabItem label="自動で設定">
|
||||
|
||||
自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:
|
||||
|
||||
<CommandTabs npm="npm run tauri add clipboard-manager"
|
||||
yarn="yarn run tauri add clipboard-manager"
|
||||
pnpm="pnpm tauri add clipboard-manager"
|
||||
bun="bun tauri add clipboard-manager"
|
||||
deno="deno task tauri add clipboard-manager"
|
||||
cargo="cargo tauri add clipboard-manager" />
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="手動で設定">
|
||||
<Steps>
|
||||
|
||||
1. `src-tauri` フォルダで次のコマンドを実行して、`Cargo.toml` 内のプロジェクトの依存関係にこのプラグインを追加します:
|
||||
|
||||
```sh frame=none
|
||||
cargo add tauri-plugin-clipboard-manager
|
||||
```
|
||||
|
||||
2. 追加したプラグインを初期化するために `lib.rs` を修正します:
|
||||
|
||||
```rust title="src-tauri/src/lib.rs" ins={4}
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_clipboard_manager::init())
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
```
|
||||
|
||||
3. JavaScript でクリップボードを管理する場合には、npm パッケージもインストールします:
|
||||
|
||||
<CommandTabs
|
||||
npm="npm install @tauri-apps/plugin-clipboard-manager"
|
||||
yarn="yarn add @tauri-apps/plugin-clipboard-manager"
|
||||
pnpm="pnpm add @tauri-apps/plugin-clipboard-manager"
|
||||
deno="deno add npm:@tauri-apps/plugin-clipboard-manager"
|
||||
bun="bun add @tauri-apps/plugin-clipboard-manager"
|
||||
/>
|
||||
|
||||
</Steps>
|
||||
</TabItem>
|
||||
|
||||
</Tabs>
|
||||
|
||||
## 使用法
|
||||
|
||||
{/* TODO: Link to which language to use, frontend vs. backend guide when it's made */}
|
||||
|
||||
「clipboard」プラグインは、JavaScript と Rust の両方で利用できます。
|
||||
|
||||
<Tabs syncKey="lang">
|
||||
<TabItem label="JavaScript">
|
||||
|
||||
```javascript
|
||||
import { writeText, readText } from '@tauri-apps/plugin-clipboard-manager';
|
||||
// `"withGlobalTauri": true` を使用する場合は、
|
||||
// const { writeText, readText } = window.__TAURI__.clipboardManager; を使用できます;
|
||||
|
||||
// コンテンツをクリップボードに書き込みます
|
||||
await writeText('Tauri is awesome!');
|
||||
|
||||
// クリップボードからコンテンツを読み取ります
|
||||
const content = await readText();
|
||||
console.log(content);
|
||||
// コンソールにコンテンツの内容「Tauri is awesome!」を表示します
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem label="Rust">
|
||||
|
||||
```rust
|
||||
use tauri_plugin_clipboard_manager::ClipboardExt;
|
||||
|
||||
app.clipboard().write_text("Tauri is awesome!".to_string()).unwrap();
|
||||
|
||||
// クリップボードからコンテンツを読み取ります
|
||||
let content = app.clipboard().read_text();
|
||||
println!("{:?}", content.unwrap());
|
||||
// ターミナルにコンテンツの内容「Tauri is awesome!」を表示します
|
||||
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
<PluginPermissions plugin={frontmatter.plugin} />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】
|
||||
</div>
|
||||
52
src/content/docs/ja/plugin/index.mdx
Normal file
52
src/content/docs/ja/plugin/index.mdx
Normal file
@@ -0,0 +1,52 @@
|
||||
---
|
||||
title: プラグイン: 機能と利用法
|
||||
i18nReady: true
|
||||
sidebar:
|
||||
label: 概要
|
||||
---
|
||||
|
||||
import { LinkCard } from '@astrojs/starlight/components';
|
||||
import FeaturesList from '@components/list/Features.astro';
|
||||
import CommunityList from '@components/list/Community.astro';
|
||||
import Search from '@components/CardGridSearch.astro';
|
||||
import AwesomeTauri from '@components/AwesomeTauri.astro';
|
||||
import TableCompatibility from '@components/plugins/TableCompatibility.astro';
|
||||
import TranslationNote from '@components/i18n/TranslationNote.astro';
|
||||
|
||||
<TranslationNote lang="ja">
|
||||
|
||||
**Plugin 説明内容の英語表記部分について** Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。
|
||||
|
||||
また、「コミュニティ・リソース版」プラグインは、公式 Tauri 文書にないため、翻訳は行なわれません。各リンク先の説明内容(英語版)を参照してください。
|
||||
|
||||
</TranslationNote>
|
||||
|
||||
Tauri は機能の拡張性を念頭に置いて設計されています。この章では以下のプラグインの内容ついてご覧いただけます:
|
||||
|
||||
- **[Tauri 公式版](#tauri-公式版)**: 組み込まれている Tauri の機能と特徴
|
||||
- **[コミュニティ・リソース版](#コミュニティリソース版)**: Tauri コミュニティによって作成された追加のプラグインとその利用法
|
||||
|
||||
<Search>
|
||||
## Tauri-公式版
|
||||
<FeaturesList />
|
||||
## コミュニティ・リソース版
|
||||
<LinkCard
|
||||
title="共有可能な資料はありますか?"
|
||||
description="プル・リクエストでその素晴らしい資料を公開してみませんか"
|
||||
href="https://github.com/tauri-apps/awesome-tauri/pulls"
|
||||
/>
|
||||
### プラグイン
|
||||
<AwesomeTauri section="plugins-no-official" />
|
||||
### 統合化
|
||||
<AwesomeTauri section="integrations" />
|
||||
</Search>
|
||||
|
||||
## 対応プラットフォーム一覧表
|
||||
|
||||
"\*" 印にカーソルを合わせるとそのプラグインの「対応状況」が表示されます。詳細については各プラグインの説明をご覧ください。
|
||||
|
||||
<TableCompatibility />
|
||||
|
||||
<div style="text-align: right;">
|
||||
【※ この日本語版は、「Sep 30, 2024 英語版」に基づいています】
|
||||
</div>
|
||||
Reference in New Issue
Block a user