操作系统(os)
提供与操作系统相关的实用方法和属性。
当 tauri.conf.json
中的 build.withGlobalTauri
设置为 true
时,可以通过 window.__TAURI__.os
访问此包。
这些 API 必须添加到 tauri.conf.json
中的 tauri.allowlist.os
中:
{
"tauri": {
"allowlist": {
"os": {
"all": true, // enable all Os APIs
}
}
}
}
建议仅将您使用的 API 列入白名单,以获得最佳的包大小和安全性。
Type Aliases
Functions
arch
返回为 tauri 应用编译的操作系统 CPU 架构。可能的值有 'x86'
、'x86_64'
、'arm'
、'aarch64'
、'mips'
、'mips64'
、'powerpc'
、'powerpc64'
、'riscv64'
、's390x'
、'sparc64'
。
示例
import { arch } from '@tauri-apps/api/os';
const archName = await arch();
Since: 1.0.0
platform
返回标识操作系统平台的字符串。该值在编译时设置。可能的值有 'linux'
、'darwin'
、'ios'
、'freebsd'
、'dragonfly'
、'netbsd'
、'openbsd'
、'solaris'
、'android'
、'win32'
。
示例
import { platform } from '@tauri-apps/api/os';
const platformName = await platform();
Since: 1.0.0
tempdir
-
tempdir():
Promise
<string
>
返回操作系统默认的临时文件目录的字符串。
示例
import { tempdir } from '@tauri-apps/api/os';
const tempdirPath = await tempdir();
Since: 1.0.0
返回: Promise
<string
>