跳转到内容
Tauri

操作系统信息

使用操作系统信息插件读取操作系统信息。

设置

安装操作系统信息插件开始。

使用项目的包管理器来添加依赖:

npm run tauri add os

用法

通过这个插件,您可以查询当前操作系统的多个信息。请参阅 JavaScript APIRust API 参考资料中的所有可用函数。

示例:操作系统平台

platform 返回一个描述使用的特定操作系统的字符串。该值在编译时设置。可能的值有 linuxmacosiosfreebsddragonflynetbsdopenbsdsolarisandroidwindows

import { platform } from '@tauri-apps/plugin-os';
const currentPlatform = await platform();
console.log(currentPlatform);
// Prints "windows" to the console

© 2024 Tauri Contributors. CC-BY / MIT