debug macos and linux
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
a333a261fd
commit
626fdefb18
@ -1,4 +1,8 @@
|
|||||||
extern crate hbb_common;
|
extern crate hbb_common;
|
||||||
|
#[cfg(target_os = "linux")]
|
||||||
|
use hbb_common::platform::linux;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use hbb_common::platform::macos;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
@ -6,7 +10,7 @@ fn main() {
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
macos::alert(
|
macos::alert(
|
||||||
"RustDesk".to_owned(),
|
"RustDesk".to_owned(),
|
||||||
"critical".to_owned(),
|
"warning".to_owned(),
|
||||||
"test title".to_owned(),
|
"test title".to_owned(),
|
||||||
"test message".to_owned(),
|
"test message".to_owned(),
|
||||||
["Ok".to_owned()].to_vec(),
|
["Ok".to_owned()].to_vec(),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
|
use crate::ResultType;
|
||||||
use osascript;
|
use osascript;
|
||||||
use serde_derive;
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct AlertParams {
|
struct AlertParams {
|
||||||
@ -20,36 +21,35 @@ struct AlertResult {
|
|||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
/// * `app` - The app to execute the script.
|
/// * `app` - The app to execute the script.
|
||||||
/// * `alert_type` - Alert type. critical
|
/// * `alert_type` - Alert type. . informational, warning, critical
|
||||||
/// * `title` - The alert title.
|
/// * `title` - The alert title.
|
||||||
/// * `message` - The alert message.
|
/// * `message` - The alert message.
|
||||||
/// * `buttons` - The buttons to show.
|
/// * `buttons` - The buttons to show.
|
||||||
pub fn alert(
|
pub fn alert(
|
||||||
app: &str,
|
app: String,
|
||||||
alert_type: &str,
|
alert_type: String,
|
||||||
title: &str,
|
title: String,
|
||||||
message: String,
|
message: String,
|
||||||
buttons: Vec<String>,
|
buttons: Vec<String>,
|
||||||
) -> ResultType<String> {
|
) -> ResultType<String> {
|
||||||
let script = osascript::JavaScript::new(format!(
|
let script = osascript::JavaScript::new(&format!(
|
||||||
"
|
"
|
||||||
var App = Application('{}');
|
var App = Application('{}');
|
||||||
App.includeStandardAdditions = true;
|
App.includeStandardAdditions = true;
|
||||||
return App.displayAlert($params.title, {
|
return App.displayAlert($params.title, {{
|
||||||
message: $params.message,
|
message: $params.message,
|
||||||
'as': $params.alert_type,
|
'as': $params.alert_type,
|
||||||
buttons: $params.buttons,
|
buttons: $params.buttons,
|
||||||
});
|
}});
|
||||||
",
|
",
|
||||||
app
|
app
|
||||||
));
|
));
|
||||||
|
|
||||||
script
|
let result: AlertResult = script.execute_with_params(AlertParams {
|
||||||
.execute_with_params(AlertParams {
|
title,
|
||||||
title,
|
message,
|
||||||
message,
|
alert_type,
|
||||||
alert_type,
|
buttons,
|
||||||
buttons,
|
})?;
|
||||||
})?
|
Ok(result.button)
|
||||||
.button
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user