修改一些细节
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# fx-falsework
|
||||
基于javafx、spring boot 开发的客户端与服务端系统开发脚手架。本项目目的是帮助快速构建javafx系统,前后端分离,客户端UI提供明暗两种主题,与服务端通信用的是OpenFeign。服务端是标准的spring-boot工程。
|
||||
|
||||
#qq交流群:114697782
|
||||
|
||||
# 说明:
|
||||
|
||||
1.当前数据库为达梦数据库,可自行换其它数据库,在server端引入所用数据库jar,并修改server端application.yml相应配置即可
|
||||
@@ -16,7 +18,7 @@
|
||||
6.用户名:admin 密码:111111
|
||||
|
||||
7.提供明色和暗色两个主题
|
||||
|
||||
|
||||
# 界面:
|
||||
|
||||
登录
|
||||
|
||||
@@ -170,6 +170,16 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.16</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.squareup.sqldelight</groupId>-->
|
||||
<!-- <artifactId>gradle-plugin</artifactId>-->
|
||||
<!-- <version>1.0.0-alpha1</version>-->
|
||||
<!-- </dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>1.0.6</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.io.InputStream;
|
||||
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @description: 应用启动类
|
||||
* @className: AppStartup
|
||||
* @author: liwen
|
||||
* @date: 2019-08-26 16:24
|
||||
@@ -55,17 +55,12 @@ public class AppStartup extends Application {
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
|
||||
String keyPrefix = "";
|
||||
// //全局样式
|
||||
// setUserAgentStylesheet(null);
|
||||
// StyleManager.getInstance().addUserAgentStylesheet("css/app-light.css");
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
SVGGlyphLoader.loadGlyphsFont(AppStartup.class.getResourceAsStream("/fonts/icon_font/iconfont.svg"),
|
||||
ApplicatonStore.ICON_FONT_KEY);
|
||||
// SVGGlyphLoader.loadGlyphsFont(AppStartup.class.getResourceAsStream("/fonts/icon_font/icon-font-solid.svg"),
|
||||
// "IconFontSolid.svg");
|
||||
|
||||
} catch (IOException ioExc) {
|
||||
ioExc.printStackTrace();
|
||||
}
|
||||
@@ -83,15 +78,13 @@ public class AppStartup extends Application {
|
||||
wfxDecorator.setCustomMaximize(true);
|
||||
wfxDecorator.setGraphic(new SVGGlyph(""));
|
||||
|
||||
|
||||
|
||||
Scene scene = new Scene(wfxDecorator, 1000, 750);
|
||||
stage.setTitle("JavaFX Welcome");
|
||||
scene.setFill(Color.TRANSPARENT);
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
|
||||
|
||||
/*全局样式*/
|
||||
scene.getStylesheets().addAll(JFoenixResources.load("/css/app-fonts.css").toExternalForm(), AppStartup.class.getResource("/css/login.css").toExternalForm(), AppStartup.class.getResource("/css/app-light.css").toExternalForm());
|
||||
|
||||
}
|
||||
@@ -101,4 +94,8 @@ public class AppStartup extends Application {
|
||||
WSClient.getInstance().close();
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +77,10 @@ public class LoginController {
|
||||
@FXML
|
||||
private StackPane centerPane;
|
||||
|
||||
//正面视图
|
||||
/*正面视图*/
|
||||
@FXML
|
||||
public HBox loginPane;
|
||||
//反面视图
|
||||
/*反面视图*/
|
||||
@FXML
|
||||
public HBox registeredPane;
|
||||
@FXML
|
||||
@@ -113,11 +113,11 @@ public class LoginController {
|
||||
private JFXPasswordField rePwd2TextField;
|
||||
@FXML
|
||||
private RegexValidator regexValidatorPwd2;
|
||||
//翻转角度
|
||||
/*翻转角度*/
|
||||
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();
|
||||
@@ -128,9 +128,6 @@ public class LoginController {
|
||||
private DoubleProperty imageHeiht = new SimpleDoubleProperty();
|
||||
|
||||
|
||||
// @Inject
|
||||
// private WebSocketManagement webSocketManagement;
|
||||
|
||||
@FXML
|
||||
@ActionTrigger("login")
|
||||
private JFXButton loginBut;
|
||||
@@ -261,7 +258,7 @@ public class LoginController {
|
||||
logBack.fitWidthProperty().bind(imageWidth);
|
||||
imagePane.getChildren().add(new Label("", logBack));
|
||||
|
||||
String imgUrl=this.getClass().getClassLoader().getResource("").toURI().getPath()+"images/login";
|
||||
String imgUrl = this.getClass().getClassLoader().getResource("").toURI().getPath() + "images/login";
|
||||
System.err.println(imgUrl);
|
||||
List<File> files = Arrays.asList(new File(imgUrl).listFiles());
|
||||
|
||||
@@ -408,7 +405,7 @@ public class LoginController {
|
||||
ObjectRestResponse<String> rel = Request.connector(LoginFeign.class).login(jwtAuthenticationRequest);
|
||||
if (rel.getStatus() == 200) {
|
||||
WSClient.getInstance().addHeader("Authorization", rel.getData());
|
||||
WSClient.getInstance().addHeader("userName",userNameTextField.getText());
|
||||
WSClient.getInstance().addHeader("userName", userNameTextField.getText());
|
||||
WSClient.getInstance().connect();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
package PACKAGE_NAME;/**
|
||||
import javafx.application.Application;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
* @version: 0.0.1
|
||||
* @description:
|
||||
*
|
||||
* @description:
|
||||
* @className: TestSvg
|
||||
* @author: liwen
|
||||
* @date: 2021/2/5 09:42
|
||||
*/public class TestSvg {
|
||||
*/
|
||||
public class TestSvg extends Application {
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import com.intellij.openapi.util.IconLoader;
|
||||
import javafx.application.Application;
|
||||
import javafx.embed.swing.SwingNode;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
|
||||
|
||||
public class TigerExample extends Application {
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws MalformedURLException {
|
||||
primaryStage.setTitle("SVG Display sample");
|
||||
|
||||
// load the sample svg file
|
||||
InputStream svgFile =
|
||||
getClass().getResourceAsStream("/test.svg");
|
||||
Icon icon = IconLoader.getIcon("/test.svg");
|
||||
|
||||
SwingNode svgImage = new SwingNode();
|
||||
JLabel label=new JLabel(icon);
|
||||
label.setText("");
|
||||
svgImage.setContent(label);
|
||||
|
||||
StackPane stackPane=new StackPane(svgImage);
|
||||
Scene scene = new Scene(stackPane);
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
|
||||
<svg width="16px" height="16px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<g>
|
||||
<path id="svg_1"
|
||||
d="m20,18l-16,0l0,-10l16,0m0,-2l-8,0l-2,-2l-6,0c-1.11,0 -2,0.89 -2,2l0,12a2,2 0 0 0 2,2l16,0a2,2 0 0 0 2,-2l0,-10c0,-1.11 -0.9,-2 -2,-2z"
|
||||
fill="#FFC107"/>
|
||||
<ellipse stroke="#0f0f00" ry="2.4" rx="2.4" id="svg_5"
|
||||
cy="13.08624" cx="7.687954" stroke-width="0"
|
||||
fill="#80CBC4"/>
|
||||
</g>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="16px" height="16px" fill="#64B5F6">
|
||||
<path d="M22.623,13.746c.056-.177.1-.331.145-.484a50.624,50.624,0,0,1,1.645-5.168,1.831,1.831,0,0,1,1.6-1.274c.524-.056,1.08-.1,1.435.4a1.313,1.313,0,0,0,.879.564,2.391,2.391,0,0,1,.524.137c.234.089.323-.008.387-.226.2-.71.411-1.411.621-2.112.234-.8.234-.79-.54-1.064a1.217,1.217,0,0,0-.951-.016,1.269,1.269,0,0,1-1.492-.306,4.342,4.342,0,0,0-1.637-1.056A11.475,11.475,0,0,0,19.6,2.523a5.991,5.991,0,0,0-2.612.951,3.242,3.242,0,0,0-.306.274,14.318,14.318,0,0,1,3.112.032,2.507,2.507,0,0,1,1.774.911,3.774,3.774,0,0,1,.661,2.1,8.227,8.227,0,0,1-.4,3.032c-.306,1.048-.6,2.112-.895,3.161-.04.137-.073.258.113.306C21.567,13.439,22.075,13.585,22.623,13.746Z"
|
||||
/>
|
||||
<path d="M17.665,29.6a1.192,1.192,0,0,0,1.177-.645,3.335,3.335,0,0,0,.347-.863q1.161-4.8,2.306-9.611c.314-1.33.613-2.661.935-3.991.065-.258,0-.363-.25-.419-.339-.081-.677-.177-1.016-.282-.621-.185-.5-.161-.685.355Q18.193,20.66,15.9,27.17a1.925,1.925,0,0,0-.129.556A1.755,1.755,0,0,0,17.665,29.6Z"
|
||||
/>
|
||||
<path d="M2.023,10.255c.032.266.065.492.1.71.234,1.548.476,3.1.7,4.644s.46,3.12.685,4.676c.234,1.572.468,3.136.71,4.709.145.992.3,1.983.443,2.983.032.21.1.306.355.266q2.2-.363,4.4-.7c2.1-.331,4.185-.645,6.281-.976.081-.016.145-.113.218-.177-.089-.048-.194-.137-.274-.129-1.145.161-2.282.339-3.427.516-2.314.363-4.628.718-6.934,1.088-.242.04-.323-.016-.355-.25-.137-1.008-.282-2.008-.435-3.007-.331-2.225-.677-4.451-1.008-6.668-.363-2.419-.718-4.846-1.088-7.273-.04-.266.048-.387.314-.419.468-.065.935-.145,1.395-.218,1.9-.306,3.806-.621,5.708-.927L14.8,8.279c1.548-.25,3.088-.5,4.636-.758.726-.121,1.443-.234,2.169-.371.089-.016.153-.145.226-.218-.1-.04-.194-.081-.29-.113-.024-.008-.056.008-.089.016-.9.153-1.806.306-2.7.452-1.9.314-3.806.621-5.708.935-1.774.29-3.548.589-5.321.879-1.822.3-3.644.6-5.467.895C2.055,10.029,1.95,10.085,2.023,10.255Z"
|
||||
/>
|
||||
<path d="M25,7.578a.876.876,0,0,1-.145-.008,2.651,2.651,0,0,0-.073.613c.089.653.218,1.306.323,1.959.29,1.75.581,3.507.871,5.257s.581,3.507.879,5.257c.185,1.121.379,2.241.564,3.354.032.169,0,.29-.21.323l-4.644.726q-1.1.169-2.2.363c-.065.008-.121.113-.177.177.081.04.153.113.226.113.234-.016.46-.056.685-.089l5.144-.822c.516-.081,1.024-.169,1.58-.258Q26.421,16.04,25,7.578Z"
|
||||
/>
|
||||
<path d="M18.882,17.737a.3.3,0,0,0,.024-.476c-.508-.6-1-1.209-1.508-1.814-1.411-1.7-2.83-3.411-4.241-5.12a1.157,1.157,0,0,1-.242-.5.759.759,0,0,1,.516-.8.814.814,0,0,1,.984.323c1.387,1.661,2.782,3.322,4.168,4.983.331.4.669.79,1.016,1.2a.3.3,0,0,0,.024-.476c-.556-.661-1.113-1.33-1.669-1.991-1.121-1.338-2.233-2.677-3.362-4a1.115,1.115,0,0,0-1.637-.121,1.051,1.051,0,0,0-.056,1.58q2.612,3.157,5.225,6.305C18.374,17.14,18.624,17.43,18.882,17.737Z"
|
||||
/>
|
||||
<path d="M13.319,14.342a1.154,1.154,0,0,0-.194-.129c-.556-.21-1.113-.4-1.669-.613-.177-.065-.258,0-.323.153Q9.61,17.5,8.086,21.244c-.081.185-.024.274.145.339.524.21,1.048.411,1.564.645.282.129.4.065.5-.218.968-2.475,1.951-4.942,2.927-7.41C13.246,14.544,13.27,14.463,13.319,14.342Z"
|
||||
/>
|
||||
<path d="M18.632,17.8c-.4-.508-.774-.927-1.08-1.379-.274-.419-.581-.637-1.088-.427a1.555,1.555,0,0,1-.387.065l-3.233.556a.422.422,0,0,0-.387.274c-.21.6-.435,1.185-.653,1.782a1.449,1.449,0,0,0-.04.258C14.061,18.559,16.3,18.188,18.632,17.8Z"
|
||||
/>
|
||||
<path d="M9.57,17.084c-1.322.218-2.58.419-3.878.629.089.6.185,1.177.25,1.758.032.25.137.282.363.25.661-.1,1.33-.194,2-.274a.457.457,0,0,0,.411-.29c.242-.581.5-1.161.75-1.742C9.505,17.318,9.521,17.237,9.57,17.084Z"
|
||||
/>
|
||||
<path d="M23.744,22.115c-.79-.484-1.572-.959-2.427-1.475.032.153.016.331.1.419a1.949,1.949,0,0,0,.54.419c.274.153.564.258.847.4a1.071,1.071,0,0,1,.71.992.79.79,0,0,0,.073.25l.081-.04A.443.443,0,0,0,23.72,23a2.729,2.729,0,0,0,.306-2.314,3.074,3.074,0,0,0-1.532-2.137c-.242-.121-.4-.016-.572.1a.5.5,0,0,0-.242.556A1.859,1.859,0,0,0,22,18.995c.2-.21.387-.161.613-.016A3.213,3.213,0,0,1,23.744,22.115Z"
|
||||
/>
|
||||
<path d="M7.53,25.493a.493.493,0,0,0,.1.04c.8-1,1.6-2,2.419-3.024-.121-.065-.194-.113-.274-.145-.516-.21-1.032-.4-1.54-.621-.242-.1-.314-.032-.331.218-.065.677-.145,1.355-.218,2.04C7.627,24.5,7.578,25,7.53,25.493Z"
|
||||
/>
|
||||
<path d="M12.73,11.593a1.044,1.044,0,0,0-.951.653c-.121.3-.234.6-.371.887-.081.169-.056.274.137.339.54.185,1.08.387,1.613.6.194.073.274.008.347-.161.121-.306.258-.613.387-.919a.739.739,0,0,0-.274-1A6.3,6.3,0,0,0,12.73,11.593Z"
|
||||
/>
|
||||
<path d="M22.188,17.156c.677-.089,1.346-.177,2.008-.282.056-.008.129-.153.121-.218-.081-.532-.177-1.072-.29-1.6a.317.317,0,0,0-.234-.194c-.339.024-.677.073-1.016.129-.169.024-.29.1-.194.347.306-.04.621-.089.935-.113.073-.008.21.056.218.1.089.4.153.822.234,1.25-.524.073-1.016.137-1.5.2C22.293,16.81,22.131,16.85,22.188,17.156Z"
|
||||
/>
|
||||
<path d="M22.623,13.746c-.54-.161-1.056-.306-1.564-.452-.185-.056-.153-.169-.113-.306.3-1.056.589-2.112.895-3.161a8.249,8.249,0,0,0,.4-3.032,3.731,3.731,0,0,0-.661-2.1A2.507,2.507,0,0,0,19.8,3.788a14.313,14.313,0,0,0-3.112-.032c.1-.089.194-.194.306-.274a5.991,5.991,0,0,1,2.612-.951,11.559,11.559,0,0,1,5.636.613A4.247,4.247,0,0,1,26.88,4.2a1.269,1.269,0,0,0,1.492.306,1.217,1.217,0,0,1,.951.016c.774.274.774.266.54,1.064-.21.7-.419,1.4-.621,2.112-.065.218-.153.306-.387.226a2.391,2.391,0,0,0-.524-.137,1.243,1.243,0,0,1-.879-.564,1.4,1.4,0,0,0-1.435-.4,1.831,1.831,0,0,0-1.6,1.274,50.624,50.624,0,0,0-1.645,5.168C22.728,13.415,22.68,13.56,22.623,13.746Z"
|
||||
/>
|
||||
<path d="M17.665,29.6a1.755,1.755,0,0,1-1.895-1.871,1.925,1.925,0,0,1,.129-.556q2.286-6.519,4.588-13.021c.177-.516.065-.532.685-.355.339.1.677.2,1.016.282.25.056.314.161.25.419-.323,1.33-.621,2.661-.935,3.991q-1.149,4.8-2.306,9.611a3.335,3.335,0,0,1-.347.863A1.218,1.218,0,0,1,17.665,29.6Z"
|
||||
/>
|
||||
<path d="M2.023,10.255c-.073-.169.032-.226.242-.258,1.822-.29,3.644-.6,5.467-.895,1.774-.29,3.548-.589,5.321-.879,1.9-.314,3.806-.621,5.708-.935.9-.145,1.806-.3,2.7-.452.032-.008.065-.024.089-.016.1.032.194.073.29.113-.073.073-.137.2-.226.218-.718.137-1.443.25-2.169.371-1.548.25-3.088.5-4.636.758L9.82,9.1q-2.854.472-5.708.927c-.468.073-.927.161-1.395.218-.266.032-.355.153-.314.419.371,2.419.726,4.846,1.088,7.273.331,2.225.677,4.451,1.008,6.668.153,1,.3,2.008.435,3.007.032.234.1.29.355.25,2.306-.371,4.62-.726,6.934-1.088,1.145-.177,2.282-.355,3.427-.516.081-.008.185.081.274.129-.073.065-.137.161-.218.177q-3.132.5-6.281.976-2.2.339-4.4.7c-.25.04-.323-.056-.355-.266-.145-.992-.29-1.983-.443-2.983-.234-1.572-.476-3.136-.71-4.709-.234-1.556-.46-3.12-.685-4.676l-.7-4.644C2.088,10.746,2.055,10.529,2.023,10.255Z"
|
||||
/>
|
||||
<path d="M25,7.578l2.838,16.98c-.556.089-1.064.177-1.58.258l-5.144.822c-.226.032-.46.073-.685.089-.073.008-.153-.073-.226-.113.056-.065.113-.161.177-.177q1.1-.194,2.2-.363c1.548-.242,3.1-.492,4.644-.726.21-.032.234-.153.21-.323-.185-1.121-.379-2.233-.564-3.354-.29-1.75-.581-3.507-.879-5.257s-.581-3.507-.871-5.257C25.01,9.5,24.889,8.852,24.8,8.2a2.757,2.757,0,0,1,.073-.613A.651.651,0,0,1,25,7.578Z"
|
||||
/>
|
||||
<path d="M18.882,17.737c-.258-.306-.508-.6-.758-.9q-2.612-3.157-5.225-6.305a1.051,1.051,0,0,1,.056-1.58,1.1,1.1,0,0,1,1.637.121c1.129,1.322,2.241,2.669,3.362,4,.556.661,1.1,1.33,1.669,1.991a.3.3,0,0,1-.024.476c-.347-.411-.685-.806-1.016-1.2C17.2,12.673,15.8,11.013,14.415,9.352a.8.8,0,0,0-.984-.323.75.75,0,0,0-.516.8,1,1,0,0,0,.242.5c1.411,1.709,2.822,3.411,4.241,5.12.5.6,1,1.209,1.508,1.814A.3.3,0,0,1,18.882,17.737Z"
|
||||
/>
|
||||
<path d="M13.319,14.342c-.04.121-.065.194-.1.274-.976,2.467-1.959,4.934-2.927,7.41-.113.282-.218.347-.5.218-.508-.234-1.04-.435-1.564-.645-.177-.073-.226-.153-.145-.339q1.536-3.737,3.048-7.49c.065-.161.145-.226.323-.153.556.21,1.113.4,1.669.613A.675.675,0,0,1,13.319,14.342Zm-1.9-.4c-.137.347-.266.653-.387.959q-1.246,3.06-2.5,6.12c-.1.242-.048.339.177.419a9.788,9.788,0,0,1,.951.387c.242.121.339.073.435-.177.629-1.613,1.266-3.217,1.911-4.83.306-.766.6-1.532.919-2.33C12.416,14.31,11.94,14.133,11.416,13.939Z"
|
||||
/>
|
||||
<path d="M18.632,17.8c-2.33.387-4.572.75-6.861,1.129a1.585,1.585,0,0,1,.04-.258c.218-.6.452-1.185.653-1.782a.411.411,0,0,1,.387-.274l3.233-.556A2.042,2.042,0,0,0,16.471,16c.508-.2.806.016,1.088.427C17.858,16.882,18.229,17.293,18.632,17.8Zm-6.418.734c1.967-.323,3.878-.645,5.829-.968-.347-.435-.645-.822-.959-1.2a.373.373,0,0,0-.282-.089c-.282.032-.556.081-.83.129-.959.161-1.919.323-2.87.5-.121.024-.3.1-.339.194C12.561,17.551,12.4,18.019,12.214,18.535Z"
|
||||
/>
|
||||
<path d="M9.57,17.084c-.048.153-.073.234-.1.314-.25.581-.508,1.161-.75,1.742a.437.437,0,0,1-.411.29c-.669.081-1.33.169-2,.274-.226.032-.331,0-.363-.25-.073-.572-.161-1.145-.25-1.758C6.99,17.5,8.247,17.3,9.57,17.084Zm-.5.411c-.968.153-1.862.29-2.741.443-.089.016-.234.161-.234.234a7.733,7.733,0,0,0,.161,1.04.278.278,0,0,0,.218.145c.548-.065,1.1-.137,1.637-.226a.446.446,0,0,0,.3-.153C8.642,18.511,8.836,18.027,9.07,17.495Z"
|
||||
/>
|
||||
<path d="M23.744,22.115a3.175,3.175,0,0,0-1.129-3.12.413.413,0,0,0-.613.016,2.461,2.461,0,0,1-.323.218.5.5,0,0,1,.242-.556.487.487,0,0,1,.572-.1A3.074,3.074,0,0,1,24.026,20.7a2.729,2.729,0,0,1-.306,2.314.443.443,0,0,1-.056.073c-.016.016-.032.016-.081.04a1.078,1.078,0,0,1-.073-.25,1.071,1.071,0,0,0-.71-.992c-.282-.137-.581-.242-.847-.4a1.983,1.983,0,0,1-.54-.419c-.081-.089-.065-.266-.1-.419C22.172,21.155,22.954,21.631,23.744,22.115Z"
|
||||
/>
|
||||
<path d="M7.53,25.493c.048-.5.089-.992.145-1.492.073-.677.161-1.355.218-2.04.024-.25.089-.323.331-.218.508.218,1.024.411,1.54.621.081.032.153.081.274.145-.822,1.024-1.621,2.024-2.419,3.024A.786.786,0,0,1,7.53,25.493Zm.411-.935c.024.008.048.008.065.016.508-.645,1.008-1.282,1.532-1.951-.476-.185-.887-.347-1.33-.524C8.118,22.953,8.03,23.76,7.941,24.558Z"
|
||||
/>
|
||||
<path d="M12.73,11.593a5.524,5.524,0,0,1,.887.4.739.739,0,0,1,.274,1c-.129.306-.266.6-.387.919-.065.169-.153.234-.347.161-.532-.21-1.072-.4-1.613-.6-.194-.065-.21-.169-.137-.339.129-.29.242-.6.371-.887A1.031,1.031,0,0,1,12.73,11.593Zm-.984,1.6c.468.177.911.347,1.346.492.048.016.161-.056.194-.121.113-.234.2-.476.314-.718a.4.4,0,0,0-.137-.556,2.65,2.65,0,0,0-.734-.3.52.52,0,0,0-.629.339C11.98,12.609,11.876,12.875,11.747,13.2Z"
|
||||
/>
|
||||
<path d="M22.188,17.156c-.065-.306.1-.347.282-.371.484-.065.968-.129,1.5-.2-.081-.427-.145-.839-.234-1.25-.008-.048-.145-.113-.218-.1-.314.024-.629.073-.935.113-.089-.25.032-.323.194-.347.339-.048.677-.1,1.016-.129a.3.3,0,0,1,.234.194q.169.8.29,1.6c.008.065-.073.21-.121.218C23.534,16.979,22.873,17.06,22.188,17.156Z"
|
||||
/>
|
||||
<path d="M11.416,13.939c.524.194,1,.363,1.508.548-.314.8-.621,1.564-.919,2.33-.637,1.613-1.282,3.217-1.911,4.83-.1.25-.2.3-.435.177a8.107,8.107,0,0,0-.951-.387c-.226-.081-.274-.177-.177-.419q1.258-3.06,2.5-6.12C11.15,14.592,11.271,14.286,11.416,13.939Z"
|
||||
/>
|
||||
<path d="M12.214,18.535c.194-.516.347-.976.54-1.427.04-.1.218-.169.339-.194.959-.177,1.919-.339,2.87-.5.274-.048.556-.1.83-.129a.384.384,0,0,1,.282.089c.314.379.621.766.959,1.2C16.092,17.89,14.182,18.2,12.214,18.535Z"
|
||||
/>
|
||||
<path d="M9.07,17.495c-.234.532-.427,1.016-.661,1.475a.446.446,0,0,1-.3.153c-.54.089-1.088.161-1.637.226-.073.008-.21-.081-.218-.145a7.354,7.354,0,0,1-.161-1.04c-.008-.073.137-.218.234-.234C7.207,17.785,8.1,17.648,9.07,17.495Z"
|
||||
/>
|
||||
<path d="M7.941,24.558c.089-.806.177-1.6.274-2.459.435.169.855.339,1.33.524-.524.669-1.032,1.306-1.532,1.951A.235.235,0,0,1,7.941,24.558Z"
|
||||
/>
|
||||
<path d="M11.747,13.2c.129-.323.234-.589.355-.855A.524.524,0,0,1,12.73,12a2.424,2.424,0,0,1,.734.3.406.406,0,0,1,.137.556c-.1.234-.2.484-.314.718-.032.056-.145.137-.194.121C12.65,13.544,12.214,13.375,11.747,13.2Z"
|
||||
/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 624 B After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
||||
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
|
||||
<svg width="16px" height="16px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<g>
|
||||
<path id="svg_1"
|
||||
d="m20,18l-16,0l0,-10l16,0m0,-2l-8,0l-2,-2l-6,0c-1.11,0 -2,0.89 -2,2l0,12a2,2 0 0 0 2,2l16,0a2,2 0 0 0 2,-2l0,-10c0,-1.11 -0.9,-2 -2,-2z"
|
||||
fill="#FFC107"/>
|
||||
<ellipse stroke="#0f0f00" ry="2.4" rx="2.4" id="svg_5"
|
||||
cy="13.08624" cx="7.687954" stroke-width="0"
|
||||
fill="#80CBC4"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 0 B After Width: | Height: | Size: 624 B |
@@ -25,4 +25,9 @@ public interface ElementMapper {
|
||||
|
||||
List<Element> selectAuthorityElementByUserId(@Param("userId") String userId);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -19,6 +19,14 @@ import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* @author liwen
|
||||
* @Description: WebSocketMessageHandler
|
||||
* @param:
|
||||
* @return:
|
||||
* @auther: liwen
|
||||
* @date: 2021/2/4 9:27 下午
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
@@ -28,8 +36,10 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
*/
|
||||
private static ConcurrentHashMap<String, WebSocketSession> WEBSOCKET_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
//静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
|
||||
private static AtomicInteger onlineNum = new AtomicInteger();
|
||||
/**
|
||||
* 静态变量,用来记录当前在线连接数。应该把它设计成线程安全的。
|
||||
*/
|
||||
private static final AtomicInteger ONLINE_NUM = new AtomicInteger();
|
||||
@Autowired
|
||||
private SysLoginInfoService sysLoginInfoService;
|
||||
|
||||
@@ -39,17 +49,19 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
@Override
|
||||
public void afterConnectionEstablished(WebSocketSession session) throws Exception {
|
||||
log.info("建立连接成功");
|
||||
String userId = (String) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_ID);//将在拦截器中保存的用户的名字取出来,然后作为 key 存到 map 中
|
||||
/* 将在拦截器中保存的用户的名字取出来,然后作为 key 存到 map 中 */
|
||||
String userId = (String) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_ID);
|
||||
SysLoginInfor sysLoginInfor = (SysLoginInfor) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_LIST);
|
||||
|
||||
if (userId != null) {
|
||||
WEBSOCKET_MAP.put(userId, session);//保存当前的连接和用户之间的关系
|
||||
// 在线数加1
|
||||
/* 保存当前的连接和用户之间的关系 */
|
||||
WEBSOCKET_MAP.put(userId, session);
|
||||
/* 在线数加1 */
|
||||
addOnlineCount();
|
||||
log.info("客户端" + sysLoginInfor.getLoginName() + "加入,当前在线数为:" + onlineNum.get());
|
||||
log.info("客户端" + sysLoginInfor.getLoginName() + "加入,当前在线数为:" + ONLINE_NUM.get());
|
||||
sendMessageToUser(userId, new TextMessage(userId + "WebSocket连接成功"));
|
||||
}
|
||||
// 这块会实现自己业务,比如,当用户登录后,会把离线消息推送给用户
|
||||
/* 这块会实现自己业务,比如,当用户登录后,会把离线消息推送给用户 */
|
||||
|
||||
}
|
||||
|
||||
@@ -76,16 +88,20 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* 给某个用户发送消息
|
||||
*
|
||||
* @param userId
|
||||
* @param message
|
||||
* @Description: 给某个用户发送消息
|
||||
* @param: [userId, message]
|
||||
* @return: void
|
||||
* @auther: liwen
|
||||
* @date: 2021/2/4 9:27 下午
|
||||
*/
|
||||
public void sendMessageToUser(String userId, TextMessage message) {
|
||||
WebSocketSession webSocketSession = WEBSOCKET_MAP.get(userId);//根据接收方的名字找到对应的连接
|
||||
if (webSocketSession != null && webSocketSession.isOpen()) {//如果没有离线,如果离线,请根据实际业务需求来处理,可能会需要保存离线消息
|
||||
/* 根据接收方的名字找到对应的连接 */
|
||||
WebSocketSession webSocketSession = WEBSOCKET_MAP.get(userId);
|
||||
//如果没有离线,如果离线,请根据实际业务需求来处理,可能会需要保存离线消息
|
||||
if (webSocketSession != null && webSocketSession.isOpen()) {
|
||||
try {
|
||||
webSocketSession.sendMessage(message);//发送消息
|
||||
/* 发送消息 */
|
||||
webSocketSession.sendMessage(message);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
@@ -93,14 +109,17 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* 给所有在线用户发送消息,此处以文本消息为例子
|
||||
*
|
||||
* @param message
|
||||
* @Description: 给所有在线用户发送消息, 此处以文本消息为例子
|
||||
* @param: [message]
|
||||
* @return: void
|
||||
* @auther: liwen
|
||||
* @date: 2021/2/4 9:29 下午
|
||||
*/
|
||||
public void sendMessageToUsers(TextMessage message) {
|
||||
for (Map.Entry<String, WebSocketSession> webSocketSessionEntry : WEBSOCKET_MAP.entrySet()) {//获取所有的连接
|
||||
|
||||
WebSocketSession session = webSocketSessionEntry.getValue();//找到每个连接
|
||||
/* 获取所有的连接 */
|
||||
for (Map.Entry<String, WebSocketSession> webSocketSessionEntry : WEBSOCKET_MAP.entrySet()) {
|
||||
/* 找到每个连接 */
|
||||
WebSocketSession session = webSocketSessionEntry.getValue();
|
||||
if (session != null && session.isOpen()) {
|
||||
try {
|
||||
session.sendMessage(message);
|
||||
@@ -126,9 +145,9 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
}
|
||||
|
||||
log.error("WebSocket发生错误");
|
||||
|
||||
WEBSOCKET_MAP.remove(userId);//移除连接
|
||||
// 在线数减1
|
||||
/* 移除连接 */
|
||||
WEBSOCKET_MAP.remove(userId);
|
||||
/* 在线数减1 */
|
||||
subOnlineCount();
|
||||
|
||||
SysLoginInfor sysLoginInfor = (SysLoginInfor) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_LIST);
|
||||
@@ -146,17 +165,18 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
*/
|
||||
@Override
|
||||
public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception {
|
||||
String userId = (String) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_ID);//找到用户对应的连接
|
||||
/* 找到用户对应的连接 */
|
||||
String userId = (String) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_ID);
|
||||
|
||||
// 从map中删除
|
||||
/* 从map中删除 */
|
||||
WEBSOCKET_MAP.remove(userId);
|
||||
// 在线数减1
|
||||
/* 在线数减1 */
|
||||
subOnlineCount();
|
||||
SysLoginInfor sysLoginInfor = (SysLoginInfor) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_LIST);
|
||||
sysLoginInfor.setStatus("1");
|
||||
sysLoginInfor.setMsg("退出登录");
|
||||
sysLoginInfoService.addSysJobLog(sysLoginInfor);
|
||||
log.info("[" + sysLoginInfor.getLoginName() + "]连接关闭,当前在线数为:" + onlineNum.get());
|
||||
log.info("[" + sysLoginInfor.getLoginName() + "]连接关闭,当前在线数为:" + ONLINE_NUM.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -169,15 +189,15 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
* 有人上线时在线人数加一
|
||||
*/
|
||||
private static synchronized void addOnlineCount() {
|
||||
onlineNum.incrementAndGet();
|
||||
ONLINE_NUM.incrementAndGet();
|
||||
}
|
||||
|
||||
/**
|
||||
* 有人下线时在线人数减一
|
||||
*/
|
||||
private static void subOnlineCount() {
|
||||
if (onlineNum.get() > 0) {
|
||||
onlineNum.decrementAndGet();
|
||||
if (ONLINE_NUM.get() > 0) {
|
||||
ONLINE_NUM.decrementAndGet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -185,9 +205,10 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
|
||||
public List<SysLoginInfor> getOnlineUsers() {
|
||||
List<SysLoginInfor> onlineUsers = new ArrayList<>();
|
||||
for (Map.Entry<String, WebSocketSession> webSocketSessionEntry : WEBSOCKET_MAP.entrySet()) {//获取所有的连接
|
||||
|
||||
WebSocketSession session = webSocketSessionEntry.getValue();//找到每个连接
|
||||
/* 获取所有的连接 */
|
||||
for (Map.Entry<String, WebSocketSession> webSocketSessionEntry : WEBSOCKET_MAP.entrySet()) {
|
||||
/* 找到每个连接 */
|
||||
WebSocketSession session = webSocketSessionEntry.getValue();
|
||||
if (session != null && session.isOpen()) {
|
||||
SysLoginInfor sysLoginInfor = (SysLoginInfor) session.getAttributes().get(CommonConstants.WEB_SOCKET_USER_LIST);
|
||||
onlineUsers.add(sysLoginInfor);
|
||||
@@ -197,7 +218,8 @@ public class WebSocketMessageHandler extends TextWebSocketHandler {
|
||||
}
|
||||
|
||||
public boolean retreat(String userId) {
|
||||
WebSocketSession webSocketSession = WEBSOCKET_MAP.get(userId);//根据接收方的名字找到对应的连接
|
||||
/* 根据接收方的名字找到对应的连接 */
|
||||
WebSocketSession webSocketSession = WEBSOCKET_MAP.get(userId);
|
||||
try {
|
||||
webSocketSession.close();
|
||||
return true;
|
||||
|
||||
@@ -321,4 +321,5 @@
|
||||
where menu_id = #{menuId,jdbcType=INTEGER}
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user