feat(爬虫桌面): 添加登录界面和平台选择界面
新增了基于JavaFX的登录界面和平台选择界面,支持管理员账号登录及 平台切换功能。 - 在 `.gitignore` 中添加忽略 `.idea` 目录 - 引入 `LoginView` 页面作为应用启动入口- 实现基础的账号密码输入与登录按钮交互逻辑 - 创建平台选择页面 `PlatformSelectionView`,展示美团开店宝和抖音来客选项- 更新模块配置文件 `module-info.java` 导出新增的服务和页面包路径
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,7 +1,7 @@
|
|||||||
# ---> Java
|
# ---> Java
|
||||||
# Compiled class file
|
# Compiled class file
|
||||||
*.class
|
*.class
|
||||||
|
.idea
|
||||||
# Log file
|
# Log file
|
||||||
*.log
|
*.log
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.fantaibao;
|
package com.fantaibao;
|
||||||
|
|
||||||
|
import com.fantaibao.page.LoginView;
|
||||||
import com.fantaibao.service.PlaywrightService;
|
import com.fantaibao.service.PlaywrightService;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@@ -37,6 +38,10 @@ public class DesktopApplication extends Application {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
|
// 直接启动登录界面
|
||||||
|
new LoginView(primaryStage);
|
||||||
|
|
||||||
|
/*
|
||||||
primaryStage.setTitle("饭太煲爬虫桌面程序");
|
primaryStage.setTitle("饭太煲爬虫桌面程序");
|
||||||
|
|
||||||
textArea = new TextArea();
|
textArea = new TextArea();
|
||||||
@@ -62,6 +67,7 @@ public class DesktopApplication extends Application {
|
|||||||
Platform.exit();
|
Platform.exit();
|
||||||
});
|
});
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void runPlaywrightCookieExample() {
|
private void runPlaywrightCookieExample() {
|
||||||
|
|||||||
74
src/main/java/com/fantaibao/page/LoginView.java
Normal file
74
src/main/java/com/fantaibao/page/LoginView.java
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
package com.fantaibao.page;
|
||||||
|
|
||||||
|
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.control.PasswordField;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
|
||||||
|
public class LoginView {
|
||||||
|
|
||||||
|
private Stage primaryStage;
|
||||||
|
|
||||||
|
public LoginView(Stage primaryStage) {
|
||||||
|
this.primaryStage = primaryStage;
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize() {
|
||||||
|
// 设置窗口标题
|
||||||
|
primaryStage.setTitle("数据采集智能解决方案");
|
||||||
|
|
||||||
|
// 创建主容器
|
||||||
|
VBox root = new VBox();
|
||||||
|
root.setAlignment(Pos.CENTER);
|
||||||
|
root.setSpacing(10);
|
||||||
|
root.setPadding(new Insets(20));
|
||||||
|
|
||||||
|
// 标题
|
||||||
|
Label titleLabel = new Label("账号登录");
|
||||||
|
titleLabel.setStyle("-fx-font-size: 18px; -fx-font-weight: bold;");
|
||||||
|
|
||||||
|
// 提示信息
|
||||||
|
Label infoLabel = new Label("请输入您的账户信息");
|
||||||
|
infoLabel.setStyle("-fx-font-size: 14px;");
|
||||||
|
|
||||||
|
// 账号输入框
|
||||||
|
TextField accountField = new TextField();
|
||||||
|
accountField.setPromptText("请输入管理员账号");
|
||||||
|
accountField.setPrefWidth(300);
|
||||||
|
|
||||||
|
// 密码输入框
|
||||||
|
PasswordField passwordField = new PasswordField();
|
||||||
|
passwordField.setPrefWidth(300);
|
||||||
|
|
||||||
|
// 登录按钮
|
||||||
|
Button loginButton = new Button("登 录");
|
||||||
|
loginButton.setStyle("-fx-background-color: #3f51b5; -fx-text-fill: white;");
|
||||||
|
loginButton.setPrefWidth(300);
|
||||||
|
|
||||||
|
// 添加登录按钮事件处理
|
||||||
|
loginButton.setOnAction(e -> {
|
||||||
|
// 这里可以添加实际的登录验证逻辑
|
||||||
|
// 当前简化处理,直接跳转到平台选择页面
|
||||||
|
navigateToPlatformSelection();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 添加组件到主容器
|
||||||
|
root.getChildren().addAll(titleLabel, infoLabel, new Label("账号"), accountField,
|
||||||
|
new Label("密码"), passwordField, loginButton);
|
||||||
|
|
||||||
|
// 设置场景并显示窗口
|
||||||
|
Scene scene = new Scene(root, 400, 600);
|
||||||
|
primaryStage.setScene(scene);
|
||||||
|
primaryStage.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToPlatformSelection() {
|
||||||
|
new PlatformSelectionView(primaryStage);
|
||||||
|
}
|
||||||
|
}
|
||||||
97
src/main/java/com/fantaibao/page/PlatformSelectionView.java
Normal file
97
src/main/java/com/fantaibao/page/PlatformSelectionView.java
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
package com.fantaibao.page;
|
||||||
|
|
||||||
|
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 = createPlatformOption(
|
||||||
|
"美团开店宝",
|
||||||
|
"https://placehold.co/64x64?text=MT&bg=FFD700&fg=333",
|
||||||
|
"采集店铺数据、获取商品信息",
|
||||||
|
"#FFD700"
|
||||||
|
);
|
||||||
|
|
||||||
|
// 抖音来客选项
|
||||||
|
VBox douyinOption = createPlatformOption(
|
||||||
|
"抖音来客",
|
||||||
|
"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 createPlatformOption(String title, String imageUrl, String description, 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;");
|
||||||
|
|
||||||
|
Label descLabel = new Label(description);
|
||||||
|
descLabel.setStyle("-fx-font-size: 12px;");
|
||||||
|
|
||||||
|
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, descLabel, connectButton);
|
||||||
|
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,4 +13,7 @@ module fantaibao.crawler.desktop {
|
|||||||
javafx.fxml, javafx.base, javafx.graphics, spring.boot, spring.boot.autoconfigure;
|
javafx.fxml, javafx.base, javafx.graphics, spring.boot, spring.boot.autoconfigure;
|
||||||
|
|
||||||
exports com.fantaibao;
|
exports com.fantaibao;
|
||||||
|
exports com.fantaibao.service;
|
||||||
|
exports com.fantaibao.page;
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user