app
获取应用程序元数据。
当tauri.conf.json
中的build.withGlobalTauri
设置为true
时,此包也可以通过window.__TAURI__.app
访问。
必须将API添加到tauri.conf.json
中的tauri.allowlist.app
{
"tauri": {
"allowlist": {
"app": {
"all": true, // enable all app APIs
"show": true,
"hide": true
}
}
}
}
建议仅允许列出您使用的API,以优化包大小和安全性。
函数
getName
getName():
Promise
<string
>
获取应用程序名称。
示例
import { getName } from '@tauri-apps/api/app';
const appName = await getName();
自: 1.0.0
返回: Promise
<string
>
getTauriVersion
getTauriVersion():
Promise
<string
>
获取Tauri版本。
示例
import { getTauriVersion } from '@tauri-apps/api/app';
const tauriVersion = await getTauriVersion();
自: 1.0.0
返回: Promise
<string
>
getVersion
getVersion():
Promise
<string
>
获取应用程序版本。
示例
import { getVersion } from '@tauri-apps/api/app';
const appVersion = await getVersion();
自: 1.0.0
返回: Promise
<string
>
hide
hide():
Promise
<void
>
在macOS上隐藏应用程序。
示例
import { hide } from '@tauri-apps/api/app';
await hide();
自: 1.2.0
返回: Promise
<void
>
show
show():
Promise
<void
>
在macOS上显示应用程序。此函数不会自动聚焦任何特定的应用程序窗口。
示例
import { show } from '@tauri-apps/api/app';
await show();
自: 1.2.0
返回: Promise
<void
>