ソースを参照

fix: format code

mrxiaozhuox 3 年 前
コミット
e4eb982a36
2 ファイル変更10 行追加18 行削除
  1. 4 10
      examples/borderless.rs
  2. 6 8
      packages/desktop/src/desktop_context.rs

+ 4 - 10
examples/borderless.rs

@@ -1,4 +1,4 @@
-use dioxus::{events::onmousedown, prelude::*};
+use dioxus::prelude::*;
 use dioxus_desktop::desktop_context::DesktopContext;
 
 fn main() {
@@ -12,11 +12,10 @@ fn app(cx: Scope) -> Element {
 
     let drag = desktop.clone();
     let close = desktop.clone();
-    let min = desktop.clone();
 
     cx.render(rsx!(
         link { href:"https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css", rel:"stylesheet" }
-        header { 
+        header {
             class: "text-gray-400 bg-gray-900 body-font",
             onmousedown: move |_| drag.drag_window(),
             div {
@@ -24,16 +23,11 @@ fn app(cx: Scope) -> Element {
                 a { class: "flex title-font font-medium items-center text-white mb-4 md:mb-0",
                     span { class: "ml-3 text-xl", "Dioxus"}
                 }
-                nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center",
-                //     a { class: "mr-5 hover:text-white", "First Link"}
-                //     a { class: "mr-5 hover:text-white", "Second Link"}
-                //     a { class: "mr-5 hover:text-white", "Third Link"}
-                //     a { class: "mr-5 hover:text-white", "Fourth Link"}
-                }
+                nav { class: "md:ml-auto flex flex-wrap items-center text-base justify-center" }
                 button {
                     class: "inline-flex items-center bg-gray-800 border-0 py-1 px-3 focus:outline-none hover:bg-gray-700 rounded text-base mt-4 md:mt-0",
                     onmousedown: |evt| evt.cancel_bubble(),
-                    onclick: move |_| min.minimize(true),
+                    onclick: move |_| desktop.minimize(true),
                     "Minimize"
                 }
                 button {

+ 6 - 8
packages/desktop/src/desktop_context.rs

@@ -5,11 +5,11 @@ use crate::UserWindowEvent;
 type ProxyType = EventLoopProxy<UserWindowEvent>;
 
 /// Desktop-Window handle api context
-/// 
+///
 /// you can use this context control some window event
-/// 
+///
 /// you can use `cx.consume_context::<DesktopContext>` to get this context
-/// 
+///
 /// ```rust
 ///     let desktop = cx.consume_context::<DesktopContext>().unwrap();
 /// ```
@@ -19,15 +19,14 @@ pub struct DesktopContext {
 }
 
 impl DesktopContext {
-
     pub(crate) fn new(proxy: ProxyType) -> Self {
         Self { proxy }
     }
 
     /// trigger the drag-window event
-    /// 
+    ///
     /// Moves the window with the left mouse button until the button is released.
-    /// 
+    ///
     /// you need use it in `onmousedown` event:
     /// ```rust
     /// onmousedown: move |_| { desktop.drag_window(); }
@@ -50,5 +49,4 @@ impl DesktopContext {
     pub fn close(&self) {
         let _ = self.proxy.send_event(UserWindowEvent::CloseWindow);
     }
-
-}
+}