🎉 init project

This commit is contained in:
fuhouyin 2025-04-21 14:46:26 +08:00
parent 964a72fe44
commit 8a8b58c80f
3 changed files with 21 additions and 39 deletions

View File

@ -59,7 +59,7 @@ public class AppUI extends Application {
} }
@Override @Override
public void start(Stage stage) throws IOException { public void start(Stage stage) {
Thread.currentThread().setUncaughtExceptionHandler(new DefaultExceptionHandler(stage)); Thread.currentThread().setUncaughtExceptionHandler(new DefaultExceptionHandler(stage));
loadApplicationProperties(); loadApplicationProperties();

View File

@ -2,10 +2,12 @@ package com.cecilia.view.window;
import animatefx.animation.BounceInRight; import animatefx.animation.BounceInRight;
import atlantafx.base.controls.Message; import atlantafx.base.controls.Message;
import atlantafx.base.controls.ModalPane;
import atlantafx.base.theme.Styles; import atlantafx.base.theme.Styles;
import atlantafx.base.util.Animations; import atlantafx.base.util.Animations;
import com.cecilia.view.loginregister.LoginRegisterView; import com.cecilia.view.loginregister.LoginRegisterView;
import com.cecilia.view.loginregister.LoginRegisterViewModel; import com.cecilia.view.loginregister.LoginRegisterViewModel;
import com.goxr3plus.fxborderlessscene.borderless.BorderlessScene;
import de.saxsys.mvvmfx.*; import de.saxsys.mvvmfx.*;
import javafx.animation.KeyFrame; import javafx.animation.KeyFrame;
import javafx.animation.Timeline; import javafx.animation.Timeline;
@ -42,12 +44,16 @@ public class WindowView implements FxmlView<WindowViewModel>, Initializable {
private StackPane rootPane; private StackPane rootPane;
@FXML @FXML
private StackPane contentPane; private StackPane contentPane;
public static final String MAIN_MODAL_ID = "modal-pane";
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
messagePane.visibleProperty().bindBidirectional(windowViewModel.mainViewVisbleProperty()); var modalPane = new ModalPane();
modalPane.setId(MAIN_MODAL_ID);
rootPane.getChildren().add(0, modalPane);
//messagePane.visibleProperty().bindBidirectional(windowViewModel.mainViewVisbleProperty());
MvvmFX.getNotificationCenter().subscribe("showMainView", (key, payload) -> { MvvmFX.getNotificationCenter().subscribe("showMainView", (key, payload) -> {
// trigger some actions // trigger some actions
Platform.runLater(() -> { Platform.runLater(() -> {
@ -66,35 +72,28 @@ public class WindowView implements FxmlView<WindowViewModel>, Initializable {
MvvmFX.getNotificationCenter().subscribe("message", (key, payload) -> { MvvmFX.getNotificationCenter().subscribe("message", (key, payload) -> {
// trigger some actions // trigger some actions
Platform.runLater(() -> { Platform.runLater(() -> {
showMessage((Integer) payload[0], (String) payload[1]); showMessage((Integer) payload[0], (String) payload[1]);
}); });
}); });
MvvmFX.getNotificationCenter().subscribe("exit", (key, payload) -> { MvvmFX.getNotificationCenter().subscribe("exit", (key, payload) -> {
// trigger some actions // trigger some actions
Platform.runLater(() -> { Platform.runLater(() -> {
Stage stage = (Stage) rootPane.getScene().getWindow(); Stage stage = (Stage) rootPane.getScene().getWindow();
stage.close(); stage.close();
}); });
}); });
showLoginView(); showLoginView();
} }
private void showMainView() { private void showMainView() {
contentPane.getChildren().clear(); contentPane.getChildren().clear();
ViewTuple<MainView, MainViewModel> load = FluentViewLoader.fxmlView(MainView.class).load(); ViewTuple<MainView, MainViewModel> load = FluentViewLoader.fxmlView(MainView.class).load();
contentPane.getChildren().add(load.getView()); contentPane.getChildren().add(load.getView());
windowViewModel.mainViewVisbleProperty().setValue(true); windowViewModel.mainViewVisbleProperty().setValue(true);
if (contentPane.getScene() instanceof BorderlessScene) {
((BorderlessScene) contentPane.getScene()).maximizeStage();
}
} }
@ -110,9 +109,8 @@ public class WindowView implements FxmlView<WindowViewModel>, Initializable {
if (windowViewModel.isMainViewVisble()) { if (windowViewModel.isMainViewVisble()) {
Platform.runLater(() -> { Platform.runLater(() -> {
Message message = null; Message message = null;
if (code == HttpStatus.SUCCESS) { if (code == HttpStatus.SUCCESS) {
message = new Message("消息提示", msg, new FontIcon(Material2OutlinedAL.CHECK_CIRCLE_OUTLINE)); message = new Message("消息提示", msg, new FontIcon(Material2OutlinedAL.CHECK_CIRCLE_OUTLINE));
message.getStyleClass().addAll(Styles.SUCCESS); message.getStyleClass().addAll(Styles.SUCCESS);
@ -122,26 +120,26 @@ public class WindowView implements FxmlView<WindowViewModel>, Initializable {
} }
message.setPrefHeight(Region.USE_PREF_SIZE); message.setPrefHeight(Region.USE_PREF_SIZE);
message.setMaxHeight(Region.USE_PREF_SIZE); message.setMaxHeight(Region.USE_PREF_SIZE);
message.setMaxWidth(Region.USE_PREF_SIZE);
StackPane.setAlignment(message, Pos.TOP_RIGHT); StackPane.setAlignment(message, Pos.TOP_RIGHT);
StackPane.setMargin(message, new Insets(10, 10, 0, 0)); StackPane.setMargin(message, new Insets(60, 10, 0, 0));
Message finalMessage = message; Message finalMessage = message;
message.setOnClose(e -> { message.setOnClose(e -> {
var out = Animations.slideOutUp(finalMessage, Duration.millis(250)); var out = Animations.slideOutUp(finalMessage, Duration.millis(250));
out.setOnFinished(f -> messagePane.getChildren().remove(finalMessage)); out.setOnFinished(f -> rootPane.getChildren().remove(finalMessage));
out.playFromStart(); out.playFromStart();
}); });
// var in = Animations.slideInDown(message, Duration.millis(250)); if (!rootPane.getChildren().contains(message)) {
if (!messagePane.getChildren().contains(message)) { rootPane.getChildren().add(message);
messagePane.getChildren().add(message);
} }
new BounceInRight(message).play(); new BounceInRight(message).play();
Timeline fiveSecondsWonder = new Timeline(new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() { Timeline fiveSecondsWonder = new Timeline(new KeyFrame(Duration.seconds(5), new EventHandler<ActionEvent>() {
@Override @Override
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
var out = Animations.slideOutUp(finalMessage, Duration.millis(250)); var out = Animations.slideOutUp(finalMessage, Duration.millis(250));
out.setOnFinished(f -> messagePane.getChildren().remove(finalMessage)); out.setOnFinished(f -> rootPane.getChildren().remove(finalMessage));
out.playFromStart(); out.playFromStart();
} }
})); }));

View File

@ -1,27 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?> <?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.StackPane?> <?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<StackPane fx:id="rootPane" prefHeight="455.0" prefWidth="539.0" styleClass="window-view" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.cecilia.view.window.WindowView"> <StackPane fx:id="rootPane" prefHeight="455.0" prefWidth="539.0" styleClass="window-view" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.cecilia.view.window.WindowView">
<children> <children>
<Pane fx:id="backgroundPane" prefHeight="200.0" prefWidth="200.0" /> <Pane fx:id="backgroundPane" prefHeight="200.0" prefWidth="200.0" />
<Pane fx:id="backgroundImgPane" prefHeight="200.0" prefWidth="200.0" /> <Pane fx:id="backgroundImgPane" prefHeight="200.0" prefWidth="200.0" />
<StackPane fx:id="contentPane" prefHeight="150.0" prefWidth="200.0" /> <StackPane fx:id="contentPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="150.0" prefWidth="200.0" />
<BorderPane pickOnBounds="false" StackPane.alignment="TOP_RIGHT">
<right>
<VBox fx:id="messagePane" alignment="TOP_CENTER" minWidth="240.0" pickOnBounds="false" prefHeight="200.0" prefWidth="100.0" spacing="10.0" BorderPane.alignment="CENTER">
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets top="60.0" />
</padding>
</VBox>
</right>
</BorderPane>
</children> </children>
</StackPane> </StackPane>