-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
336 additions
and
121 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,14 @@ | ||
package cn.reddragon.eportal; | ||
|
||
import cn.reddragon.eportal.config.ConfigManager; | ||
import cn.reddragon.eportal.utils.Authenticator; | ||
import cn.reddragon.eportal.window.MainWindow; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public class Main { | ||
public static Logger logger = LogManager.getLogger("EPortal"); | ||
|
||
public static void main(String[] args) { | ||
Thread.currentThread().setName("EPortal Main"); | ||
EPortal.askThread.setDaemon(true); | ||
Authenticator.checkOnline(); | ||
try { | ||
if (Authenticator.online) { | ||
Authenticator.updateUserIndex(); | ||
} | ||
} catch (NullPointerException e) { | ||
EPortal.logger.error("启动时出错!", e); | ||
System.exit(0); | ||
} | ||
EPortal.launch(); | ||
ConfigManager.saveConfigs(); | ||
MainWindow.main(args); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
package cn.reddragon.eportal.account; | ||
|
||
public final class Account { | ||
private final String name; | ||
private final String password; | ||
|
||
public Account(String name, String password) { | ||
this.name = name; | ||
this.password = password; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
public record Account(String name, String password) { | ||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (!(obj instanceof Account a)) | ||
return false; | ||
return name.equals(a.name); | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 4 additions & 8 deletions
12
src/main/java/cn/reddragon/eportal/config/configs/NetTypeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,24 @@ | ||
package cn.reddragon.eportal.config.configs; | ||
|
||
import cn.reddragon.eportal.EPortal; | ||
import cn.reddragon.eportal.config.AbstractConfig; | ||
import cn.reddragon.eportal.window.MainWindow; | ||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonPrimitive; | ||
import javafx.scene.control.ChoiceBox; | ||
|
||
public class NetTypeConfig extends AbstractConfig { | ||
private final ChoiceBox<String> selector = EPortal.controller.selector; | ||
public static int index; | ||
|
||
public NetTypeConfig() { | ||
super("NetType"); | ||
} | ||
|
||
@Override | ||
public JsonElement toJson() { | ||
return new JsonPrimitive(EPortal.controller.selector.getItems().indexOf(EPortal.controller.selector.getValue())); | ||
return new JsonPrimitive(MainWindow.controller.typeSelector.getItems().indexOf(MainWindow.controller.typeSelector.getValue())); | ||
} | ||
|
||
@Override | ||
public void fromJson(JsonElement element) { | ||
if (element.getAsInt() != -1) | ||
selector.setValue(selector.getItems().get(element.getAsInt())); | ||
else | ||
selector.setValue(""); | ||
index = element.getAsInt(); | ||
} | ||
} |
4 changes: 0 additions & 4 deletions
4
src/main/java/cn/reddragon/eportal/controllers/SettingsController.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/cn/reddragon/eportal/window/AccountWindow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package cn.reddragon.eportal.window; | ||
|
||
import cn.reddragon.eportal.account.Account; | ||
import cn.reddragon.eportal.account.AccountManager; | ||
import cn.reddragon.eportal.window.controllers.AccountController; | ||
import javafx.collections.ObservableList; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.ListView; | ||
import javafx.stage.Modality; | ||
import javafx.stage.Stage; | ||
|
||
import java.io.IOException; | ||
|
||
public class AccountWindow { | ||
public static AccountController controller; | ||
private static Stage stage; | ||
|
||
public static Stage getStage() { | ||
return stage; | ||
} | ||
|
||
public static void init(Stage parent) throws IOException { | ||
FXMLLoader loader = new FXMLLoader(AccountWindow.class.getResource("account-view.fxml")); | ||
Parent root = loader.load(); | ||
controller = loader.getController(); | ||
Scene scene = new Scene(root); | ||
Stage stage = new Stage(); | ||
stage.setTitle("账号管理"); | ||
stage.setScene(scene); | ||
stage.initOwner(parent); | ||
stage.initModality(Modality.WINDOW_MODAL); | ||
ListView<String> listView = controller.listView; | ||
listView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> { | ||
controller.onSelectionChanged(newValue); | ||
}); | ||
ObservableList<String> items = listView.getItems(); | ||
for (Account account : AccountManager.accounts) { | ||
items.add(account.name()); | ||
} | ||
AccountWindow.stage = stage; | ||
} | ||
|
||
public static void open() { | ||
stage.show(); | ||
} | ||
} |
Oops, something went wrong.