[Feature] [UI] 统一账户选择弹窗在列表为空时的表现 (#5054)

This commit is contained in:
mineDiamond
2025-12-23 21:52:43 +08:00
committed by GitHub
parent 2af3c8f714
commit fcabe9ca36
4 changed files with 18 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ package org.jackhuang.hmcl.ui.main;
import com.jfoenix.controls.JFXPopup; import com.jfoenix.controls.JFXPopup;
import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.scene.control.Label;
import javafx.scene.input.MouseButton; import javafx.scene.input.MouseButton;
import org.jackhuang.hmcl.Metadata; import org.jackhuang.hmcl.Metadata;
import org.jackhuang.hmcl.auth.Account; import org.jackhuang.hmcl.auth.Account;
@@ -149,7 +150,6 @@ public class RootPage extends DecoratorAnimatedPage implements DecoratorPage {
accountListItem.setOnAction(e -> Controllers.navigate(Controllers.getAccountListPage())); accountListItem.setOnAction(e -> Controllers.navigate(Controllers.getAccountListPage()));
accountListItem.setOnMouseClicked(e -> { accountListItem.setOnMouseClicked(e -> {
if (e.getButton() == MouseButton.SECONDARY) { if (e.getButton() == MouseButton.SECONDARY) {
if (!Accounts.getAccounts().isEmpty())
showAccountListPopupMenu(accountListItem); showAccountListPopupMenu(accountListItem);
e.consume(); e.consume();
} }
@@ -265,6 +265,11 @@ public class RootPage extends DecoratorAnimatedPage implements DecoratorPage {
scrollPane.setPrefHeight(-1); scrollPane.setPrefHeight(-1);
scrollPane.setMaxHeight(260); scrollPane.setMaxHeight(260);
if (Accounts.getAccounts().isEmpty()) {
Label placeholder = new Label(i18n("account.empty"));
placeholder.setStyle("-fx-padding: 10px; -fx-text-fill: gray; -fx-font-style: italic;");
scrollPane.add(placeholder);
} else {
for (Account account : Accounts.getAccounts()) { for (Account account : Accounts.getAccounts()) {
AccountAdvancedListItem item = new AccountAdvancedListItem(account); AccountAdvancedListItem item = new AccountAdvancedListItem(account);
item.setOnAction(e -> { item.setOnAction(e -> {
@@ -273,6 +278,7 @@ public class RootPage extends DecoratorAnimatedPage implements DecoratorPage {
}); });
scrollPane.add(item); scrollPane.add(item);
} }
}
popupMenu.getContent().add(scrollPane); popupMenu.getContent().add(scrollPane);
popup.show(accountListItem, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, accountListItem.getWidth(), 0); popup.show(accountListItem, JFXPopup.PopupVPosition.TOP, JFXPopup.PopupHPosition.LEFT, accountListItem.getWidth(), 0);

View File

@@ -60,6 +60,7 @@ account.create.microsoft=Add a Microsoft Account
account.create.offline=Add an Offline Account account.create.offline=Add an Offline Account
account.create.authlibInjector=Add an authlib-injector Account account.create.authlibInjector=Add an authlib-injector Account
account.email=Email account.email=Email
account.empty=No Accounts
account.failed=Failed to refresh account. account.failed=Failed to refresh account.
account.failed.character_deleted=The player has already been deleted. account.failed.character_deleted=The player has already been deleted.
account.failed.connect_authentication_server=Failed to connect to the authentication server, your network connection may be down. account.failed.connect_authentication_server=Failed to connect to the authentication server, your network connection may be down.

View File

@@ -59,6 +59,7 @@ account.create.microsoft=新增 Microsoft 帳戶
account.create.offline=新增離線模式帳戶 account.create.offline=新增離線模式帳戶
account.create.authlibInjector=新增 authlib-injector 帳戶 account.create.authlibInjector=新增 authlib-injector 帳戶
account.email=電子信箱 account.email=電子信箱
account.empty=沒有帳戶
account.failed=帳戶重新整理失敗 account.failed=帳戶重新整理失敗
account.failed.character_deleted=已刪除此角色 account.failed.character_deleted=已刪除此角色
account.failed.connect_authentication_server=無法連線至認證伺服器。可能是網路問題,請檢查裝置能否正常上網或使用代理服務。 account.failed.connect_authentication_server=無法連線至認證伺服器。可能是網路問題,請檢查裝置能否正常上網或使用代理服務。

View File

@@ -59,6 +59,7 @@ account.create.microsoft=添加微软账户
account.create.offline=添加离线模式账户 account.create.offline=添加离线模式账户
account.create.authlibInjector=添加外置登录账户 (authlib-injector) account.create.authlibInjector=添加外置登录账户 (authlib-injector)
account.email=邮箱 account.email=邮箱
account.empty=没有账户
account.failed=账户刷新失败 account.failed=账户刷新失败
account.failed.character_deleted=此角色已被删除 account.failed.character_deleted=此角色已被删除
account.failed.connect_authentication_server=无法连接认证服务器。可能是网络问题,请检查设备能否正常上网或使用代理服务。\n你可以点击右上角帮助按钮进行求助。 account.failed.connect_authentication_server=无法连接认证服务器。可能是网络问题,请检查设备能否正常上网或使用代理服务。\n你可以点击右上角帮助按钮进行求助。