@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
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
function eol(): string
返回操作系统特定的行结束符。
- POSIX 系统上为
\n
- Windows 系统上为
\r\n
字符串
2.0.0
来源:https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L62
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
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
function hostname(): Promise<string | null>
返回操作系统的hostname。
Promise
<string
| 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
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
来源:https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/os/guest-js/index.ts#L169
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#L79
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#L123
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