mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
feat(fs): enhance scope config to accept string as well (#1053)
* feat(fs): enhance scope config to accept string as well * clippy * Update protocol.rs * regression resolving path variables * add change file --------- Co-authored-by: Lucas Nogueira <lucas@tauri.app>
This commit is contained in:
co-authored by
Lucas Nogueira
parent
fe4ad4dd5c
commit
f39d362add
+28
-2
@@ -2,12 +2,38 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use std::{fs::create_dir_all, path::Path};
|
||||
use std::{
|
||||
fs::create_dir_all,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
#[path = "src/scope.rs"]
|
||||
#[allow(dead_code)]
|
||||
mod scope;
|
||||
|
||||
/// FS scope entry.
|
||||
#[derive(schemars::JsonSchema)]
|
||||
#[serde(untagged)]
|
||||
#[allow(unused)]
|
||||
enum FsScopeEntry {
|
||||
/// FS scope path.
|
||||
Value(PathBuf),
|
||||
Object {
|
||||
/// FS scope path.
|
||||
path: PathBuf,
|
||||
},
|
||||
}
|
||||
|
||||
// Ensure scope entry is kept up to date
|
||||
impl From<FsScopeEntry> for scope::EntryRaw {
|
||||
fn from(value: FsScopeEntry) -> Self {
|
||||
match value {
|
||||
FsScopeEntry::Value(path) => scope::EntryRaw::Value(path),
|
||||
FsScopeEntry::Object { path } => scope::EntryRaw::Object { path },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const BASE_DIR_VARS: &[&str] = &[
|
||||
"AUDIO",
|
||||
"CACHE",
|
||||
@@ -163,6 +189,6 @@ permissions = [
|
||||
|
||||
tauri_plugin::Builder::new(COMMANDS)
|
||||
.global_api_script_path("./api-iife.js")
|
||||
.global_scope_schema(schemars::schema_for!(scope::Entry))
|
||||
.global_scope_schema(schemars::schema_for!(FsScopeEntry))
|
||||
.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user