Skip to content

Commit 28bc5c2

Browse files
authored
feat(http): add http plugin version in user agent sting (#1501)
* feat(http): add http plugin version in user agent sting * Update build.rs
1 parent 720b604 commit 28bc5c2

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

examples/api/src-tauri/src/tray.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::sync::atomic::{AtomicBool, Ordering};
66
use tauri::{
77
menu::{Menu, MenuItem},
8-
tray::{ClickType, TrayIconBuilder},
8+
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
99
Manager, Runtime, WebviewUrl, WebviewWindowBuilder,
1010
};
1111

@@ -107,7 +107,12 @@ pub fn create_tray<R: Runtime>(app: &tauri::AppHandle<R>) -> tauri::Result<()> {
107107
_ => {}
108108
})
109109
.on_tray_icon_event(|tray, event| {
110-
if event.click_type == ClickType::Left {
110+
if let TrayIconEvent::Click {
111+
button_state: MouseButtonState::Down,
112+
button: MouseButton::Left,
113+
..
114+
} = event
115+
{
111116
let app = tray.app_handle();
112117
if let Some(window) = app.get_webview_window("main") {
113118
let _ = window.show();

plugins/http/src/commands.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use crate::{
1919
Error, Http, Result,
2020
};
2121

22+
const HTTP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),);
23+
2224
struct ReqwestResponse(reqwest::Response);
2325

2426
type CancelableResponseResult = Result<Result<reqwest::Response>>;
@@ -221,7 +223,7 @@ pub async fn fetch<R: Runtime>(
221223
}
222224

223225
if !headers.contains_key(header::USER_AGENT.as_str()) {
224-
request = request.header(header::USER_AGENT, "tauri-plugin-http");
226+
request = request.header(header::USER_AGENT, HTTP_USER_AGENT);
225227
}
226228

227229
if cfg!(feature = "unsafe-headers")

plugins/notification/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const COMMANDS: &[&str] = &[
1818
"list_channels",
1919
"delete_channel",
2020
"create_channel",
21-
"permission_state"
21+
"permission_state",
2222
];
2323

2424
fn main() {

0 commit comments

Comments
 (0)