跳到主要內容
Tauri

app

函式

defaultWindowIcon()

function defaultWindowIcon(): Promise<Image | null>

取得預設視窗圖示。

回傳

Promise<Image | null>

範例

import { defaultWindowIcon } from '@tauri-apps/api/app';
await defaultWindowIcon();

2.0.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L99


getName()

function getName(): Promise<string>

取得應用程式名稱。

回傳

Promise<string>

範例

import { getName } from '@tauri-apps/api/app';
const appName = await getName();

1.0.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L39


getTauriVersion()

function getTauriVersion(): Promise<string>

取得 Tauri 版本。

回傳

Promise<string>

範例

import { getTauriVersion } from '@tauri-apps/api/app';
const tauriVersion = await getTauriVersion();

1.0.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L54


getVersion()

function getVersion(): Promise<string>

取得應用程式版本。

回傳

Promise<string>

範例

import { getVersion } from '@tauri-apps/api/app';
const appVersion = await getVersion();

1.0.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L25


hide()

function hide(): Promise<void>

在 macOS 上隱藏應用程式。

回傳

Promise<void>

範例

import { hide } from '@tauri-apps/api/app';
await hide();

1.2.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L84


setTheme()

function setTheme(theme?): Promise<void>

設定應用程式主題,傳入 nullundefined 以跟隨系統主題

參數

參數類型
theme?null | Theme

回傳

Promise<void>

範例

import { setTheme } from '@tauri-apps/api/app';
await setTheme('dark');

平台特定

  • iOS / Android: 不支援。

2.0.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L120


show()

function show(): Promise<void>

在 macOS 上顯示應用程式。此函式不會自動聚焦任何特定應用程式視窗。

回傳

Promise<void>

範例

import { show } from '@tauri-apps/api/app';
await show();

1.2.0

來源https://github.com/tauri-apps/tauri/blob/dev/packages/api/src/app.ts#L69


© 2025 Tauri Contributors。CC-BY / MIT