feat(playwright): 添加浏览器配置类并集成Playwright 新增BrowserConfig配置类,用于创建和管理Playwright实例。 移除DesktopApplication中冗余的UI示例代码和旧版PlaywrightService。 添加FtbCrawlNetBase接口及其实现类FtbCrawlNetMt,用于执行Cookie拦截逻辑。更新PlatformSelectionView以支持美团平台的连接功能,并通过SpringContext获取爬虫服务。 调整module-info.java以开放和导出新增模块包路径,确保Spring能够正确注入依赖。 ```
124 lines
4.1 KiB
Java
124 lines
4.1 KiB
Java
package com.fantaibao.page;
|
|
|
|
import com.fantaibao.base.FtbCrawlNetBase;
|
|
import com.fantaibao.config.SpringContext;
|
|
import javafx.geometry.Insets;
|
|
import javafx.geometry.Pos;
|
|
import javafx.scene.Scene;
|
|
import javafx.scene.control.Button;
|
|
import javafx.scene.control.Label;
|
|
import javafx.scene.image.Image;
|
|
import javafx.scene.image.ImageView;
|
|
import javafx.scene.layout.HBox;
|
|
import javafx.scene.layout.VBox;
|
|
import javafx.stage.Stage;
|
|
|
|
public class PlatformSelectionView {
|
|
|
|
private Stage primaryStage;
|
|
|
|
public PlatformSelectionView(Stage primaryStage) {
|
|
this.primaryStage = primaryStage;
|
|
initialize();
|
|
}
|
|
|
|
private void initialize() {
|
|
// 设置窗口标题
|
|
primaryStage.setTitle("中差评采集工具");
|
|
|
|
// 主容器
|
|
VBox root = new VBox();
|
|
root.setAlignment(Pos.CENTER);
|
|
root.setSpacing(20);
|
|
root.setPadding(new Insets(40));
|
|
|
|
// 标题
|
|
Label titleLabel = new Label("请选择爬虫平台");
|
|
titleLabel.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
|
|
|
|
// 描述信息
|
|
Label infoLabel = new Label("连接您的电商平台,智能化采集中差评数据");
|
|
infoLabel.setStyle("-fx-font-size: 14px;");
|
|
|
|
// 平台选项容器
|
|
HBox platformOptions = new HBox();
|
|
platformOptions.setAlignment(Pos.CENTER);
|
|
platformOptions.setSpacing(20);
|
|
|
|
// 美团开店宝选项
|
|
VBox meituanOption = createPlatformMtOption(
|
|
"美团开店宝",
|
|
"https://placehold.co/64x64?text=MT&bg=FFD700&fg=333",
|
|
"#FFD700"
|
|
);
|
|
|
|
// 抖音来客选项
|
|
VBox douyinOption = createPlatformDyOption(
|
|
"抖音来客",
|
|
"https://placehold.co/64x64?text=DY&bg=4A90E2&fg=FFF",
|
|
"#4A90E2"
|
|
);
|
|
|
|
platformOptions.getChildren().addAll(meituanOption, douyinOption);
|
|
|
|
// 添加组件到主容器
|
|
root.getChildren().addAll(titleLabel, infoLabel, platformOptions);
|
|
|
|
// 设置场景并显示窗口
|
|
Scene scene = new Scene(root, 800, 600);
|
|
primaryStage.setScene(scene);
|
|
primaryStage.show();
|
|
}
|
|
|
|
private VBox createPlatformMtOption(String title, String imageUrl, String buttonColor) {
|
|
VBox option = new VBox();
|
|
option.setAlignment(Pos.CENTER);
|
|
option.setSpacing(10);
|
|
option.setPadding(new Insets(20));
|
|
option.setStyle("-fx-background-color: white; -fx-border-radius: 8px; -fx-padding: 20px;");
|
|
|
|
ImageView imageView = new ImageView(new Image(imageUrl));
|
|
imageView.setFitWidth(64);
|
|
imageView.setFitHeight(64);
|
|
|
|
Label titleLabel = new Label(title);
|
|
titleLabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
|
|
|
|
|
|
Button connectButton = new Button("立即连接");
|
|
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("ftbCrawlNetMt");
|
|
ftbCrawlNetMt.executeCookieIntercept();
|
|
|
|
});
|
|
|
|
option.getChildren().addAll(imageView, titleLabel, connectButton);
|
|
|
|
return option;
|
|
}
|
|
|
|
private VBox createPlatformDyOption(String title, String imageUrl, String buttonColor) {
|
|
VBox option = new VBox();
|
|
option.setAlignment(Pos.CENTER);
|
|
option.setSpacing(10);
|
|
option.setPadding(new Insets(20));
|
|
option.setStyle("-fx-background-color: white; -fx-border-radius: 8px; -fx-padding: 20px;");
|
|
|
|
ImageView imageView = new ImageView(new Image(imageUrl));
|
|
imageView.setFitWidth(64);
|
|
imageView.setFitHeight(64);
|
|
|
|
Label titleLabel = new Label(title);
|
|
titleLabel.setStyle("-fx-font-size: 16px; -fx-font-weight: bold;");
|
|
|
|
Button connectButton = new Button("立即连接");
|
|
connectButton.setStyle("-fx-background-color: " + buttonColor + "; -fx-text-fill: white; -fx-padding: 10px 20px; -fx-border-radius: 4px;");
|
|
|
|
option.getChildren().addAll(imageView, titleLabel, connectButton);
|
|
|
|
return option;
|
|
}
|
|
|
|
} |