mirror of
https://github.com/tauri-apps/tauri.git
synced 2025-01-04 17:18:56 +03:00
feat(tauri) allow plugin config on tauri.conf.json (#824)
This commit is contained in:
parent
3337677109
commit
56f819d2ef
@ -259,6 +259,18 @@
|
|||||||
},
|
},
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"plugins": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"additionalProperties": {
|
||||||
|
},
|
||||||
|
"defaultProperties": [
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"defaultProperties": [
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"defaultProperties": [
|
"defaultProperties": [
|
||||||
|
@ -292,6 +292,11 @@ export interface TauriConfig {
|
|||||||
active?: boolean
|
active?: boolean
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
plugins?: {
|
||||||
|
[name: string]: {
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TauriConfig
|
export default TauriConfig
|
||||||
|
@ -269,6 +269,18 @@ export const TauriConfigSchema = {
|
|||||||
},
|
},
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"plugins": {
|
||||||
|
"additionalProperties": {
|
||||||
|
"additionalProperties": {
|
||||||
|
},
|
||||||
|
"defaultProperties": [
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"defaultProperties": [
|
||||||
|
],
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"defaultProperties": [
|
"defaultProperties": [
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
use serde::de::{Deserializer, Error as DeError, Visitor};
|
use serde::de::{Deserializer, Error as DeError, Visitor};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use serde_json::Value as JsonValue;
|
||||||
|
|
||||||
use once_cell::sync::OnceCell;
|
use once_cell::sync::OnceCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -306,6 +307,8 @@ fn default_dev_path() -> String {
|
|||||||
"".to_string()
|
"".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type JsonObject = HashMap<String, JsonValue>;
|
||||||
|
|
||||||
/// The tauri.conf.json mapper.
|
/// The tauri.conf.json mapper.
|
||||||
#[derive(PartialEq, Deserialize, Debug)]
|
#[derive(PartialEq, Deserialize, Debug)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
@ -316,6 +319,16 @@ pub struct Config {
|
|||||||
/// The build configuration.
|
/// The build configuration.
|
||||||
#[serde(default = "default_build")]
|
#[serde(default = "default_build")]
|
||||||
pub build: BuildConfig,
|
pub build: BuildConfig,
|
||||||
|
/// The plugins config.
|
||||||
|
#[serde(default)]
|
||||||
|
plugins: HashMap<String, JsonObject>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
/// Gets a plugin configuration.
|
||||||
|
pub fn plugin_config<S: AsRef<str>>(&self, plugin_name: S) -> Option<&JsonObject> {
|
||||||
|
self.plugins.get(plugin_name.as_ref())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_tauri() -> TauriConfig {
|
fn default_tauri() -> TauriConfig {
|
||||||
@ -431,6 +444,7 @@ mod test {
|
|||||||
build: BuildConfig {
|
build: BuildConfig {
|
||||||
dev_path: String::from("../dist"),
|
dev_path: String::from("../dist"),
|
||||||
},
|
},
|
||||||
|
plugins: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user