瀏覽代碼

fix(core): rename `ManageBase::app_handle` to avoid naming conflict

Lucas Nogueira 3 年之前
父節點
當前提交
a332b09f43
共有 3 個文件被更改,包括 12 次插入8 次删除
  1. 2 2
      core/tauri/src/app.rs
  2. 8 4
      core/tauri/src/lib.rs
  3. 2 2
      core/tauri/src/window.rs

+ 2 - 2
core/tauri/src/app.rs

@@ -324,7 +324,7 @@ impl<R: Runtime> ManagerBase<R> for AppHandle<R> {
     RuntimeOrDispatch::RuntimeHandle(self.runtime_handle.clone())
   }
 
-  fn app_handle(&self) -> AppHandle<R> {
+  fn managed_app_handle(&self) -> AppHandle<R> {
     self.clone()
   }
 }
@@ -354,7 +354,7 @@ impl<R: Runtime> ManagerBase<R> for App<R> {
     RuntimeOrDispatch::Runtime(self.runtime.as_ref().unwrap())
   }
 
-  fn app_handle(&self) -> AppHandle<R> {
+  fn managed_app_handle(&self) -> AppHandle<R> {
     self.handle()
   }
 }

+ 8 - 4
core/tauri/src/lib.rs

@@ -401,7 +401,7 @@ impl<A: Assets> Context<A> {
 pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
   /// The application handle associated with this manager.
   fn app_handle(&self) -> AppHandle<R> {
-    sealed::ManagerBase::app_handle(self)
+    self.managed_app_handle()
   }
 
   /// The [`Config`] the manager was created with.
@@ -538,7 +538,7 @@ pub(crate) mod sealed {
     fn manager(&self) -> &WindowManager<R>;
 
     fn runtime(&self) -> RuntimeOrDispatch<'_, R>;
-    fn app_handle(&self) -> AppHandle<R>;
+    fn managed_app_handle(&self) -> AppHandle<R>;
 
     /// Creates a new [`Window`] on the [`Runtime`] and attaches it to the [`Manager`].
     fn create_new_window(
@@ -549,13 +549,17 @@ pub(crate) mod sealed {
       let labels = self.manager().labels().into_iter().collect::<Vec<_>>();
       let pending = self
         .manager()
-        .prepare_window(self.app_handle(), pending, &labels)?;
+        .prepare_window(self.managed_app_handle(), pending, &labels)?;
       let window = match self.runtime() {
         RuntimeOrDispatch::Runtime(runtime) => runtime.create_window(pending),
         RuntimeOrDispatch::RuntimeHandle(handle) => handle.create_window(pending),
         RuntimeOrDispatch::Dispatch(mut dispatcher) => dispatcher.create_window(pending),
       }
-      .map(|window| self.manager().attach_window(self.app_handle(), window))?;
+      .map(|window| {
+        self
+          .manager()
+          .attach_window(self.managed_app_handle(), window)
+      })?;
 
       self.manager().emit_filter(
         "tauri://window-created",

+ 2 - 2
core/tauri/src/window.rs

@@ -120,7 +120,7 @@ impl<R: Runtime> ManagerBase<R> for WindowBuilder<R> {
     }
   }
 
-  fn app_handle(&self) -> AppHandle<R> {
+  fn managed_app_handle(&self) -> AppHandle<R> {
     self.app_handle.clone()
   }
 }
@@ -416,7 +416,7 @@ impl<R: Runtime> ManagerBase<R> for Window<R> {
     RuntimeOrDispatch::Dispatch(self.dispatcher())
   }
 
-  fn app_handle(&self) -> AppHandle<R> {
+  fn managed_app_handle(&self) -> AppHandle<R> {
     self.app_handle.clone()
   }
 }