mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
use Wry as default ApplicationExt (#1303)
Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
This commit is contained in:
@@ -9,7 +9,7 @@ mod cmd;
|
||||
struct Context;
|
||||
|
||||
fn main() {
|
||||
tauri::AppBuilder::<tauri::flavors::Wry, Context>::new()
|
||||
tauri::AppBuilder::<Context>::new()
|
||||
.invoke_handler(|_webview, arg| async move {
|
||||
use cmd::Cmd::*;
|
||||
match serde_json::from_str(&arg) {
|
||||
|
||||
@@ -16,7 +16,7 @@ struct Reply {
|
||||
struct Context;
|
||||
|
||||
fn main() {
|
||||
tauri::AppBuilder::<tauri::flavors::Wry, Context>::new()
|
||||
tauri::AppBuilder::<Context>::new()
|
||||
.setup(|webview_manager| async move {
|
||||
let dispatcher = webview_manager.current_webview().await.unwrap();
|
||||
let dispatcher_ = dispatcher.clone();
|
||||
|
||||
@@ -10,7 +10,7 @@ mod cmd;
|
||||
struct Context;
|
||||
|
||||
fn main() {
|
||||
tauri::AppBuilder::<tauri::flavors::Wry, Context>::new()
|
||||
tauri::AppBuilder::<Context>::new()
|
||||
.invoke_handler(|_webview, arg| async move {
|
||||
use cmd::Cmd::*;
|
||||
match serde_json::from_str(&arg) {
|
||||
|
||||
@@ -10,7 +10,7 @@ struct Context;
|
||||
use tauri::WebviewBuilderExt;
|
||||
|
||||
fn main() {
|
||||
tauri::AppBuilder::<tauri::flavors::Wry, Context>::new()
|
||||
tauri::AppBuilder::<Context>::new()
|
||||
.setup(|webview_manager| async move {
|
||||
if webview_manager.current_window_label() == "Main" {
|
||||
webview_manager.listen("clicked", move |_| {
|
||||
|
||||
@@ -13,6 +13,7 @@ pub(crate) mod webview;
|
||||
mod webview_manager;
|
||||
|
||||
pub use crate::api::config::WindowUrl;
|
||||
use crate::flavors::Wry;
|
||||
pub use webview::{
|
||||
wry::WryApplication, ApplicationDispatcherExt, ApplicationExt, Callback, CustomProtocol, Icon,
|
||||
Message, WebviewBuilderExt,
|
||||
@@ -189,7 +190,10 @@ impl<A: ApplicationExt + 'static> WebviewInitializer<A> for Arc<App<A>> {
|
||||
|
||||
/// The App builder.
|
||||
#[derive(Default)]
|
||||
pub struct AppBuilder<A: ApplicationExt, C: AsTauriContext> {
|
||||
pub struct AppBuilder<C: AsTauriContext, A = Wry>
|
||||
where
|
||||
A: ApplicationExt,
|
||||
{
|
||||
/// The JS message handler.
|
||||
invoke_handler: Option<Box<InvokeHandler<A>>>,
|
||||
/// The setup callback, invoked when the webview is ready.
|
||||
@@ -201,7 +205,7 @@ pub struct AppBuilder<A: ApplicationExt, C: AsTauriContext> {
|
||||
webviews: Vec<Webview<A>>,
|
||||
}
|
||||
|
||||
impl<A: ApplicationExt + 'static, C: AsTauriContext> AppBuilder<A, C> {
|
||||
impl<A: ApplicationExt + 'static, C: AsTauriContext> AppBuilder<C, A> {
|
||||
/// Creates a new App builder.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
||||
@@ -4,7 +4,7 @@ use super::{
|
||||
App, ApplicationDispatcherExt, ApplicationExt, Icon, Webview, WebviewBuilderExt,
|
||||
WebviewInitializer,
|
||||
};
|
||||
use crate::{api::config::WindowUrl, async_runtime::Mutex};
|
||||
use crate::{api::config::WindowUrl, async_runtime::Mutex, flavors::Wry};
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -170,7 +170,10 @@ impl<A: ApplicationDispatcherExt> WebviewDispatcher<A> {
|
||||
}
|
||||
|
||||
/// The webview manager.
|
||||
pub struct WebviewManager<A: ApplicationExt> {
|
||||
pub struct WebviewManager<A = Wry>
|
||||
where
|
||||
A: ApplicationExt,
|
||||
{
|
||||
application: Arc<App<A>>,
|
||||
dispatchers: Arc<Mutex<HashMap<String, WebviewDispatcher<A::Dispatcher>>>>,
|
||||
current_webview_window_label: String,
|
||||
|
||||
Reference in New Issue
Block a user