Skip to content

Commit

Permalink
实现关于窗口
Browse files Browse the repository at this point in the history
  • Loading branch information
RedDragon0293 committed Jun 11, 2024
1 parent 7e333f7 commit 6270470
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
}

group 'cn.reddragon'
version '2.0.0'
version '2.1.0'

repositories {
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/cn/reddragon/eportal/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class Main {
public static final String name = "EPortal";
public static final String version = "2.0.0";
public static final String version = "2.1.0";
public static Logger logger = LogManager.getLogger(name);

public static void main(String[] args) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cn/reddragon/eportal/window/AccountWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

public class AccountWindow {
public static AccountController controller;
public static Stage fatherStage;
private static Stage stage;

public static Stage getStage() {
Expand All @@ -31,7 +30,7 @@ private static void init() throws IOException {
Stage stage = new Stage();
stage.setTitle("账号管理");
stage.setScene(scene);
stage.initOwner(fatherStage);
stage.initOwner(MainWindow.fatherStage);
stage.initModality(Modality.WINDOW_MODAL);
ListView<String> listView = controller.listView;
listView.getSelectionModel().selectedItemProperty().addListener((observableValue, oldValue, newValue) -> {
Expand All @@ -55,5 +54,6 @@ public static void open() {
throw new RuntimeException(e);
}
stage.showAndWait();
stage = null;
}
}
3 changes: 2 additions & 1 deletion src/main/java/cn/reddragon/eportal/window/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class MainWindow extends Application {
}
}
});
public static Stage fatherStage;

public static void main(String[] args) {
askThread.setDaemon(true);
Expand All @@ -67,7 +68,7 @@ public void start(Stage stage) throws IOException {
stage.setScene(scene);
ConfigManager.loadConfigs();
//AccountWindow.init(stage);
AccountWindow.fatherStage = stage;
fatherStage = stage;
ChoiceBox<String> box = (ChoiceBox<String>) root.lookup("#typeSelector");
for (LoginType it : LoginType.values())
if (!Objects.equals(it.displayName, ""))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
import cn.reddragon.eportal.account.AccountManager;
import cn.reddragon.eportal.utils.*;
import cn.reddragon.eportal.window.AccountWindow;
import cn.reddragon.eportal.window.MainWindow;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.MenuBar;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;

import java.awt.*;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.Arrays;
Expand Down Expand Up @@ -91,14 +96,43 @@ public void onOpenAccountWindow() {

@FXML
public void onOpenLog() {
Desktop desktop = Desktop.getDesktop();
try {
Desktop desktop = Desktop.getDesktop();
desktop.open(new File("logs\\latest.log"));
} catch (Exception e) {
Main.logger.error("打开日志失败!", e);
}
}

@FXML
public void openAboutDialog() {
Alert dialog = new Alert(Alert.AlertType.INFORMATION);
dialog.setTitle("关于");
dialog.setHeaderText(null);
VBox vbox = new VBox();
Label label1 = new Label(Main.name + " version " + Main.version);
vbox.getChildren().add(label1);
Hyperlink link = new Hyperlink("https://github.com/RedDragon0293/EPortal");
link.setOnAction(e -> {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(new URI("https://github.com/RedDragon0293/EPortal"));
} catch (IOException | URISyntaxException ex) {
Main.logger.error(ex);
}
});
Label label2 = new Label("开源地址: ");
//label2.setLabelFor(link);
label2.setGraphic(link);
label2.setContentDisplay(ContentDisplay.RIGHT);
vbox.getChildren().add(label2);
//vbox.getChildren().add(link);
dialog.getDialogPane().setContent(vbox);
dialog.initOwner(MainWindow.fatherStage);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.showAndWait();
}

@FXML
public void onLoginButtonClick() {
button.setDisable(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<Menu mnemonicParsing="false" text="帮助">
<items>
<MenuItem mnemonicParsing="false" onAction="#onOpenLog" text="查看日志"/>
<MenuItem mnemonicParsing="false" text="关于"/>
<MenuItem mnemonicParsing="false" onAction="#openAboutDialog" text="关于"/>
</items>
</Menu>
</menus>
</MenuBar>
<VBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="210.0"
<VBox alignment="CENTER" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefWidth="220.0"
spacing="20.0">
<padding>
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
Expand Down

0 comments on commit 6270470

Please sign in to comment.