app
获取应用程序基本信息
如果在 tauri.conf.json 文件中把 build.withGlobalTauri 设置为true,则也可通过window.__ TAURI __ .app访问。
以下函数必须添加到 tauri.conf.json 文件中的 tauri.allowlist.app 里。
{
"tauri": {
"allowlist": {
"app": {
"all": true, // app下的所有函数都可以用
"show": true,
"hide": true
}
}
}
}
不建议用all,最好把所用的列出来,可以减少包的大小以及提高安全性。
注:上面中划线的文字部分是官网上内容,但是本人实际运行的时候该节点不需要添加到 allowlist 里
函数
getName
getName(): Promise < string >
获取应用程序名称
例:
import { getName } from '@tauri-apps/api/app';
const appName = await getName();
版本:1.0.0
所返回的就是 tauri.conf.json 文件中的 package.productName设置的值
getTauriVersion
getTauriVersion(): Promise < string >
获取Tauri的版本号
版本:1.0.0
getVersion
getVersion(): Promise < string >
获取应用程序的版本号
版本:1.0.0
所返回的就是 tauri.conf.json 文件中的 package.version设置的值
hide
hide(): Promise < void >
在macOS上隐藏应用程序
版本:1.2.0
show
show(): Promise < void >
在macOS上显示应用程序。此功能不会自动聚焦任何具体的应用程序窗口
版本:1.2.0