跳到主要內容
Tauri

@tauri-apps/plugin-os

提供與作業系統相關的實用方法和屬性。

類型別名

架構

type Arch:
| "x86"
| "x86_64"
| "arm"
| "aarch64"
| "mips"
| "mips64"
| "powerpc"
| "powerpc64"
| "riscv64"
| "s390x"
| "sparc64";

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L42


系列

type Family: "unix" | "windows";

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L97


作業系統類型

type OsType:
| "linux"
| "windows"
| "macos"
| "ios"
| "android";

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L40


平台

type Platform:
| "linux"
| "macos"
| "ios"
| "freebsd"
| "dragonfly"
| "netbsd"
| "openbsd"
| "solaris"
| "android"
| "windows";

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L28

函式

arch()

function arch(): Arch

回傳目前的作業系統架構。可能的值為 'x86''x86_64''arm''aarch64''mips''mips64''powerpc''powerpc64''riscv64''s390x''sparc64'

回傳

架構

範例

import { arch } from '@tauri-apps/plugin-os';
const archName = arch();

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L138


eol()

function eol(): string

回傳作業系統特定的行尾標記。

  • \n 在 POSIX 上
  • \r\n 在 Windows 上

回傳

字串

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L62


exeExtension()

function exeExtension(): string

回傳此平台上可執行二進制檔案使用的檔案擴展名(如果有的話)。可能的值為 'exe''' (空字串)。

回傳

字串

範例

import { exeExtension } from '@tauri-apps/plugin-os';
const exeExt = exeExtension();

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L152


family()

function family(): Family

回傳目前的作業系統系列。可能的值為 'unix''windows'

回傳

系列

範例

import { family } from '@tauri-apps/plugin-os';
const family = family();

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L109


hostname()

function hostname(): Promise<string | null>

回傳作業系統的主機名稱。

回傳

Promise<字串 | null>

範例

import { hostname } from '@tauri-apps/plugin-os';
const hostname = await hostname();

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L181


locale()

function locale(): Promise<string | null>

回傳一個字串,其中包含 BCP-47 語言標籤。如果無法取得地區設定,則會改為回傳 null

回傳

Promise<字串 | null>

範例

import { locale } from '@tauri-apps/plugin-os';
const locale = await locale();
if (locale) {
// use the locale string here
}

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L169


platform()

function platform(): Platform

回傳一個字串,描述目前使用的特定作業系統。此值在編譯時設定。可能的值為 'linux''macos''ios''freebsd''dragonfly''netbsd''openbsd''solaris''android''windows'

回傳

平台

範例

import { platform } from '@tauri-apps/plugin-os';
const platformName = platform();

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L169


type()

function type(): OsType

回傳目前的作業系統類型。在 Linux 上回傳 'linux',在 macOS 上回傳 'macos',在 Windows 上回傳 'windows',在 iOS 上回傳 'ios',在 Android 上回傳 'android'

回傳

作業系統類型

範例

import { type } from '@tauri-apps/plugin-os';
const osType = type();

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L79


version()

function version(): string

回傳目前的作業系統版本。

回傳

字串

範例

import { version } from '@tauri-apps/plugin-os';
const osVersion = version();

始於

2.0.0

來源: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L93


© 2025 Tauri 貢獻者。CC-BY / MIT