mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-06-02 13:41:49 +02:00
feat: add init scripts (#361)
This commit is contained in:
committed by
GitHub
parent
d87b569643
commit
7ae7167fbe
@@ -271,8 +271,8 @@ pub(crate) async fn ask<R: Runtime>(
|
||||
title,
|
||||
message,
|
||||
type_,
|
||||
ok_button_label,
|
||||
cancel_button_label,
|
||||
Some(ok_button_label.unwrap_or_else(|| "Yes".into())),
|
||||
Some(cancel_button_label.unwrap_or_else(|| "No".into())),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ pub(crate) async fn confirm<R: Runtime>(
|
||||
title,
|
||||
message,
|
||||
type_,
|
||||
ok_button_label,
|
||||
cancel_button_label,
|
||||
Some(ok_button_label.unwrap_or_else(|| "Ok".into())),
|
||||
Some(cancel_button_label.unwrap_or_else(|| "Cancel".into())),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
window.alert = function (message) {
|
||||
window.__TAURI_INVOKE__('plugin:dialog|message', {
|
||||
message: message.toString()
|
||||
})
|
||||
}
|
||||
|
||||
window.confirm = function (message) {
|
||||
return window.__TAURI_INVOKE__('plugin:dialog|confirm', {
|
||||
message: message.toString()
|
||||
})
|
||||
}
|
||||
@@ -69,7 +69,15 @@ impl<R: Runtime> Dialog<R> {
|
||||
|
||||
/// Initializes the plugin.
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::new("dialog")
|
||||
let mut builder = Builder::new("dialog");
|
||||
|
||||
// Dialogs are implemented natively on Android
|
||||
#[cfg(not(target_os = "android"))]
|
||||
{
|
||||
builder = builder.js_init_script(include_str!("init.js").to_string());
|
||||
}
|
||||
|
||||
builder
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
commands::open,
|
||||
commands::save,
|
||||
|
||||
Reference in New Issue
Block a user