Ver Fonte

feat:客户端增加图标,并修改javafx application的类名

yangyi há 1 mês atrás
pai
commit
0247b0dc7a

+ 1 - 1
client/pom.xml

@@ -50,7 +50,7 @@
                 <artifactId>javafx-maven-plugin</artifactId>
                 <version>0.0.8</version>
                 <configuration>
-                    <mainClass>space.anyi.client.App</mainClass>
+                    <mainClass>space.anyi.client.UIApplication</mainClass>
                 </configuration>
             </plugin>
         </plugins>

+ 1 - 1
client/src/main/java/space/anyi/client/Client.java

@@ -12,6 +12,6 @@ import javafx.application.Application;
  */
 public class Client {
     public static void main(String[] args) {
-        Application.launch(App.class,args);
+        Application.launch(UIApplication.class,args);
     }
 }

+ 6 - 5
client/src/main/java/space/anyi/client/App.java → client/src/main/java/space/anyi/client/UIApplication.java

@@ -3,10 +3,10 @@ package space.anyi.client;
 import javafx.application.Application;
 import javafx.fxml.FXMLLoader;
 import javafx.scene.Scene;
+import javafx.scene.image.Image;
 import javafx.stage.Stage;
-import space.anyi.client.util.LoginUserHolder;
 
-public class App extends Application {
+public class UIApplication extends Application {
 
     private static Stage primaryStage;
 
@@ -15,6 +15,7 @@ public class App extends Application {
         primaryStage = stage;
         showLoginScene();
         stage.setTitle("校园二手书交易系统");
+        stage.getIcons().add(new Image(UIApplication.class.getResourceAsStream("/favicon.png")));
         stage.show();
     }
 
@@ -24,7 +25,7 @@ public class App extends Application {
     }
 
     public static void showLoginScene() throws Exception {
-        FXMLLoader loader = new FXMLLoader(App.class.getResource("/fxml/login.fxml"));
+        FXMLLoader loader = new FXMLLoader(UIApplication.class.getResource("/fxml/login.fxml"));
         Scene scene = new Scene(loader.load());
         addStylesheets(scene);
         primaryStage.setScene(scene);
@@ -32,7 +33,7 @@ public class App extends Application {
     }
 
     public static void showRegisterScene() throws Exception {
-        FXMLLoader loader = new FXMLLoader(App.class.getResource("/fxml/register.fxml"));
+        FXMLLoader loader = new FXMLLoader(UIApplication.class.getResource("/fxml/register.fxml"));
         Scene scene = new Scene(loader.load());
         addStylesheets(scene);
         primaryStage.setScene(scene);
@@ -40,7 +41,7 @@ public class App extends Application {
     }
 
     public static void showMainScene() throws Exception {
-        FXMLLoader loader = new FXMLLoader(App.class.getResource("/fxml/main.fxml"));
+        FXMLLoader loader = new FXMLLoader(UIApplication.class.getResource("/fxml/main.fxml"));
         Scene scene = new Scene(loader.load());
         addStylesheets(scene);
         primaryStage.setScene(scene);

+ 3 - 3
client/src/main/java/space/anyi/client/controller/LoginController.java

@@ -5,7 +5,7 @@ import javafx.scene.control.PasswordField;
 import javafx.scene.control.TextField;
 import javafx.scene.control.Alert;
 import javafx.scene.control.Label;
-import space.anyi.client.App;
+import space.anyi.client.UIApplication;
 import space.anyi.client.service.UserService;
 import space.anyi.client.util.LoginUserHolder;
 import space.anyi.common.dto.R;
@@ -32,7 +32,7 @@ public class LoginController {
         if (result.getCode() == 200 && result.getData() != null) {
             LoginUserHolder.set(result.getData());
             try {
-                App.showMainScene();
+                UIApplication.showMainScene();
             } catch (Exception e) {
                 showAlert("加载主界面失败:" + e.getMessage());
             }
@@ -44,7 +44,7 @@ public class LoginController {
     @FXML
     private void handleRegister() {
         try {
-            App.showRegisterScene();
+            UIApplication.showRegisterScene();
         } catch (Exception e) {
             showAlert("加载注册界面失败:" + e.getMessage());
         }

+ 2 - 2
client/src/main/java/space/anyi/client/controller/MainController.java

@@ -12,7 +12,7 @@ import javafx.scene.layout.*;
 import javafx.geometry.Pos;
 import javafx.stage.Modality;
 import java.time.format.DateTimeFormatter;
-import space.anyi.client.App;
+import space.anyi.client.UIApplication;
 import space.anyi.client.service.AiService;
 import space.anyi.client.service.BookService;
 import space.anyi.client.service.StatisticsService;
@@ -1311,7 +1311,7 @@ public class MainController {
     private void handleLogout() {
         LoginUserHolder.clear();
         try {
-            App.showLoginScene();
+            UIApplication.showLoginScene();
         } catch (Exception e) {
             showAlert("错误:" + e.getMessage());
         }

+ 3 - 3
client/src/main/java/space/anyi/client/controller/RegisterController.java

@@ -5,7 +5,7 @@ import javafx.scene.control.PasswordField;
 import javafx.scene.control.TextField;
 import javafx.scene.control.Alert;
 import javafx.scene.control.Label;
-import space.anyi.client.App;
+import space.anyi.client.UIApplication;
 import space.anyi.client.service.UserService;
 import space.anyi.common.dto.R;
 import space.anyi.common.dto.RegisterRequest;
@@ -48,7 +48,7 @@ public class RegisterController {
         if (result.getCode() == 200) {
             showInfo("注册成功!请登录。");
             try {
-                App.showLoginScene();
+                UIApplication.showLoginScene();
             } catch (Exception e) {
                 showAlert("错误:" + e.getMessage());
             }
@@ -60,7 +60,7 @@ public class RegisterController {
     @FXML
     private void handleBack() {
         try {
-            App.showLoginScene();
+            UIApplication.showLoginScene();
         } catch (Exception e) {
             showAlert("Error: " + e.getMessage());
         }

BIN
client/src/main/resources/favicon.png