You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Dioxus桌面应用中的Window、Edit、Help菜单栏按钮?

Dioxus桌面应用移除顶部系统菜单栏(Window/Edit/Help)解决方案

你设置with_decorations(false)后仍能看到顶部的Window、Edit、Help菜单栏,是因为这个配置仅隐藏窗口的边框和标题栏,不会自动清除系统默认的菜单栏。要移除这些菜单,需要单独通过窗口API手动设置。

解决步骤

修改你的启动代码,添加with_window_setup闭包来清除默认菜单栏:

use dioxus::prelude::*;
use tracing::Level;
use dioxus_desktop::Config;
use dioxus_desktop::tao::dpi::LogicalSize;
use dioxus_desktop::tao::window::WindowBuilder;

fn main() {
    // Init logger
    dioxus_logger::init(Level::INFO).expect("failed to init logger");

    // Create the WindowBuilder that app launches with
    let window = WindowBuilder::new()
        .with_title("Dioxus App")
        .with_inner_size(LogicalSize::new(518.0, 864.0)) // Set the window size to RPI screen ratio
        .with_decorations(false); // make window borderless

    // Create the Config with the custom window builder
    let cfg = Config::new()
        .with_custom_head(r#"<link rel="stylesheet" href="tailwind.css">"#.to_string())
        .with_window(window)
        .with_window_setup(|window, _app_handle| {
            // 移除默认系统菜单栏
            window.set_menu_bar(None);
        });

    // Launch app from cfg
    LaunchBuilder::desktop().with_cfg(cfg).launch(App);
}

原理说明

  • with_decorations(false)的作用范围仅限窗口装饰(边框、标题栏等),系统默认菜单栏是独立的组件,不受该配置影响。
  • 通过with_window_setup闭包可以获取到窗口实例,调用set_menu_bar(None)会直接清除默认的系统菜单栏,在Windows、macOS等平台均生效。

内容的提问来源于stack exchange,提问作者Theta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 19:57:04