跳到内容
Tauri

@tauri-apps/plugin-os

提供与操作系统相关的实用方法和属性。

类型别名

Arch

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

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


Family

type Family: "unix" | "windows";

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


OsType

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

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


Platform

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

Source: 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'

返回值

Arch

示例

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

始于

2.0.0

Source: 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 上

返回值

string

始于

2.0.0

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


exeExtension()

function exeExtension(): string

返回用于此平台上可执行二进制文件的文件扩展名(如果有)。可能的值为 'exe''' (空字符串)。

返回值

string

示例

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

始于

2.0.0

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


family()

function family(): Family

返回当前操作系统的系列。可能的值为 'unix''windows'

返回值

Family

示例

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

始于

2.0.0

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


hostname()

function hostname(): Promise<string | null>

返回操作系统的主机名。

返回值

Promise<string | null>

示例

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

Source: 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<string | null>

示例

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

始于

2.0.0

Source: 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'

返回值

Platform

示例

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

始于

2.0.0

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


type()

function type(): OsType

返回当前操作系统类型。在 Linux 上返回 'linux',在 macOS 上返回 'macos',在 Windows 上返回 'windows',在 iOS 上返回 'ios',在 Android 上返回 'android'

返回值

OsType

示例

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

始于

2.0.0

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L123


version()

function version(): string

返回当前操作系统版本。

返回值

string

示例

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

始于

2.0.0

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


© 2025 Tauri 贡献者。CC-BY / MIT