feat(platform): 添加平台选择页面的用户信息显示和退出登录功能

- 添加 Priority 导入以支持布局权重分配
- 重构顶部区域布局,创建 HBox 容器分离标题和用户信息区域
- 添加租户名称显示功能,显示当前登录租户信息
- 实现退出登录按钮及其样式设置
- 添加退出登录事件处理逻辑,清空全局配置信息
- 实现退出登录后跳转到登录页面功能
- 调整平台选项容器的内边距和间距设置
This commit is contained in:
2025-12-29 15:38:13 +08:00
parent bbec32c78c
commit 6606e798b2

View File

@@ -12,6 +12,7 @@ import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@@ -29,21 +30,45 @@ public class PlatformSelectionView {
// 设置窗口标题
primaryStage.setTitle("中差评采集工具");
// 容器
VBox root = new VBox();
root.setAlignment(Pos.CENTER);
root.setSpacing(30);
root.setPadding(new Insets(40));
// 标题
// 顶部区域容器
HBox topContainer = new HBox();
topContainer.setPadding(new Insets(10, 20, 10, 20));
// 左侧标题
VBox titleContainer = new VBox();
Label titleLabel = new Label("请选择采集平台");
titleLabel.setStyle("-fx-font-size: 20px; -fx-font-weight: bold;");
// 描述信息
Label infoLabel = new Label("连接您的电商平台,智能化采集中差评数据");
infoLabel.setStyle("-fx-font-size: 14px; -fx-padding: 0 0 10 0;");
infoLabel.setStyle("-fx-font-size: 14px; -fx-padding: 5 0 0 0;");
titleContainer.getChildren().addAll(titleLabel, infoLabel);
HBox.setHgrow(titleContainer, Priority.ALWAYS);
// 右侧用户信息区域
HBox userInfoContainer = new HBox();
userInfoContainer.setAlignment(Pos.CENTER_RIGHT);
userInfoContainer.setSpacing(10);
// 显示租户名称
Label tenantNameLabel = new Label("当前租户: " + (GlobalConfig.tenantName != null ? GlobalConfig.tenantName : "未登录"));
tenantNameLabel.setStyle("-fx-font-size: 14px; -fx-text-fill: #333; -fx-font-weight: bold;");
// 退出登录按钮
Button logoutButton = new Button("退出登录");
logoutButton.setStyle("-fx-background-color: #f44336; -fx-text-fill: white; -fx-border-radius: 4px; -fx-background-radius: 4px;");
logoutButton.setCursor(javafx.scene.Cursor.HAND);
userInfoContainer.getChildren().addAll(tenantNameLabel, logoutButton);
topContainer.getChildren().addAll(titleContainer, userInfoContainer);
// 平台选项容器
VBox platformOptionsContainer = new VBox();
platformOptionsContainer.setAlignment(Pos.CENTER);
platformOptionsContainer.setSpacing(30);
platformOptionsContainer.setPadding(new Insets(20, 40, 40, 40));
HBox platformOptions = new HBox();
platformOptions.setAlignment(Pos.CENTER);
platformOptions.setSpacing(60);
@@ -70,14 +95,32 @@ public class PlatformSelectionView {
);
platformOptions.getChildren().addAll(meituanOption, meituanFirstOption, meituanCrawlOption);
platformOptionsContainer.getChildren().addAll(platformOptions);
// 添加组件到主容器
root.getChildren().addAll(titleLabel, infoLabel, platformOptions);
// 主容器
VBox root = new VBox();
root.getChildren().addAll(topContainer, platformOptionsContainer);
// 设置场景并显示窗口
Scene scene = new Scene(root, 800, 600);
primaryStage.setScene(scene);
primaryStage.show();
// 退出登录按钮事件处理
logoutButton.setOnAction(event -> {
// 清空租户信息和相关配置
GlobalConfig.tenantId = null;
GlobalConfig.tenantName = null;
GlobalConfig.mtShopListInterfaceAddress = null;
GlobalConfig.mtDianPingInterfaceAddress = null;
GlobalConfig.mtDaZhInterfaceAddress = null;
GlobalConfig.dyPingJiaInterfaceAddress = null;
GlobalConfig.mtLoginPage = null;
GlobalConfig.dyLoginPage = null;
// 返回登录页面
new LoginView(primaryStage);
});
}
private VBox createPlatformMtOption(String title, Image imageUrl, String buttonColor,String beanName) {