tauri-apps/tauri

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

Aberta

#10.478 aberto em 4 de ago. de 2024

 (13 comentários) (2 reações) (0 responsável)Rust (3.597 forks)batch import
help wantedtype: documentation

Métricas do repositório

Stars
 (106.642 estrelas)
Métricas de merge de PR
 (Mesclagem média 4d 18h) (56 fundiu PRs em 30d)

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

Guia do colaborador