浏览代码

Doc fixes, running examples instructions, change menubar behavior for desktop

Jonathan Kelley 1 年之前
父节点
当前提交
329c323b35
共有 3 个文件被更改,包括 29 次插入17 次删除
  1. 4 0
      README.md
  2. 1 1
      packages/desktop/src/app.rs
  3. 24 16
      packages/desktop/src/menubar.rs

+ 4 - 0
README.md

@@ -219,6 +219,10 @@ Dioxus has grown from a side project to a small team of fulltime engineers. Than
   </table>
 </div>
 
+## Running the examples
+
+The examples in the top level of this repository can be run with `cargo run --example <example>`. However, we encourage you to download the dioxus-cli and run the examples with `dx serve` since many examples also support web. When running for web, you either need to modify the Cargo.toml to disable the default desktop feature, or use
+
 ## Dioxus vs other frameworks
 
 We love all frameworks and enjoy watching innovation in the Rust ecosystem. In fact, many of our projects are shared with other frameworks. For example, our flex-box library [Taffy](https://github.com/DioxusLabs/taffy) is used by [Bevy](https://bevyengine.org/), [Zed](https://zed.dev/), [Lapce](https://lapce.dev/), [Iced](https://github.com/iced-rs/iced),  and many more.

+ 1 - 1
packages/desktop/src/app.rs

@@ -63,7 +63,7 @@ impl App {
             webviews: HashMap::new(),
             control_flow: ControlFlow::Wait,
             unmounted_dom: Cell::new(Some(virtual_dom)),
-            float_all: cfg!(debug_assertions),
+            float_all: !cfg!(debug_assertions),
             cfg: Cell::new(Some(cfg)),
             shared: Rc::new(SharedContext {
                 event_handlers: WindowEventHandlers::default(),

+ 24 - 16
packages/desktop/src/menubar.rs

@@ -88,28 +88,36 @@ mod desktop_platforms {
             ])
             .unwrap();
 
-        let help_menu = Submenu::new("Help", true);
-        help_menu
-            .append_items(&[&MenuItem::new("Toggle Developer Tools", true, None)])
-            .unwrap();
+        menu.append_items(&[&window_menu, &edit_menu]).unwrap();
 
-        // By default we float the window on top in dev mode, but let the user disable it
-        help_menu
-            .append_items(&[&MenuItem::with_id(
-                "dioxus-float-top",
-                "Float on Top (dev mode only)",
-                true,
-                None,
-            )])
-            .unwrap();
+        if cfg!(debug_assertions) {
+            let help_menu = Submenu::new("Help", true);
 
-        menu.append_items(&[&window_menu, &edit_menu, &help_menu])
-            .unwrap();
+            help_menu
+                .append_items(&[&MenuItem::new("Toggle Developer Tools", true, None)])
+                .unwrap();
+
+            // By default we float the window on top in dev mode, but let the user disable it
+            help_menu
+                .append_items(&[&MenuItem::with_id(
+                    "dioxus-float-top",
+                    "Float on Top (dev mode only)",
+                    true,
+                    None,
+                )])
+                .unwrap();
+
+            _ = menu.append_items(&[&help_menu]);
+
+            #[cfg(target_os = "macos")]
+            {
+                help_menu.set_as_help_menu_for_nsapp();
+            }
+        }
 
         #[cfg(target_os = "macos")]
         {
             window_menu.set_as_windows_menu_for_nsapp();
-            help_menu.set_as_help_menu_for_nsapp();
         }
 
         menu