コンテンツにスキップ
Tauri

OS Information(OS 情報)

《訳注》

Plugin 説明内容の英語表記部分について Plugin の各章は、原文データからページ内容の一部が自動生成されているため、英語表記のままの部分があります。

「OS Information(OS 情報)」プラグインを使用して、オペレーティング・システムに関する情報を読み取ります。

This plugin requires a Rust version of at least 1.77.2

Platform Level Notes
windows
linux
macos
android
ios

はじめに、「OS Information」プラグインをインストールしてください。

自分のプロジェクトのパッケージ・マネージャーを使用して依存関係を追加します:

npm run tauri add os

このプラグインを使用すると、現在のオペレーティング・システム*から複数の情報を照会できます。利用可能なすべての関数については、JavaScript API または Rust API の各リファレンスをご覧ください。

《訳注》

* オペレーション・システム: 原文は operational system で、直訳では「運用システム」の意味になりますが、ここでは「オペレーション・システム」の意味に解釈しています。

platform は、使用中のオペレーティング・システムを表す文字列を返します。この値がコンパイル時に設定されます。取り得る値は linuxmacosiosfreebsddragonflynetbsdopenbsdsolarisandroidwindows です。

import { platform } from '@tauri-apps/plugin-os';
// `"withGlobalTauri": true` を使用する場合は、
// const { platform } = window.__TAURI__.os; を使用できます
const currentPlatform = platform();
console.log(currentPlatform);
// コンソールに「windows」と表示します

デフォルトでは、潜在的に危険なプラグイン・コマンドとそのスコープ(有効範囲)はすべてブロックされており、アクセスできません。これらを有効にするには、capabilities 設定でアクセス権限を変更する必要があります。

詳細については「セキュリティ・レベル Capabilities」の章を参照してください。また、プラグインのアクセス権限を設定するには「プライグン・アクセス権の使用」の章のステップ・バイ・ステップ・ガイドを参照してください。

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

Default Permission

This permission set configures which operating system information are available to gather from the frontend.

Granted Permissions

All information except the host name are available.

This default permission set includes the following:

  • allow-arch
  • allow-exe-extension
  • allow-family
  • allow-locale
  • allow-os-type
  • allow-platform
  • allow-version

Permission Table

Identifier Description

os:allow-arch

Enables the arch command without any pre-configured scope.

os:deny-arch

Denies the arch command without any pre-configured scope.

os:allow-exe-extension

Enables the exe_extension command without any pre-configured scope.

os:deny-exe-extension

Denies the exe_extension command without any pre-configured scope.

os:allow-family

Enables the family command without any pre-configured scope.

os:deny-family

Denies the family command without any pre-configured scope.

os:allow-hostname

Enables the hostname command without any pre-configured scope.

os:deny-hostname

Denies the hostname command without any pre-configured scope.

os:allow-locale

Enables the locale command without any pre-configured scope.

os:deny-locale

Denies the locale command without any pre-configured scope.

os:allow-os-type

Enables the os_type command without any pre-configured scope.

os:deny-os-type

Denies the os_type command without any pre-configured scope.

os:allow-platform

Enables the platform command without any pre-configured scope.

os:deny-platform

Denies the platform command without any pre-configured scope.

os:allow-version

Enables the version command without any pre-configured scope.

os:deny-version

Denies the version command without any pre-configured scope.

【※ この日本語版は、「Feb 22, 2025 英語版」に基づいています】


© 2025 Tauri Contributors. CC-BY / MIT