Skip to content

Commit

Permalink
bak
Browse files Browse the repository at this point in the history
  • Loading branch information
TC999 committed Dec 11, 2024
1 parent 03eda95 commit 11d1246
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,43 @@ impl Default for SubscriptionManager {
impl SubscriptionManager {
pub fn show_window(&mut self, ctx: &egui::Context) {
if self.is_open {
let mut start_download = false;

egui::Window::new("订阅规则")
.open(&mut self.is_open)
.show(ctx, |ui| {
self.render_controls(ui);
start_download = self.render_controls(ui);
self.render_subscriptions(ui);
self.render_download_status(ui);
});

// 在 UI 渲染完成后处理状态更新
if self.start_download_request {
if start_download {
self.handle_start_download();
self.start_download_request = false;
}
}
}

fn render_controls(&mut self, ui: &mut egui::Ui) {
fn render_controls(&mut self, ui: &mut egui::Ui) -> bool {
let mut start_download = false;

ui.horizontal(|ui| {
ui.add(
egui::TextEdit::singleline(&mut self.download_url).hint_text("请输入规则下载链接"),
);

if ui.button("下载规则").clicked() || ui.input(|i| i.key_pressed(egui::Key::Enter))
{
self.start_download_request = true;
start_download = true;
}

if ui.button("从文件导入").clicked() {
self.import_from_file();
}
});
ui.separator();

start_download
}

fn render_subscriptions(&mut self, ui: &mut egui::Ui) {
Expand Down

0 comments on commit 11d1246

Please sign in to comment.