From 8a5b5d42c99e8ef3c866d92884e99b0c521d10c9 Mon Sep 17 00:00:00 2001 From: liwen Date: Fri, 6 Nov 2020 11:40:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epri/fx/client/AppStartup.java | 3 +- .../uicomponents/login/LoginController.java | 240 ++++++--- .../login/LoginControllerNew.java | 478 ------------------ .../gui/uicomponents/main/MainController.java | 1 - .../main/resources/fxml/login/Untitled.fxml | 143 ------ .../src/main/resources/fxml/login/login.fxml | 210 ++++---- 6 files changed, 308 insertions(+), 767 deletions(-) delete mode 100644 client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginControllerNew.java delete mode 100644 client/src/main/resources/fxml/login/Untitled.fxml diff --git a/client/src/main/java/com/epri/fx/client/AppStartup.java b/client/src/main/java/com/epri/fx/client/AppStartup.java index f0ec4cb..9f2b8ac 100644 --- a/client/src/main/java/com/epri/fx/client/AppStartup.java +++ b/client/src/main/java/com/epri/fx/client/AppStartup.java @@ -2,7 +2,6 @@ package com.epri.fx.client; import com.epri.fx.client.gui.uicomponents.control.LFXDecorator; import com.epri.fx.client.gui.uicomponents.login.LoginController; -import com.epri.fx.client.gui.uicomponents.login.LoginControllerNew; import com.epri.fx.client.store.ApplicatonStore; import com.jfoenix.assets.JFoenixResources; import com.jfoenix.svg.SVGGlyph; @@ -70,7 +69,7 @@ public class AppStartup extends Application { ApplicationContext.getInstance().register(stage, Stage.class); - Flow flow = new Flow(LoginControllerNew.class); + Flow flow = new Flow(LoginController.class); FlowHandler flowHandler = flow.createHandler(); StackPane rootPane = flowHandler.start(new AnimatedFlowContainer(Duration.millis(320), ContainerAnimations.SWIPE_LEFT)); diff --git a/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java b/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java index eb72fda..b9879c2 100644 --- a/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java +++ b/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginController.java @@ -2,13 +2,12 @@ package com.epri.fx.client.gui.uicomponents.login; import com.epri.fx.client.bean.MenuVoCell; import com.epri.fx.client.gui.uicomponents.main.MainController; -import com.epri.fx.client.request.feign.admin.MenuFeign; -import com.epri.fx.client.store.ApplicatonStore; -import com.epri.fx.client.request.feign.login.LoginFeign; import com.epri.fx.client.request.Request; +import com.epri.fx.client.request.feign.admin.MenuFeign; +import com.epri.fx.client.request.feign.login.LoginFeign; +import com.epri.fx.client.store.ApplicatonStore; import com.epri.fx.client.utils.AlertUtil; import com.epri.fx.client.websocket.Session; -import com.epri.fx.server.util.DynamicEnumUtils; import com.epri.fx.server.util.EncryptUtil; import com.epri.fx.server.util.user.JwtAuthenticationRequest; import com.epri.fx.server.vo.FrontUser; @@ -18,6 +17,8 @@ import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXPasswordField; import com.jfoenix.controls.JFXProgressBar; import com.jfoenix.controls.JFXTextField; +import com.jfoenix.svg.SVGGlyph; +import com.jfoenix.svg.SVGGlyphLoader; import io.datafx.controller.ViewController; import io.datafx.controller.flow.FlowException; import io.datafx.controller.flow.action.ActionMethod; @@ -34,16 +35,17 @@ import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; -import javafx.event.EventType; +import javafx.event.Event; +import javafx.event.EventHandler; import javafx.fxml.FXML; +import javafx.scene.control.Hyperlink; import javafx.scene.control.Label; +import javafx.scene.effect.PerspectiveTransform; import javafx.scene.image.ImageView; import javafx.scene.input.KeyCode; -import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import javafx.stage.Stage; import javafx.util.Duration; import javax.annotation.PostConstruct; @@ -65,28 +67,50 @@ import java.util.stream.Collectors; @ViewController("/fxml/login/login.fxml") public class LoginController { - - @FXML - - private Pane imagePane; - @FXML - private GridPane enterPane; @FXML private StackPane rootPane; @FXML + private Pane imagePane; + + @FXML + private StackPane centerPane; + + //正面视图 + @FXML + public HBox loginPane; + //反面视图 + @FXML + public HBox registeredPane; + @FXML + public Hyperlink registeredLink; + @FXML + public Hyperlink loginLink; + @FXML + private Label errorLabel; + @FXML + private Label userIcon; + @FXML + private Label pwdIcon; + @FXML + private Label reuserIcon; + @FXML + private Label repwdIcon; + @FXML + private Label repwd2Icon; + @FXML + private JFXProgressBar lodingBar; + @FXML private JFXTextField userNameTextField; @FXML private JFXPasswordField passWordTextField; - @FXML - private Label errorLabel; - @FXML - @ActionTrigger("login") - private JFXButton loginBut; - @FXML - private VBox signCredsPane; - - @FXML - private JFXProgressBar lodingBar; + //翻转角度 + private DoubleProperty angleProperty = new SimpleDoubleProperty(Math.PI / 2); + //正面翻转特效 + private PerspectiveTransform frontEffect = new PerspectiveTransform(); + //反面翻转特效 + private PerspectiveTransform backEffect = new PerspectiveTransform(); + private Timeline frontTimeLine = new Timeline(); + private Timeline backTimeLine = new Timeline(); @ActionHandler private FlowActionHandler actionHandler; @@ -95,47 +119,42 @@ public class LoginController { private DoubleProperty imageWidth = new SimpleDoubleProperty(); private DoubleProperty imageHeiht = new SimpleDoubleProperty(); - private Stage stage; @Inject private Session session; + @FXML + @ActionTrigger("login") + private JFXButton loginBut; @FXMLViewFlowContext private ViewFlowContext flowContext; @PostConstruct public void init() { - errorLabel.visibleProperty().bind(errorLabel.textProperty().isNotEmpty()); - errorLabel.managedProperty().bind(errorLabel.visibleProperty()); - lodingBar.visibleProperty().bind(enterPane.disableProperty()); - lodingBar.managedProperty().bind(lodingBar.visibleProperty()); + try { + SVGGlyph userSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".user-name"); + SVGGlyph pwdSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".password"); + SVGGlyph reuserSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".user-name"); + SVGGlyph repwdSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".password"); + SVGGlyph repwd2Svg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".querenmima"); + userSvg.setId("login-svg-glyph"); + pwdSvg.setId("login-svg-glyph"); + reuserSvg.setId("login-svg-glyph"); + repwdSvg.setId("login-svg-glyph"); + repwd2Svg.setId("login-svg-glyph"); - userNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> { - if (!newVal) { - userNameTextField.validate(); - } - }); - passWordTextField.focusedProperty().addListener((o, oldVal, newVal) -> { - if (!newVal) { - passWordTextField.validate(); - } - }); + userIcon.setGraphic(userSvg); + pwdIcon.setGraphic(pwdSvg); + reuserIcon.setGraphic(reuserSvg); + repwdIcon.setGraphic(repwdSvg); + repwd2Icon.setGraphic(repwd2Svg); + } catch (Exception e) { + e.printStackTrace(); + } - loginBut.disableProperty().bind(Bindings.or( - userNameTextField.textProperty().isEqualTo(""), - passWordTextField.textProperty().isEqualTo(""))); - - rootPane.setOnKeyPressed(event -> { - if (event.getCode() == KeyCode.ENTER) { - if (loginBut.isDisable() == false) { - login(); - } - } - - }); imagePane.widthProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Number oldValue, Number newValue) { @@ -149,16 +168,25 @@ public class LoginController { } }); + registeredPane.visibleProperty().bind( + Bindings.when(angleProperty.lessThan(0)).then(true).otherwise(false)); + loginPane.visibleProperty().bind(registeredPane.visibleProperty().not()); + initAnimation(); + loadingImage(); + initAction(); - FadeTransition fadeTransition = new FadeTransition(Duration.millis(500), signCredsPane); + } + + private void initAnimation() { + FadeTransition fadeTransition = new FadeTransition(Duration.millis(500), centerPane); fadeTransition.setFromValue(0f); fadeTransition.setToValue(1f); - TranslateTransition translateTransition = new TranslateTransition(Duration.millis(500), signCredsPane); + TranslateTransition translateTransition = new TranslateTransition(Duration.millis(500), centerPane); translateTransition.setInterpolator(Interpolator.EASE_BOTH); translateTransition.setFromY(400); - translateTransition.setToY(signCredsPane.getLayoutY()); + translateTransition.setToY(centerPane.getLayoutY()); ParallelTransition parallelTransition = new ParallelTransition(); parallelTransition.setDelay(Duration.millis(1500)); @@ -169,6 +197,52 @@ public class LoginController { parallelTransition.setCycleCount(1); parallelTransition.play(); + + KeyFrame frame1 = new KeyFrame(Duration.ZERO, new KeyValue(angleProperty, + Math.PI / 2, Interpolator.LINEAR)); + KeyFrame frame2 = new KeyFrame(Duration.seconds(0.5), + new EventHandler() { + @Override + public void handle(Event event) { + loginPane.setEffect(null); + registeredPane.setEffect(null); + } + + }, new KeyValue(angleProperty, -Math.PI / 2, Interpolator.LINEAR)); + + KeyFrame frame3 = new KeyFrame(Duration.seconds(0.5), new EventHandler() { + @Override + public void handle(Event event) { + loginPane.setEffect(null); + registeredPane.setEffect(null); + } + + }, new KeyValue(angleProperty, + Math.PI / 2, Interpolator.LINEAR)); + KeyFrame frame4 = new KeyFrame(Duration.ZERO, new KeyValue(angleProperty, -Math.PI / 2, Interpolator.LINEAR)); + + + frontTimeLine.getKeyFrames().addAll(frame1, frame2); + backTimeLine.getKeyFrames().addAll(frame4, frame3); + } + + private void setPT(PerspectiveTransform pt, double t) { + double width = 650; + double height = 450; + double radius = width / 2; + double back = height / 10; + pt.setUlx(radius - Math.sin(t) * radius); + pt.setUly(0 - Math.cos(t) * back); + pt.setUrx(radius + Math.sin(t) * radius); + pt.setUry(0 + Math.cos(t) * back); + pt.setLrx(radius + Math.sin(t) * radius); + pt.setLry(height - Math.cos(t) * back); + pt.setLlx(radius - Math.sin(t) * radius); + pt.setLly(height + Math.cos(t) * back); + } + + private void loadingImage() { + ImageView logBack = new ImageView("/images/loginBack.jpg"); logBack.fitHeightProperty().bind(imageHeiht); logBack.fitWidthProperty().bind(imageWidth); @@ -205,10 +279,62 @@ public class LoginController { } }).withFinal(() -> sequentialTransition.play()).run(); + } + private void initAction() { + errorLabel.visibleProperty().bind(errorLabel.textProperty().isNotEmpty()); + errorLabel.managedProperty().bind(errorLabel.visibleProperty()); + + lodingBar.visibleProperty().bind(centerPane.disableProperty()); + lodingBar.managedProperty().bind(lodingBar.visibleProperty()); + + userNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> { + if (!newVal) { + userNameTextField.validate(); + } + }); + passWordTextField.focusedProperty().addListener((o, oldVal, newVal) -> { + if (!newVal) { + passWordTextField.validate(); + } + }); + + loginBut.disableProperty().bind(Bindings.or( + userNameTextField.textProperty().isEqualTo(""), + passWordTextField.textProperty().isEqualTo(""))); + + rootPane.setOnKeyPressed(event -> { + if (event.getCode() == KeyCode.ENTER) { + if (loginBut.isDisable() == false) { + login(); + } + } + + }); + angleProperty.addListener((observable, oldValue, newValue) -> { + setPT(frontEffect, angleProperty.get()); + setPT(backEffect, angleProperty.get() - Math.PI); + }); + registeredLink.setOnAction(event -> { + loginPane.setEffect(frontEffect); + registeredPane.setEffect(backEffect); + frontTimeLine.play(); + }); + loginLink.setOnAction(event -> { + loginPane.setEffect(frontEffect); + registeredPane.setEffect(backEffect); + backTimeLine.play(); + }); } + /** + * @Description:登录 + * @param: [] + * @return: void + * @auther: liwen + * @date: 2020/11/6 9:56 上午 + */ @ActionMethod("login") private void login() { @@ -217,7 +343,7 @@ public class LoginController { jwtAuthenticationRequest.setPassword(EncryptUtil.getInstance().Base64Encode(passWordTextField.getText())); ProcessChain.create() .addRunnableInPlatformThread(() -> { - enterPane.setDisable(true); + centerPane.setDisable(true); loginBut.setText("正在登录..."); }) .addSupplierInExecutor(() -> Request.connector(LoginFeign.class).login(jwtAuthenticationRequest)) @@ -239,7 +365,7 @@ public class LoginController { lodingBar.requestFocus(); }) .withFinal(() -> { - enterPane.setDisable(false); + centerPane.setDisable(false); loginBut.setText("登录"); }).run(); @@ -312,7 +438,7 @@ public class LoginController { continue; } - MenuVoCell menuVoCell=new MenuVoCell(menu,childrenMenus); + MenuVoCell menuVoCell = new MenuVoCell(menu, childrenMenus); ApplicatonStore.getMenuVoCells().add(menuVoCell); diff --git a/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginControllerNew.java b/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginControllerNew.java deleted file mode 100644 index e088407..0000000 --- a/client/src/main/java/com/epri/fx/client/gui/uicomponents/login/LoginControllerNew.java +++ /dev/null @@ -1,478 +0,0 @@ -package com.epri.fx.client.gui.uicomponents.login; - -import com.epri.fx.client.bean.MenuVoCell; -import com.epri.fx.client.gui.uicomponents.main.MainController; -import com.epri.fx.client.request.Request; -import com.epri.fx.client.request.feign.admin.MenuFeign; -import com.epri.fx.client.request.feign.login.LoginFeign; -import com.epri.fx.client.store.ApplicatonStore; -import com.epri.fx.client.utils.AlertUtil; -import com.epri.fx.client.websocket.Session; -import com.epri.fx.server.util.EncryptUtil; -import com.epri.fx.server.util.user.JwtAuthenticationRequest; -import com.epri.fx.server.vo.FrontUser; -import com.epri.fx.server.vo.MenuVO; -import com.epri.fx.server.vo.PermissionInfo; -import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXPasswordField; -import com.jfoenix.controls.JFXProgressBar; -import com.jfoenix.controls.JFXTextField; -import com.jfoenix.svg.SVGGlyph; -import com.jfoenix.svg.SVGGlyphLoader; -import io.datafx.controller.ViewController; -import io.datafx.controller.flow.FlowException; -import io.datafx.controller.flow.action.ActionMethod; -import io.datafx.controller.flow.action.ActionTrigger; -import io.datafx.controller.flow.context.ActionHandler; -import io.datafx.controller.flow.context.FXMLViewFlowContext; -import io.datafx.controller.flow.context.FlowActionHandler; -import io.datafx.controller.flow.context.ViewFlowContext; -import io.datafx.controller.util.VetoException; -import io.datafx.core.concurrent.ProcessChain; -import javafx.animation.*; -import javafx.beans.binding.Bindings; -import javafx.beans.property.DoubleProperty; -import javafx.beans.property.SimpleDoubleProperty; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.event.Event; -import javafx.event.EventHandler; -import javafx.fxml.FXML; -import javafx.scene.control.Hyperlink; -import javafx.scene.control.Label; -import javafx.scene.effect.PerspectiveTransform; -import javafx.scene.image.ImageView; -import javafx.scene.input.KeyCode; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Pane; -import javafx.scene.layout.StackPane; -import javafx.util.Duration; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Inject; -import java.io.File; -import java.util.Arrays; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @description: - * @className: ConversationItemPresenter - * @author: liwen - * @date: 2019-09-25 16:51 - */ -@ViewController("/fxml/login/Untitled.fxml") -public class LoginControllerNew { - - @FXML - private StackPane rootPane; - @FXML - private Pane imagePane; - - @FXML - private StackPane centerPane; - - //正面视图 - @FXML - public HBox loginPane; - //反面视图 - @FXML - public HBox registeredPane; - @FXML - public Hyperlink registeredLink; - @FXML - public Hyperlink loginLink; - @FXML - private Label errorLabel; - @FXML - private Label userIcon; - @FXML - private Label pwdIcon; - @FXML - private Label reuserIcon; - @FXML - private Label repwdIcon; - @FXML - private Label repwd2Icon; - @FXML - private JFXProgressBar lodingBar; - @FXML - private JFXTextField userNameTextField; - @FXML - private JFXPasswordField passWordTextField; - //翻转角度 - private DoubleProperty angleProperty = new SimpleDoubleProperty(Math.PI / 2); - //正面翻转特效 - private PerspectiveTransform frontEffect = new PerspectiveTransform(); - //反面翻转特效 - private PerspectiveTransform backEffect = new PerspectiveTransform(); - private Timeline frontTimeLine = new Timeline(); - private Timeline backTimeLine = new Timeline(); - - @ActionHandler - private FlowActionHandler actionHandler; - - private SequentialTransition sequentialTransition = new SequentialTransition(); - - private DoubleProperty imageWidth = new SimpleDoubleProperty(); - private DoubleProperty imageHeiht = new SimpleDoubleProperty(); - - - @Inject - private Session session; - - @FXML - @ActionTrigger("login") - private JFXButton loginBut; - - @FXMLViewFlowContext - private ViewFlowContext flowContext; - - @PostConstruct - public void init() { - - try { - SVGGlyph userSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".user-name"); - SVGGlyph pwdSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".password"); - SVGGlyph reuserSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".user-name"); - SVGGlyph repwdSvg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".password"); - SVGGlyph repwd2Svg = SVGGlyphLoader.getIcoMoonGlyph(ApplicatonStore.ICON_FONT_KEY + ".querenmima"); - userSvg.setId("login-svg-glyph"); - pwdSvg.setId("login-svg-glyph"); - reuserSvg.setId("login-svg-glyph"); - repwdSvg.setId("login-svg-glyph"); - repwd2Svg.setId("login-svg-glyph"); - - userIcon.setGraphic(userSvg); - pwdIcon.setGraphic(pwdSvg); - reuserIcon.setGraphic(reuserSvg); - repwdIcon.setGraphic(repwdSvg); - repwd2Icon.setGraphic(repwd2Svg); - } catch (Exception e) { - e.printStackTrace(); - } - - imagePane.widthProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, Number oldValue, Number newValue) { - imageWidth.setValue(newValue); - } - }); - imagePane.heightProperty().addListener(new ChangeListener() { - @Override - public void changed(ObservableValue observable, Number oldValue, Number newValue) { - imageHeiht.setValue(newValue); - } - }); - - registeredPane.visibleProperty().bind( - Bindings.when(angleProperty.lessThan(0)).then(true).otherwise(false)); - loginPane.visibleProperty().bind(registeredPane.visibleProperty().not()); - - initAnimation(); - loadingImage(); - initAction(); - - } - - private void initAnimation() { - FadeTransition fadeTransition = new FadeTransition(Duration.millis(500), centerPane); - fadeTransition.setFromValue(0f); - fadeTransition.setToValue(1f); - - TranslateTransition translateTransition = new TranslateTransition(Duration.millis(500), centerPane); - translateTransition.setInterpolator(Interpolator.EASE_BOTH); - translateTransition.setFromY(400); - translateTransition.setToY(centerPane.getLayoutY()); - - ParallelTransition parallelTransition = new ParallelTransition(); - parallelTransition.setDelay(Duration.millis(1500)); - parallelTransition.getChildren().addAll( - fadeTransition, - translateTransition - ); - parallelTransition.setCycleCount(1); - parallelTransition.play(); - - - KeyFrame frame1 = new KeyFrame(Duration.ZERO, new KeyValue(angleProperty, - Math.PI / 2, Interpolator.LINEAR)); - KeyFrame frame2 = new KeyFrame(Duration.seconds(0.5), - new EventHandler() { - @Override - public void handle(Event event) { - loginPane.setEffect(null); - registeredPane.setEffect(null); - } - - }, new KeyValue(angleProperty, -Math.PI / 2, Interpolator.LINEAR)); - - KeyFrame frame3 = new KeyFrame(Duration.seconds(0.5), new EventHandler() { - @Override - public void handle(Event event) { - loginPane.setEffect(null); - registeredPane.setEffect(null); - } - - }, new KeyValue(angleProperty, - Math.PI / 2, Interpolator.LINEAR)); - KeyFrame frame4 = new KeyFrame(Duration.ZERO, new KeyValue(angleProperty, -Math.PI / 2, Interpolator.LINEAR)); - - - frontTimeLine.getKeyFrames().addAll(frame1, frame2); - backTimeLine.getKeyFrames().addAll(frame4, frame3); - } - - private void setPT(PerspectiveTransform pt, double t) { - double width = 650; - double height = 450; - double radius = width / 2; - double back = height / 10; - pt.setUlx(radius - Math.sin(t) * radius); - pt.setUly(0 - Math.cos(t) * back); - pt.setUrx(radius + Math.sin(t) * radius); - pt.setUry(0 + Math.cos(t) * back); - pt.setLrx(radius + Math.sin(t) * radius); - pt.setLry(height - Math.cos(t) * back); - pt.setLlx(radius - Math.sin(t) * radius); - pt.setLly(height + Math.cos(t) * back); - } - - private void loadingImage() { - - ImageView logBack = new ImageView("/images/loginBack.jpg"); - logBack.fitHeightProperty().bind(imageHeiht); - logBack.fitWidthProperty().bind(imageWidth); - imagePane.getChildren().add(new Label("", logBack)); - - List files = Arrays.asList(new File(this.getClass().getResource("/images/login/").getPath()).listFiles()); - - sequentialTransition.setAutoReverse(true); - sequentialTransition.setCycleCount(Timeline.INDEFINITE); - - ProcessChain.create().addPublishingTask(() -> imagePane.getChildren(), p -> { - for (int i = 0; i < files.size(); i++) { - - File file = files.get(i); - if (!file.isDirectory()) { - String url = "/images/login/" + file.getName(); - ImageView imageView = new ImageView(url); - imageView.fitHeightProperty().bind(imageHeiht); - imageView.fitWidthProperty().bind(imageWidth); - Label label = new Label("", imageView); - - label.setOpacity(0d); - FadeTransition fadeT = new FadeTransition(Duration.millis(500), label); - fadeT.setDelay(Duration.millis(1500)); - fadeT.setFromValue(0f); - fadeT.setToValue(1f); - fadeT.setCycleCount(1); - sequentialTransition.getChildren().add(fadeT); - - p.publish(label); - - } - - } - }).withFinal(() -> sequentialTransition.play()).run(); - - } - - private void initAction() { - errorLabel.visibleProperty().bind(errorLabel.textProperty().isNotEmpty()); - errorLabel.managedProperty().bind(errorLabel.visibleProperty()); - - lodingBar.visibleProperty().bind(centerPane.disableProperty()); - lodingBar.managedProperty().bind(lodingBar.visibleProperty()); - - userNameTextField.focusedProperty().addListener((o, oldVal, newVal) -> { - if (!newVal) { - userNameTextField.validate(); - } - }); - passWordTextField.focusedProperty().addListener((o, oldVal, newVal) -> { - if (!newVal) { - passWordTextField.validate(); - } - }); - - loginBut.disableProperty().bind(Bindings.or( - userNameTextField.textProperty().isEqualTo(""), - passWordTextField.textProperty().isEqualTo(""))); - - rootPane.setOnKeyPressed(event -> { - if (event.getCode() == KeyCode.ENTER) { - if (loginBut.isDisable() == false) { - login(); - } - } - - }); - angleProperty.addListener((observable, oldValue, newValue) -> { - setPT(frontEffect, angleProperty.get()); - setPT(backEffect, angleProperty.get() - Math.PI); - }); - registeredLink.setOnAction(event -> { - loginPane.setEffect(frontEffect); - registeredPane.setEffect(backEffect); - frontTimeLine.play(); - }); - loginLink.setOnAction(event -> { - loginPane.setEffect(frontEffect); - registeredPane.setEffect(backEffect); - backTimeLine.play(); - }); - } - - - /** - * @Description:登录 - * @param: [] - * @return: void - * @auther: liwen - * @date: 2020/11/6 9:56 上午 - */ - @ActionMethod("login") - private void login() { - - JwtAuthenticationRequest jwtAuthenticationRequest = new JwtAuthenticationRequest(); - jwtAuthenticationRequest.setUsername(userNameTextField.getText()); - jwtAuthenticationRequest.setPassword(EncryptUtil.getInstance().Base64Encode(passWordTextField.getText())); - ProcessChain.create() - .addRunnableInPlatformThread(() -> { - centerPane.setDisable(true); - loginBut.setText("正在登录..."); - }) - .addSupplierInExecutor(() -> Request.connector(LoginFeign.class).login(jwtAuthenticationRequest)) - .addConsumerInPlatformThread(rel -> { - - if (rel.getStatus() == 200) { - errorLabel.setText(""); - ApplicatonStore.setToken(rel.getData()); - loadApplicatonStore(); - } else { - lodingBar.requestFocus(); - errorLabel.setText(rel.getMessage()); - } - - }) - .onException(e -> { - e.printStackTrace(); - errorLabel.setText("无法连接服务器,请检查服务器是否启动。"); - lodingBar.requestFocus(); - }) - .withFinal(() -> { - centerPane.setDisable(false); - loginBut.setText("登录"); - }).run(); - - - } - - public void loadApplicatonStore() { - ProcessChain.create() - .addRunnableInPlatformThread(() -> { - try { - actionHandler.navigate(LoadingController.class); - } catch (Exception e) { - throw new RuntimeException(e); - } - ApplicatonStore.setName(""); - ApplicatonStore.getAllMenu().clear(); - ApplicatonStore.getMenus().clear(); - ApplicatonStore.getElements().clear(); - ApplicatonStore.getPermissionMenus().clear(); - ApplicatonStore.getRoles().clear(); - }) - .addSupplierInExecutor(() -> Request.connector(MenuFeign.class).getMenuAll()) - .addConsumerInPlatformThread(rel -> ApplicatonStore.getAllMenu().addAll(rel)) - .addSupplierInExecutor(() -> - Request.connector(LoginFeign.class).getInfo(ApplicatonStore.getToken()) - ) - .addConsumerInPlatformThread(rel -> { - if (rel.getStatus() == 200) { - FrontUser frontUser = rel.getData(); - ApplicatonStore.setName(frontUser.name); - ApplicatonStore.getMenus().addAll(frontUser.getMenus()); - ApplicatonStore.getRoles().addAll(frontUser.getRoles()); - ApplicatonStore.getElements().addAll(frontUser.getElements()); - ApplicatonStore.setIntroduction(frontUser.getDescription()); - - for (PermissionInfo permissionInfo : frontUser.getElements()) { - ApplicatonStore.getFeatureMap().put(permissionInfo.getCode(), permissionInfo.getName()); - } - - - } else { - AlertUtil.show(rel); - } - }) - .addSupplierInExecutor(() -> - Request.connector(LoginFeign.class).getMenus(ApplicatonStore.getToken()) - ) - .addConsumerInPlatformThread(rel -> { - ApplicatonStore.getPermissionMenus().addAll(rel); - - }) - .addSupplierInExecutor(() -> { - - List allMenuList = ApplicatonStore.getAllMenu(); - Map> allMap = allMenuList.stream().collect(Collectors.groupingBy(MenuVO::getParentId)); - MenuVO rootMenu = allMenuList.stream().min(Comparator.comparing(MenuVO::getParentId)).get(); - - - List permissionInfoList = ApplicatonStore.getPermissionMenus(); - Map> permissionInfoMap = permissionInfoList.stream().collect(Collectors.groupingBy(MenuVO::getParentId)); - Map> permissonTitleMap = permissionInfoList.stream().collect(Collectors.groupingBy(MenuVO::getTitle)); - - for (MenuVO menu : allMap.get(rootMenu.getId())) { - - List childrenMenus = permissionInfoMap.get(menu.getId()); - - List partMenus = permissonTitleMap.get(menu.getTitle()); - if (childrenMenus == null && partMenus == null) { - - continue; - } - - MenuVoCell menuVoCell = new MenuVoCell(menu, childrenMenus); - - ApplicatonStore.getMenuVoCells().add(menuVoCell); - - } - return 0; - - }) - .addConsumerInPlatformThread(rel -> { - - try { - actionHandler.navigate(MainController.class); - } catch (Exception e) { - throw new RuntimeException(e); - } - }) - .onException(e -> { - e.printStackTrace(); - try { - actionHandler.navigate(LoginController.class); - } catch (VetoException vetoException) { - vetoException.printStackTrace(); - } catch (FlowException flowException) { - flowException.printStackTrace(); - } - }) - .run(); - } - - @PreDestroy - private void destroy() { - sequentialTransition.stop(); - } - - -} - - diff --git a/client/src/main/java/com/epri/fx/client/gui/uicomponents/main/MainController.java b/client/src/main/java/com/epri/fx/client/gui/uicomponents/main/MainController.java index 54fdc66..8c0cbbd 100644 --- a/client/src/main/java/com/epri/fx/client/gui/uicomponents/main/MainController.java +++ b/client/src/main/java/com/epri/fx/client/gui/uicomponents/main/MainController.java @@ -32,7 +32,6 @@ import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.geometry.Insets; import javafx.scene.Node; -import javafx.scene.control.ContentDisplay; import javafx.scene.control.Label; import javafx.scene.control.Tab; import javafx.scene.control.TabPane; diff --git a/client/src/main/resources/fxml/login/Untitled.fxml b/client/src/main/resources/fxml/login/Untitled.fxml deleted file mode 100644 index 49255fb..0000000 --- a/client/src/main/resources/fxml/login/Untitled.fxml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/client/src/main/resources/fxml/login/login.fxml b/client/src/main/resources/fxml/login/login.fxml index 516f76d..49255fb 100644 --- a/client/src/main/resources/fxml/login/login.fxml +++ b/client/src/main/resources/fxml/login/login.fxml @@ -4,102 +4,140 @@ - - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +