diff --git a/src/main/java/com/fantaibao/page/DataCrawlView.java b/src/main/java/com/fantaibao/page/DataCrawlView.java index 3b3d724..8aafcbd 100644 --- a/src/main/java/com/fantaibao/page/DataCrawlView.java +++ b/src/main/java/com/fantaibao/page/DataCrawlView.java @@ -16,8 +16,12 @@ public class DataCrawlView { private DatePicker startDatePicker; private DatePicker endDatePicker; private Button crawlButton; + private Stage primaryStage; + private Scene previousScene; public DataCrawlView(Stage primaryStage) { + this.primaryStage = primaryStage; + this.previousScene = primaryStage.getScene(); initialize(primaryStage); } @@ -81,6 +85,28 @@ public class DataCrawlView { formPane.add(endDateLabel, 0, 2); formPane.add(endDatePicker, 1, 2); + // 按钮区域 + HBox buttonBox = new HBox(); + buttonBox.setAlignment(Pos.CENTER); + buttonBox.setSpacing(20); + + // 返回按钮 + Button backButton = new Button("返回"); + backButton.setStyle("-fx-background-color: #cccccc; -fx-text-fill: #333333; " + + "-fx-font-size: 16px; -fx-font-weight: bold; -fx-padding: 12px 36px; " + + "-fx-border-radius: 30px; -fx-background-radius: 30px; " + + "-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.2), 10, 0, 0, 0);"); + backButton.setCursor(javafx.scene.Cursor.HAND); + backButton.setOnMouseEntered(e -> backButton.setStyle("-fx-background-color: #bbbbbb; " + + "-fx-text-fill: #333333; -fx-font-size: 16px; -fx-font-weight: bold; " + + "-fx-padding: 12px 36px; -fx-border-radius: 30px; -fx-background-radius: 30px; " + + "-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.3), 15, 0, 0, 0);")); + backButton.setOnMouseExited(e -> backButton.setStyle("-fx-background-color: #cccccc; " + + "-fx-text-fill: #333333; -fx-font-size: 16px; -fx-font-weight: bold; " + + "-fx-padding: 12px 36px; -fx-border-radius: 30px; -fx-background-radius: 30px; " + + "-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.2), 10, 0, 0, 0);")); + backButton.setOnAction(e -> handleBackAction()); + // 开始抓取按钮 crawlButton = new Button("开始抓取"); crawlButton.setStyle("-fx-background-color: #4CAF50; -fx-text-fill: white; " + @@ -100,8 +126,11 @@ public class DataCrawlView { // 为按钮添加点击事件 crawlButton.setOnAction(e -> handleCrawlAction()); + // 添加按钮到按钮区域 + buttonBox.getChildren().addAll(backButton, crawlButton); + // 将组件添加到主容器 - root.getChildren().addAll(titleLabel, formPane, crawlButton); + root.getChildren().addAll(titleLabel, formPane, buttonBox); // 设置场景并显示窗口 Scene scene = new Scene(root, 500, 450); @@ -141,6 +170,14 @@ public class DataCrawlView { "数据抓取任务已启动!"); } + private void handleBackAction() { + if (previousScene != null) { + primaryStage.setScene(previousScene); + } else { + new PlatformSelectionView(primaryStage); + } + } + private void showAlert(Alert.AlertType alertType, String title, String content) { Alert alert = new Alert(alertType); alert.setTitle(title);