@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
返回操作系统特定的换行符。
- POSIX上的
\n
- Windows上的
\r\n
返回
字符串
自
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
<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
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
来源: 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#L79
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#L123
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