From 5b7f6f8ce3841d93d624ae76457c1b5c08f608ed Mon Sep 17 00:00:00 2001 From: wangchunxiang Date: Thu, 11 Dec 2025 17:43:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=B7=BB=E5=8A=A0=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=8A=93=E5=8F=96=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=20-=20=E6=96=B0=E5=A2=9E=20DataCrawlView=20=E7=B1=BB=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E6=95=B0=E6=8D=AE=E6=8A=93=E5=8F=96=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20-=20=E5=AE=9E=E7=8E=B0=E5=B9=B3=E5=8F=B0=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=EF=BC=88=E7=BE=8E=E5=9B=A2=E3=80=81?= =?UTF-8?q?=E5=A4=A7=E4=BC=97=E7=82=B9=E8=AF=84=EF=BC=89=20-=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=97=A5=E6=9C=9F=E9=80=89=E6=8B=A9=E5=99=A8=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E8=AE=BE=E7=BD=AE=E6=8A=93=E5=8F=96=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=20-=20=E5=88=9B=E5=BB=BA=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=8A=93=E5=8F=96=E6=8C=89=E9=92=AE=E5=B9=B6=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E7=82=B9=E5=87=BB=E4=BA=8B=E4=BB=B6=20-=20=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=AA=8C=E8=AF=81=E5=92=8C=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E5=8A=9F=E8=83=BD=20-=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E9=80=89=E6=8B=A9=E9=A1=B5=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BE=8E=E5=9B=A2=E6=95=B0=E6=8D=AE=E6=8A=93?= =?UTF-8?q?=E5=8F=96=E9=80=89=E9=A1=B9=20-=20=E8=B0=83=E6=95=B4=E5=8E=9F?= =?UTF-8?q?=E6=9C=89=E5=B9=B3=E5=8F=B0=E9=80=89=E9=A1=B9=E7=9A=84=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E6=96=87=E5=AD=97=E5=92=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fantaibao/page/DataCrawlView.java | 151 ++++++++++++++++++ .../fantaibao/page/PlatformSelectionView.java | 24 ++- 2 files changed, 161 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/fantaibao/page/DataCrawlView.java diff --git a/src/main/java/com/fantaibao/page/DataCrawlView.java b/src/main/java/com/fantaibao/page/DataCrawlView.java new file mode 100644 index 0000000..3b3d724 --- /dev/null +++ b/src/main/java/com/fantaibao/page/DataCrawlView.java @@ -0,0 +1,151 @@ +package com.fantaibao.page; + +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.*; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import java.time.LocalDate; + +public class DataCrawlView { + + private ComboBox platformComboBox; + private DatePicker startDatePicker; + private DatePicker endDatePicker; + private Button crawlButton; + + public DataCrawlView(Stage primaryStage) { + initialize(primaryStage); + } + + private void initialize(Stage primaryStage) { + // 设置窗口标题 + primaryStage.setTitle("数据抓取配置"); + + // 创建主容器 + VBox root = new VBox(); + root.setAlignment(Pos.CENTER); + root.setSpacing(20); + root.setPadding(new Insets(30)); + root.setStyle("-fx-background-color: #f5f5f5;"); + + // 标题 + Label titleLabel = new Label("数据抓取配置"); + titleLabel.setStyle("-fx-font-size: 24px; -fx-font-weight: bold; -fx-text-fill: #333333;"); + + // 创建表单容器 + GridPane formPane = new GridPane(); + formPane.setAlignment(Pos.CENTER); + formPane.setHgap(15); + formPane.setVgap(20); + formPane.setPadding(new Insets(20)); + formPane.setStyle("-fx-background-color: white; -fx-border-radius: 10px; -fx-background-radius: 10px; " + + "-fx-effect: dropshadow(gaussian, rgba(0,0,0,0.1), 10, 0, 0, 0);"); + + // 平台选择 + Label platformLabel = new Label("选择平台:"); + platformLabel.setStyle("-fx-font-size: 14px; -fx-text-fill: #333333;"); + + platformComboBox = new ComboBox<>(); + platformComboBox.getItems().addAll("美团", "大众点评"); + platformComboBox.setValue("美团"); + platformComboBox.setPrefWidth(200); + platformComboBox.setStyle("-fx-font-size: 14px;"); + + // 开始时间选择 + Label startDateLabel = new Label("开始时间:"); + startDateLabel.setStyle("-fx-font-size: 14px; -fx-text-fill: #333333;"); + + startDatePicker = new DatePicker(); + startDatePicker.setValue(LocalDate.now().minusDays(7)); // 默认一周前 + startDatePicker.setPrefWidth(200); + startDatePicker.setStyle("-fx-font-size: 14px;"); + + // 结束时间选择 + Label endDateLabel = new Label("结束时间:"); + endDateLabel.setStyle("-fx-font-size: 14px; -fx-text-fill: #333333;"); + + endDatePicker = new DatePicker(); + endDatePicker.setValue(LocalDate.now()); // 默认今天 + endDatePicker.setPrefWidth(200); + endDatePicker.setStyle("-fx-font-size: 14px;"); + + // 添加到表单 + formPane.add(platformLabel, 0, 0); + formPane.add(platformComboBox, 1, 0); + formPane.add(startDateLabel, 0, 1); + formPane.add(startDatePicker, 1, 1); + formPane.add(endDateLabel, 0, 2); + formPane.add(endDatePicker, 1, 2); + + // 开始抓取按钮 + crawlButton = new Button("开始抓取"); + crawlButton.setStyle("-fx-background-color: #4CAF50; -fx-text-fill: white; " + + "-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);"); + crawlButton.setCursor(javafx.scene.Cursor.HAND); + crawlButton.setOnMouseEntered(e -> crawlButton.setStyle("-fx-background-color: #45a049; " + + "-fx-text-fill: white; -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);")); + crawlButton.setOnMouseExited(e -> crawlButton.setStyle("-fx-background-color: #4CAF50; " + + "-fx-text-fill: white; -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);")); + + // 为按钮添加点击事件 + crawlButton.setOnAction(e -> handleCrawlAction()); + + // 将组件添加到主容器 + root.getChildren().addAll(titleLabel, formPane, crawlButton); + + // 设置场景并显示窗口 + Scene scene = new Scene(root, 500, 450); + primaryStage.setScene(scene); + primaryStage.show(); + } + + private void handleCrawlAction() { + // 获取选择的平台值 + String selectedPlatform = platformComboBox.getValue(); + int platformValue = 0; // 默认美团 + + if ("大众点评".equals(selectedPlatform)) { + platformValue = 5; + } + + LocalDate startDate = startDatePicker.getValue(); + LocalDate endDate = endDatePicker.getValue(); + + // 验证日期 + if (startDate == null || endDate == null) { + showAlert(Alert.AlertType.WARNING, "警告", "请选择完整的日期范围"); + return; + } + + if (startDate.isAfter(endDate)) { + showAlert(Alert.AlertType.WARNING, "警告", "开始时间不能晚于结束时间"); + return; + } + + // 显示成功提示 + showAlert(Alert.AlertType.INFORMATION, "抓取成功", + "平台: " + selectedPlatform + "\n" + + "平台值: " + platformValue + "\n" + + "开始时间: " + startDate + "\n" + + "结束时间: " + endDate + "\n" + + "数据抓取任务已启动!"); + } + + private void showAlert(Alert.AlertType alertType, String title, String content) { + Alert alert = new Alert(alertType); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(content); + alert.showAndWait(); + } +} \ No newline at end of file diff --git a/src/main/java/com/fantaibao/page/PlatformSelectionView.java b/src/main/java/com/fantaibao/page/PlatformSelectionView.java index 5750356..d268aea 100644 --- a/src/main/java/com/fantaibao/page/PlatformSelectionView.java +++ b/src/main/java/com/fantaibao/page/PlatformSelectionView.java @@ -62,14 +62,14 @@ public class PlatformSelectionView { "#FFD700","ftbCrawlNetFirstMt" ); - // 抖音来客选项 - VBox douyinOption = createPlatformDyOption( - "抖音来客", - GlobalConfig.dyLogo, - "#4A90E2" + // 美团数据抓取选项 + VBox meituanCrawlOption = createPlatformMtCrawlOption( + "美团数据抓取", + GlobalConfig.mtLogo, + "#FF6B35" ); - platformOptions.getChildren().addAll(meituanOption,meituanFirstOption, douyinOption); + platformOptions.getChildren().addAll(meituanOption, meituanFirstOption, meituanCrawlOption); // 添加组件到主容器 root.getChildren().addAll(titleLabel, infoLabel, platformOptions); @@ -110,8 +110,8 @@ public class PlatformSelectionView { return option; } - - private VBox createPlatformDyOption(String title, Image imageUrl, String buttonColor) { + + private VBox createPlatformMtCrawlOption(String title, Image imageUrl, String buttonColor) { VBox option = new VBox(); option.setAlignment(Pos.CENTER); option.setSpacing(10); @@ -125,16 +125,12 @@ public class PlatformSelectionView { Label titleLabel = new Label(title); titleLabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;"); - Button connectButton = new Button("立即连接"); + Button connectButton = new Button("立即进入"); connectButton.setCursor(javafx.scene.Cursor.HAND); connectButton.setStyle("-fx-background-color: " + buttonColor + "; -fx-text-fill: white; -fx-padding: 10px 20px; -fx-border-radius: 4px;"); connectButton.setOnAction(event -> { - FtbCrawlNetBase ftbCrawlNetMt = SpringContext.getBean("ftbCrawlNetDy"); - ThreadPoolTaskExecutor poolTaskExecutor = SpringContext.getBean(ThreadPoolTaskExecutor.class); - poolTaskExecutor.execute(() -> { - ftbCrawlNetMt.executeCookieIntercept(); - }); + new DataCrawlView(primaryStage); }); option.getChildren().addAll(imageView, titleLabel, connectButton);