tauri-apps/tauri

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

开放

#10,478 创建于 2024年8月4日

 (13 条评论) (2 个反应) (0 位负责人)Rust (3,597 个派生)batch import
help wantedtype: documentation

仓库指标

星标
 (106,642 个星标)
PR 合并指标
 (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

贡献者指南