fix(mqtt): gate Tauri commands behind feature

This commit is contained in:
t8y2 committed 2026-08-04 19:56:19 +08:00
1 parent 8cfe380784
commit 8d03d284d9
3 files changed
+19

No files matched your search

+10
View File
@@ -1098,12 +1098,17 @@ async fn test_connection_with_info_inner(
Err("Message queue admin support is not compiled in this build. Rebuild with the 'mq-admin' feature." Err("Message queue admin support is not compiled in this build. Rebuild with the 'mq-admin' feature."
.to_string()) .to_string())
} }
#[cfg(feature = "mq-admin")]
DatabaseType::Mqtt => { DatabaseType::Mqtt => {
let mqtt_config = dbx_core::mqtt::types::MqttConnectionConfig::from_connection(&config)?; let mqtt_config = dbx_core::mqtt::types::MqttConnectionConfig::from_connection(&config)?;
let client = dbx_core::mqtt::client::MqttClient::connect(mqtt_config).await?; let client = dbx_core::mqtt::client::MqttClient::connect(mqtt_config).await?;
client.disconnect().await; client.disconnect().await;
Ok("Connection successful".to_string()) Ok("Connection successful".to_string())
} }
#[cfg(not(feature = "mq-admin"))]
DatabaseType::Mqtt => {
Err("MQTT support is not compiled in this build. Rebuild with the 'mq-admin' feature.".to_string())
}
db_type if database_capabilities::is_agent_type(&db_type) => { db_type if database_capabilities::is_agent_type(&db_type) => {
match test_agent_connection(state, &config, &host, port).await { match test_agent_connection(state, &config, &host, port).await {
Ok(details) => { Ok(details) => {
@@ -1455,11 +1460,16 @@ pub async fn connect_db(
state.external_driver_pool("jdbc", &jdbc_config).await? state.external_driver_pool("jdbc", &jdbc_config).await?
} }
DatabaseType::Jdbc => state.external_driver_pool("jdbc", &db_config).await?, DatabaseType::Jdbc => state.external_driver_pool("jdbc", &db_config).await?,
#[cfg(feature = "mq-admin")]
DatabaseType::Mqtt => { DatabaseType::Mqtt => {
let mqtt_config = dbx_core::mqtt::types::MqttConnectionConfig::from_connection(&db_config)?; let mqtt_config = dbx_core::mqtt::types::MqttConnectionConfig::from_connection(&db_config)?;
let client = dbx_core::mqtt::client::MqttClient::connect(mqtt_config).await?; let client = dbx_core::mqtt::client::MqttClient::connect(mqtt_config).await?;
PoolKind::Mqtt(client) PoolKind::Mqtt(client)
} }
#[cfg(not(feature = "mq-admin"))]
DatabaseType::Mqtt => {
return Err("MQTT support is not compiled in this build. Rebuild with the 'mq-admin' feature.".to_string());
}
db_type => return Err(format!("Unsupported database type: {db_type:?}")), db_type => return Err(format!("Unsupported database type: {db_type:?}")),
}; };
+1
View File
@@ -26,6 +26,7 @@ pub mod mcp_bridge;
pub mod mongo_cmd; pub mod mongo_cmd;
#[cfg(feature = "mq-admin")] #[cfg(feature = "mq-admin")]
pub mod mq_cmd; pub mod mq_cmd;
#[cfg(feature = "mq-admin")]
pub mod mqtt_cmd; pub mod mqtt_cmd;
pub mod nacos_cmd; pub mod nacos_cmd;
pub mod plugins; pub mod plugins;
+8
View File
@@ -1967,13 +1967,21 @@ pub fn run() {
commands::mq_cmd::mq_raw_request, commands::mq_cmd::mq_raw_request,
#[cfg(feature = "mq-admin")] #[cfg(feature = "mq-admin")]
commands::mq_cmd::mq_send_message, commands::mq_cmd::mq_send_message,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_get_broker_info, commands::mqtt_cmd::mqtt_get_broker_info,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_subscribe, commands::mqtt_cmd::mqtt_subscribe,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_unsubscribe, commands::mqtt_cmd::mqtt_unsubscribe,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_publish, commands::mqtt_cmd::mqtt_publish,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_list_topics, commands::mqtt_cmd::mqtt_list_topics,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_get_topic_tree, commands::mqtt_cmd::mqtt_get_topic_tree,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_get_messages, commands::mqtt_cmd::mqtt_get_messages,
#[cfg(feature = "mq-admin")]
commands::mqtt_cmd::mqtt_clear_messages, commands::mqtt_cmd::mqtt_clear_messages,
commands::history::save_history, commands::history::save_history,
commands::history::load_history, commands::history::load_history,