From e01656faa911044e072826d79b63e3e419d05acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=94=9F=E6=9D=82=E7=89=A9=E6=88=BF?= <88823709+TC999@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:04:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/subscription.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/subscription.rs b/src/subscription.rs index 69dcf09..8316601 100644 --- a/src/subscription.rs +++ b/src/subscription.rs @@ -25,13 +25,13 @@ impl Default for SubscriptionManager { impl SubscriptionManager { pub fn show_window(&mut self, ctx: &egui::Context) { - if self.is_open { - // 获取 mutable reference to the ui + let mut is_open = self.is_open; + if is_open { egui::Window::new("订阅规则") - .open(&mut self.is_open) + .open(&mut is_open) .show(ctx, |ui| { - // 调用 render_controls 方法时传入 ui 参数 - let start_download = self.render_controls(ui); + // 直接在闭包内部渲染控件 + let start_download = self.render_controls(ui); // 传递 ui self.render_subscriptions(ui); self.render_download_status(ui); @@ -41,6 +41,7 @@ impl SubscriptionManager { } }); } + self.is_open = is_open; } fn render_controls(&mut self, ui: &mut egui::Ui) -> bool {