Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
RedDragon0293 committed Jun 6, 2024
1 parent bbd08f3 commit bf406ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
19 changes: 14 additions & 5 deletions src/main/java/cn/reddragon/eportal/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,27 @@ public static void loadConfigs() {
alert.setContentText("配置文件版本过旧! 这可能导致配置加载错误. 由于软件会在退出时保存配置文件, 请考虑在软件退出前备份旧版配置文件.");
alert.showAndWait();
}
for (AbstractConfig config : configs) {
if (config.name.equals(next.getKey())) {
config.fromJson(next.getValue());
logger.info("成功加载配置文件 {}.", config.name);
break;
AbstractConfig config = null;
try {
for (AbstractConfig abstractConfig : configs) {
config = abstractConfig;
if (config.name.equals(next.getKey())) {
config.fromJson(next.getValue());
logger.info("成功加载配置文件 {}.", config.name);
break;
}
}
} catch (Exception e) {
logger.error("加载配置文件 {} 时发生错误!", config.name);
logger.error(e);
}
}
} else {
logger.warn("配置文件损坏!");
}
} catch (FileNotFoundException e) {
logger.error("无法加载配置文件!");
logger.error(e);
throw new RuntimeException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import com.google.gson.JsonObject;

public class AccountConfig extends AbstractConfig {
public static int index;
public static int index = -1;

public AccountConfig() {
super("Account");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import com.google.gson.JsonPrimitive;

public class NetTypeConfig extends AbstractConfig {
public static int index;
public static int index = -1;

public NetTypeConfig() {
super("NetType");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/reddragon/eportal/window/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void start(Stage stage) throws IOException {
box.setValue(box.getItems().get(NetTypeConfig.index));
else
box.setValue("");
if (AccountConfig.index < AccountManager.accounts.size())
if (AccountConfig.index < AccountManager.accounts.size() && AccountConfig.index != -1)
box2.setValue(box2.getItems().get(AccountConfig.index));
/*
TextField name = (TextField) root.lookup("#userNameField");
Expand Down

0 comments on commit bf406ab

Please sign in to comment.