docs: Add scope handling in file association example (#10864)

This commit is contained in:
Fabian-Lars 2024-09-02 16:11:55 +02:00 committed by GitHub
parent 6696e48800
commit ecc5362c1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,9 +8,30 @@
)]
use std::path::PathBuf;
use tauri::AppHandle;
use tauri::{AppHandle, Manager};
fn handle_file_associations(app: AppHandle, files: Vec<PathBuf>) {
// -- Scope handling start --
// You can remove this block if you only want to know about the paths, but not actually "use" them in the frontend.
// This requires the `fs` tauri plugin and is required to make the plugin's frontend work:
// use tauri_plugin_fs::FsExt;
// let fs_scope = app.fs_scope();
// This is for the `asset:` protocol to work:
let asset_protocol_scope = app.asset_protocol_scope();
for file in &files {
// This requires the `fs` plugin:
// let _ = fs_scope.allow_file(file);
// This is for the `asset:` protocol:
let _ = asset_protocol_scope.allow_file(file);
}
// -- Scope handling end --
let files = files
.into_iter()
.map(|f| {