tauri-apps/tauri

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

Open

#10 478 ouverte le 4 août 2024

Voir sur GitHub
 (13 commentaires) (2 réactions) (0 assignés)Rust (3 597 forks)batch import
help wantedtype: documentation

Métriques du dépôt

Stars
 (106 642 stars)
Métriques de merge PR
 (Merge moyen 4j 18h) (56 PRs mergées en 30 j)

Description

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

Guide contributeur