feat(ui): 添加返回按钮并优化界面布局

- 在数据抓取页面添加返回按钮
- 实现返回上一场景的功能
- 重新组织按钮区域布局
- 优化按钮样式和交互效果
- 调整主容器组件排列顺序
- 增加平台选择页面的代码结构调整
This commit is contained in:
2025-12-11 17:47:45 +08:00
parent 5b7f6f8ce3
commit ad3380c979

View File

@@ -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);