tauri-apps/tauri

v2 requiring an instance of App, AppHandle or Window to get access to path functions like home_dir()

Open

#10,478 建立於 2024年8月4日

在 GitHub 查看
 (13 留言) (2 反應) (0 負責人)Rust (3,597 fork)batch import
help wantedtype: documentation

倉庫指標

Star
 (106,642 star)
PR 合併指標
 (平均合併 4天 18小時) (30 天內合併 56 個 PR)

描述

in v1, all you needed was to import and you had access to paths:

use tauri::api::path::home_dir;

#[tauri::command]
fn getPath() -> Result<PathBuf> {
   home_dir()

but now in v2, you need an instance of AppHandle:

use tauri::Manager;

#[tauri::command]
fn getPath(app: tauri::AppHandle) -> Result<PathBuf> {
   app.path().home_dir()

is this intended? also there's no documentation I could find on v2 usage of paths

貢獻者指南