cn.hutool
@@ -157,25 +165,60 @@
- org.openjfx
+ com.zenjava
javafx-maven-plugin
- 0.0.8
+ 8.8.3
+
+ analysis
+ top.octopusyan.YanFrpLuncher
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.2.0
-
- default-cli
-
- top.octopusyan/top.octopusyan.YanFrpLauncher
- app
- app
- app
- true
- true
- true
-
+ make-assembly
+
+ package
+
+
+ single
+
+
+
+
+ top.octopusyan.YanFrpLuncher
+
+
+
+ jar-with-dependencies
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/top/octopusyan/YanFrpApplication.java b/src/main/java/top/octopusyan/YanFrpApplication.java
index 9f0e6ca..0912428 100644
--- a/src/main/java/top/octopusyan/YanFrpApplication.java
+++ b/src/main/java/top/octopusyan/YanFrpApplication.java
@@ -1,21 +1,25 @@
package top.octopusyan;
-import com.sun.org.slf4j.internal.Logger;
-import com.sun.org.slf4j.internal.LoggerFactory;
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
+import javafx.fxml.JavaFXBuilderFactory;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
-import top.octopusyan.common.http.HttpConfig;
-import top.octopusyan.common.http.config.LogStrategy;
-import top.octopusyan.common.http.request.RequestHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import top.octopusyan.base.BaseController;
+import top.octopusyan.manager.http.HttpConfig;
+import top.octopusyan.manager.http.config.LogStrategy;
+import top.octopusyan.manager.http.request.RequestHandler;
import top.octopusyan.http.OkHttpClientConfig;
import top.octopusyan.utils.AlertUtil;
import top.octopusyan.utils.ApplicatonStore;
+import top.octopusyan.utils.FrpUtil;
+import top.octopusyan.utils.FxmlUtil;
/**
* @author : octopus yan
@@ -24,12 +28,15 @@ import top.octopusyan.utils.ApplicatonStore;
* @create : 2022-3-29 15:00
*/
public class YanFrpApplication extends Application {
- private static final Logger LOGGER = LoggerFactory.getLogger(YanFrpApplication.class);
+ private static final Logger logger = LoggerFactory.getLogger(YanFrpApplication.class);
@Override
public void init() throws Exception {
super.init();
- LOGGER.debug("init...");
+ logger.info("init...");
+
+ // 初始化frp客户端临时文件
+ FrpUtil.initFrpc();
// 网络请求设置
HttpConfig.with(OkHttpClientConfig.httpClient())
@@ -49,7 +56,7 @@ public class YanFrpApplication extends Application {
@Override
public void start(Stage stage) {
- LOGGER.debug("start...");
+ logger.info("start...");
// TODO 全局异常处理... (emm有点草率,先这样了。。)
Thread.setDefaultUncaughtExceptionHandler((t, e) -> Platform.runLater(() -> showErrorDialog(t, e)));
@@ -61,8 +68,12 @@ public class YanFrpApplication extends Application {
ApplicatonStore.setRegisterSuccess(false);
try {
+ // 静态写法无法获取controler
+// StackPane root = new FXMLLoader(this.getClass().getResource("/fxml/login.fxml")).load();//底层面板
+ FXMLLoader fxmlLoader = FxmlUtil.init("/fxml/login.fxml");
+
+ StackPane root = fxmlLoader.load();//底层面板
stage.initStyle(StageStyle.TRANSPARENT);
- StackPane root = new FXMLLoader(this.getClass().getResource("/fxml/login.fxml")).load();//底层面板
Scene scene = new Scene(
root,
root.getPrefWidth() + 20,
@@ -73,22 +84,26 @@ public class YanFrpApplication extends Application {
stage.setScene(scene);
stage.show();
+ BaseController controller = fxmlLoader.getController();
+ controller.setApplication(this);
+
} catch (Throwable t) {
showErrorDialog(Thread.currentThread(), t);
}
- LOGGER.debug("start end...");
+ logger.debug("start end...");
}
private void showErrorDialog(Thread t, Throwable e) {
e.printStackTrace();
- AlertUtil.exceptionAlert(new Exception(e)).show();
+ Platform.runLater(() -> AlertUtil.exceptionAlert(new Exception(e)).show());
}
@Override
public void stop() throws Exception {
super.stop();
- LOGGER.debug("stop...");
+ FrpUtil.clearTmp();
+ logger.info("stop...");
}
public static void main(String[] args) {
diff --git a/src/main/java/top/octopusyan/YanFrpLuncher.java b/src/main/java/top/octopusyan/YanFrpLuncher.java
new file mode 100644
index 0000000..76db4fe
--- /dev/null
+++ b/src/main/java/top/octopusyan/YanFrpLuncher.java
@@ -0,0 +1,33 @@
+package top.octopusyan;
+
+import javafx.application.Application;
+import javafx.application.Platform;
+import javafx.fxml.FXMLLoader;
+import javafx.scene.Scene;
+import javafx.scene.layout.StackPane;
+import javafx.scene.paint.Color;
+import javafx.stage.Stage;
+import javafx.stage.StageStyle;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import top.octopusyan.base.BaseController;
+import top.octopusyan.http.OkHttpClientConfig;
+import top.octopusyan.manager.http.HttpConfig;
+import top.octopusyan.manager.http.config.LogStrategy;
+import top.octopusyan.manager.http.request.RequestHandler;
+import top.octopusyan.utils.AlertUtil;
+import top.octopusyan.utils.ApplicatonStore;
+import top.octopusyan.utils.FrpUtil;
+import top.octopusyan.utils.FxmlUtil;
+
+/**
+ * @author : octopus yan
+ * @email : octopus_yan@foxmail.com
+ * @description : YanFrp Application
+ * @create : 2022-3-29 15:00
+ */
+public class YanFrpLuncher {
+ public static void main(String[] args) {
+ Application.launch(YanFrpApplication.class, args);
+ }
+}
diff --git a/src/main/java/top/octopusyan/base/BaseController.java b/src/main/java/top/octopusyan/base/BaseController.java
index cef2045..174ac65 100644
--- a/src/main/java/top/octopusyan/base/BaseController.java
+++ b/src/main/java/top/octopusyan/base/BaseController.java
@@ -1,6 +1,7 @@
package top.octopusyan.base;
import com.jfoenix.controls.JFXButton;
+import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
@@ -11,6 +12,7 @@ import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
+import top.octopusyan.utils.FxmlUtil;
import top.octopusyan.utils.Loading;
import java.io.IOException;
@@ -25,21 +27,35 @@ import java.util.ResourceBundle;
*/
public abstract class BaseController implements Initializable {
+ private Application application;
+
private double xOffSet = 0, yOffSet = 0;
private volatile Loading loading;
- public void jumpTo(BaseController
controller){
+ public void jumpTo(BaseController
controller) throws IOException {
+ FXMLLoader fxmlLoader = FxmlUtil.init(controller.getRootFxmlPath());
+
Scene scene = getRootPanel().getScene();
- try {
- Pane root = FXMLLoader.load(getClass().getResource(controller.getRootFxmlPath()));
- scene.setRoot(root);
- Stage stage = (Stage) scene.getWindow();
- stage.setWidth(root.getPrefWidth() + 20);
- stage.setHeight(root.getPrefHeight() + 20);
- } catch (IOException e) {
- e.printStackTrace();
- }
+ double oldHeight = getRootPanel().getPrefHeight();
+ double oldWidth = getRootPanel().getPrefWidth();
+
+ Pane root = fxmlLoader.load();
+ Stage stage = (Stage) scene.getWindow();
+ // 窗口大小
+ double newWidth = root.getPrefWidth() + 20;
+ double newHeight = root.getPrefHeight() + 20;
+ // 窗口位置
+ double newX = stage.getX() - (newWidth - oldWidth) / 2;
+ double newY = stage.getY() - (newHeight - oldHeight) / 2;
+ scene.setRoot(root);
+ stage.setX(newX < 0 ? 0 : newX);
+ stage.setY(newY < 0 ? 0 : newY);
+ stage.setWidth(newWidth);
+ stage.setHeight(newHeight);
+
+ controller = fxmlLoader.getController();
+ controller.setApplication(getApplication());
}
@Override
@@ -86,21 +102,29 @@ public abstract class BaseController
implements Initializable {
initViewAction();
}
- public void showLoading(){
+ public void showLoading() {
showLoading(null);
}
- public void showLoading(String message){
- if(loading == null) loading = new Loading((Stage) getRootPanel().getScene().getWindow());
- if(!StringUtils.isEmpty(message))loading.showMessage(message);
+ public void showLoading(String message) {
+ if (loading == null) loading = new Loading((Stage) getRootPanel().getScene().getWindow());
+ if (!StringUtils.isEmpty(message)) loading.showMessage(message);
loading.show();
}
- public boolean isLoadShowing(){
+ public void setApplication(Application application) {
+ this.application = application;
+ }
+
+ public Application getApplication() {
+ return application;
+ }
+
+ public boolean isLoadShowing() {
return loading != null && loading.showing();
}
- public void stopLoading(){
+ public void stopLoading() {
loading.closeStage();
}
@@ -159,11 +183,16 @@ public abstract class BaseController
implements Initializable {
/**
* 关闭窗口
*/
- public void onDestroy(){
+ public void onDestroy() {
Stage stage = (Stage) getRootPanel().getScene().getWindow();
stage.hide();
stage.close();
- Platform.exit();
- System.exit(0);
+ try {
+ Thread.sleep(2000);
+ Platform.exit();
+ System.exit(0);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
}
}
diff --git a/src/main/java/top/octopusyan/common/test.java b/src/main/java/top/octopusyan/common/test.java
deleted file mode 100644
index 98369f9..0000000
--- a/src/main/java/top/octopusyan/common/test.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package top.octopusyan.common;
-
-/**
- * @author : octopus yan
- * @email : octopus_yan@foxmail.com
- * @description : test
- * @create : 2022-4-1 23:36
- */
-public class test {
-}
diff --git a/src/main/java/top/octopusyan/config/ProxyConfig.java b/src/main/java/top/octopusyan/config/ProxyConfig.java
index a078d12..c7b34f9 100644
--- a/src/main/java/top/octopusyan/config/ProxyConfig.java
+++ b/src/main/java/top/octopusyan/config/ProxyConfig.java
@@ -1,5 +1,9 @@
package top.octopusyan.config;
+import lombok.Getter;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@@ -10,14 +14,19 @@ import java.util.Map;
* @create : 2022-4-5 18:14
*/
public class ProxyConfig {
- private static Map serverPath = new HashMap<>();
- private static Map typePort = new HashMap<>();
+ private static final Map serverPath = new HashMap<>();
+ private static final Map serverIp = new HashMap<>();
+ private static final Map typePort = new HashMap<>();
static {
serverPath.put("香港", "xg.frp.octopusyan.top");
serverPath.put("北京", "bj.frp.octopusyan.top");
serverPath.put("上海", "frp.octopusyan.top");
+ serverIp.put("香港", "101.32.202.135");
+ serverIp.put("北京", "112.125.120.135");
+ serverIp.put("上海", "81.68.214.67");
+
typePort.put("http", 80);
typePort.put("https", 80);
typePort.put("ssh", 22);
@@ -25,8 +34,25 @@ public class ProxyConfig {
}
+ @Getter
public enum ProxyServer {
- 香港, 北京, 上海
+ xg("香港", 1),
+ bj("北京", 2),
+ sh("上海", 3);
+ private final String serverName;
+ private final int value;
+
+ ProxyServer(String serverName, int value) {
+ this.serverName = serverName;
+ this.value = value;
+ }
+
+ public static ProxyServer valueOf(int node) {
+ for (ProxyServer value : values()) {
+ if (value.value == node) return value;
+ }
+ return null;
+ }
}
public enum ProxyType {
@@ -36,7 +62,7 @@ public class ProxyConfig {
TCP("tcp"),
;
- private String type;
+ private final String type;
public String getType() {
return type;
@@ -51,7 +77,49 @@ public class ProxyConfig {
return serverPath.get(serverName);
}
+ public static int getServerNode(String serverName) {
+ for (ProxyServer server : Arrays.asList(ProxyServer.values())) {
+ if(server.serverName.equals(serverName)) return server.value;
+ }
+
+ return 3;
+ }
+
+ /**
+ * 获取服务名称
+ * @param node 服务器标签
+ */
+ public static String getServerName(int node) {
+ ProxyServer proxyServer = ProxyServer.valueOf(node);
+ assert proxyServer != null;
+ return proxyServer.getServerName();
+ }
+
+ /**
+ * 获取服务器IP地址
+ * @param serverName 服务器名称
+ */
+ public static String getServerIP(String serverName) {
+ return serverIp.get(serverName);
+ }
+
+ /**
+ * 获取服务器IP地址
+ * @param node 服务器标签
+ */
+ public static String getServerIP(int node) {
+ return serverIp.get(getServerName(node));
+ }
+
+ /**
+ * 获取代理类型默认端口
+ * @param type 类型名称
+ */
public static Integer getTypePort(String type) {
return typePort.get(type);
}
+
+ public static Integer getTypeIndex(String type) {
+ return Arrays.asList(ProxyType.values()).indexOf(ProxyType.valueOf(StringUtils.upperCase(type)));
+ }
}
diff --git a/src/main/java/top/octopusyan/config/TextValidate.java b/src/main/java/top/octopusyan/config/TextValidate.java
new file mode 100644
index 0000000..d5655f6
--- /dev/null
+++ b/src/main/java/top/octopusyan/config/TextValidate.java
@@ -0,0 +1,155 @@
+package top.octopusyan.config;
+
+import com.jfoenix.validation.RegexValidator;
+import com.jfoenix.validation.RequiredFieldValidator;
+import com.jfoenix.validation.StringLengthValidator;
+import com.jfoenix.validation.base.ValidatorBase;
+import top.octopusyan.config.ProxyConfig;
+import top.octopusyan.model.ProxySetupModel;
+import top.octopusyan.utils.DomainUtil;
+
+import java.util.Objects;
+import java.util.regex.Pattern;
+
+/**
+ * @author : octopus yan
+ * @email : octopus_yan@foxmail.com
+ * @description : JFX文本校验
+ * @create : 2022-4-2 17:03
+ */
+public class TextValidate {
+// /**
+// * 账号格式错误
+// */
+// public static ValidatorBase AccountFail = new ValidatorBase() {
+// @Override
+// protected void eval() {
+// setMessage("账号格式错误");
+// hasErrors.set(true);
+// }
+// };
+
+ /**
+ * 账号不能为空
+ */
+ public static RequiredFieldValidator AccoountRequired = new RequiredFieldValidator("账号不能为空!");
+ /**
+ * 账号格式
+ */
+ public static RegexValidator AccoountValidator = new RegexValidator("账号格式有误!");
+ /**
+ * 密码不能为空
+ */
+ public static RequiredFieldValidator PasswordRequired = new RequiredFieldValidator("密码不能为空!");
+ /**
+ * 邮箱地址格式验证
+ */
+ public static RegexValidator EmailFormat = new RegexValidator("邮箱地址格式错误");
+ /**
+ * 域名为空检查
+ */
+ public static RequiredFieldValidator DomainRequired = new RequiredFieldValidator("域名不能为空!");
+ /**
+ * 端口为空检查
+ */
+ public static RequiredFieldValidator PortRequired = new RequiredFieldValidator("端口不能为空");
+ /**
+ * 端口格式检查
+ */
+ public static final RegexValidator PortFormat = new RegexValidator("端口格式错误");
+ /**
+ * IP为空检查
+ */
+ public static RequiredFieldValidator IpRequired = new RequiredFieldValidator("本地IP不能为空");
+ /**
+ * IP格式检查
+ */
+ public static final RegexValidator IpFormat = new RegexValidator("本地IP格式错误");
+
+ static {
+ EmailFormat.setRegexPattern("^\\s*\\w+(?:\\.{0,1}[\\w-]+)*@[a-zA-Z0-9]+(?:[-.][a-zA-Z0-9]+)*\\.[a-zA-Z]+\\s*$");
+ AccoountValidator.setRegexPattern("^[a-zA-Z0-9_-]*$");
+ PortFormat.setRegexPattern("^([0-9]|[1-9]\\d{1,3}|[1-5]\\d{4}|6[0-4]\\d{4}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])$");
+ IpFormat.setRegexPattern("^(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])$");
+ }
+
+ /**
+ * 文本长度校验
+ * message > name + "长度有误"
+ */
+ public static StringLengthValidator getLengthValidator(String name, int length) {
+ return new StringLengthValidator(name + "长度有误", length);
+ }
+
+ /**
+ * 文本长度校验
+ * message > name + "长度有误,应在" + min + "到" + max + "之间"
+ */
+ public static RegexValidator getLengthValidator(int min, int max, String name) {
+ String message = name + "长度有误,应在" + min + "到" + max + "之间";
+
+ RegexValidator validator = new RegexValidator(message);
+
+ validator.setRegexPattern("[a-zA-Z0-9_-]{" + min + "," + max + "}$");
+
+ return validator;
+ }
+
+ /**
+ * 域名格式检查
+ */
+ public static ValidatorBase domainFormatValidator(ProxySetupModel model) {
+
+ return new ValidatorBase("域名格式错误") {
+ @Override
+ protected void eval() {
+ if (!DomainUtil.isCustomize(model.get()))
+ hasErrors.set(false);
+ else {
+ boolean matches = Pattern.compile("^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$")
+ .matcher(model.getDomain() + model.getDomainSuffix()).matches();
+ hasErrors.set(!matches);
+ }
+ }
+ };
+ }
+
+ /**
+ * 域名格式检查
+ */
+ public static ValidatorBase domainLengthValidator(ProxySetupModel model) {
+
+ return new RegexValidator("请输入子域名,长度不小于3个字符") {
+ @Override
+ protected void eval() {
+ setRegexPattern("^[a-zA-Z0-9_-]{3,18}$");
+ if (DomainUtil.isHttp(model) && !DomainUtil.isCustomize(model.get())) {
+ super.eval();
+ } else {
+ hasErrors.set(false);
+ }
+ }
+ };
+ }
+
+ /**
+ * 自定义域名解析检查
+ */
+ public static ValidatorBase domainAddressValidator(ProxySetupModel model) {
+
+ return new ValidatorBase("请输入您的域名,并解析至: " + ProxyConfig.getServerIP(model.getServer())) {
+ @Override
+ protected void eval() {
+ if (!DomainUtil.isCustomize(model.get()))
+ hasErrors.set(false);
+ else
+ hasErrors.set(
+ !Objects.equals(
+ ProxyConfig.getServerIP(model.getServer()),
+ DomainUtil.getDomainAddress(model.getDomain())
+ )
+ );
+ }
+ };
+ }
+}
diff --git a/src/main/java/top/octopusyan/controller/LoginController.java b/src/main/java/top/octopusyan/controller/LoginController.java
index ce2546a..931bda8 100644
--- a/src/main/java/top/octopusyan/controller/LoginController.java
+++ b/src/main/java/top/octopusyan/controller/LoginController.java
@@ -5,39 +5,28 @@ import com.jfoenix.controls.JFXCheckBox;
import com.jfoenix.controls.JFXPasswordField;
import com.jfoenix.controls.JFXTextField;
import javafx.application.Platform;
-import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
-import javafx.scene.input.MouseEvent;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.select.Elements;
import org.kordamp.ikonli.javafx.FontIcon;
import top.octopusyan.base.BaseController;
-import top.octopusyan.common.http.EasyHttp;
-import top.octopusyan.common.http.api.NotParamApi;
-import top.octopusyan.common.http.config.HttpConstant;
-import top.octopusyan.common.http.listener.OnHttpListener;
+import top.octopusyan.manager.http.EasyHttp;
+import top.octopusyan.manager.http.api.NotParamApi;
+import top.octopusyan.manager.http.config.HttpConstant;
+import top.octopusyan.manager.http.listener.OnHttpListener;
+import top.octopusyan.config.TextValidate;
import top.octopusyan.http.Api;
import top.octopusyan.http.request.LoginParam;
-import top.octopusyan.http.request.ProxySetup;
-import top.octopusyan.utils.AlertUtil;
-import top.octopusyan.utils.ApplicatonStore;
-import top.octopusyan.utils.ProxyUtil;
-import top.octopusyan.utils.TextValidate;
+import top.octopusyan.utils.*;
-import java.net.URL;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.stream.Collectors;
+import java.io.IOException;
/**
* @author : octopus yan
@@ -119,8 +108,8 @@ public class LoginController extends BaseController implements Initia
String account = ApplicatonStore.getAccount();
String password = ApplicatonStore.getPassword();
- if(!StringUtils.isEmpty(account)) accountTextField.setText(account);
- if(!StringUtils.isEmpty(password)) {
+ if (!StringUtils.isEmpty(account)) accountTextField.setText(account);
+ if (!StringUtils.isEmpty(password)) {
passwordTextField.setText(password);
seePwdTextField.setText(password);
}
@@ -172,7 +161,13 @@ public class LoginController extends BaseController implements Initia
public void initViewAction() {
// 注册
- registerBtn.setOnMouseClicked(event -> jumpTo(new RegisterController()));
+ registerBtn.setOnMouseClicked(event -> {
+ try {
+ jumpTo(new RegisterController());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
// 查看密码
seePwdIconBtn.setOnMouseClicked(event -> {
@@ -187,22 +182,23 @@ public class LoginController extends BaseController implements Initia
// 登录
loginBtn.setOnMouseClicked(event -> login());
accountTextField.setOnKeyPressed(event -> {
- if(event.getCode() == KeyCode.ENTER) login();
+ if (event.getCode() == KeyCode.ENTER) login();
});
passwordTextField.setOnKeyPressed(event -> {
- if(event.getCode() == KeyCode.ENTER) login();
+ if (event.getCode() == KeyCode.ENTER) login();
});
// 自动登录
- if((ApplicatonStore.isAutoLogin() || ApplicatonStore.isRegisterSuccess()) &&
+ if ((ApplicatonStore.isAutoLogin() || ApplicatonStore.isRegisterSuccess()) &&
!StringUtils.isEmpty(ApplicatonStore.getAccount()) &&
!StringUtils.isEmpty(ApplicatonStore.getPassword())
- ){
+ ) {
login();
}
}
- private void login(){
+ private void login() {
+
// 获取文本校验结果
boolean pwdValidate = pwdParent.getChildren().contains(passwordTextField) ?
passwordTextField.validate() : seePwdTextField.validate();
@@ -215,15 +211,20 @@ public class LoginController extends BaseController implements Initia
.request(new OnHttpListener() {
@Override
public void onSucceed(String result) {
- Document html = Jsoup.parse(result);
// 登录出错
- if (result.contains("alert-danger")) {
- Platform.runLater(() -> AlertUtil.error(getHtmlErrorMessage(html)).show());
+ if (!JsoupUtil.isAlertSuccess(result)) {
+ Platform.runLater(() -> AlertUtil.error(JsoupUtil.getErrorMessage(result)).show());
return;
}
// TODO 登录成功
setCsrf();
- jumpTo(new MainController());
+ Platform.runLater(() -> {
+ try {
+ jumpTo(new MainController());
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
}
});
}
@@ -242,10 +243,6 @@ public class LoginController extends BaseController implements Initia
});
}
- private String getHtmlErrorMessage(Document html) {
- return html.body().getElementsByClass("alert alert-danger alert-dismissable").text().substring(1);
- }
-
@Override
public void onDestroy() {
EasyHttp.cancel();
diff --git a/src/main/java/top/octopusyan/controller/MainController.java b/src/main/java/top/octopusyan/controller/MainController.java
index 41b57c2..dcdc43b 100644
--- a/src/main/java/top/octopusyan/controller/MainController.java
+++ b/src/main/java/top/octopusyan/controller/MainController.java
@@ -1,14 +1,22 @@
package top.octopusyan.controller;
import com.jfoenix.controls.*;
+import com.jfoenix.validation.IntegerValidator;
+import com.jfoenix.validation.RequiredFieldValidator;
+import javafx.application.HostServices;
import javafx.application.Platform;
+import javafx.beans.property.SimpleBooleanProperty;
+import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.ObservableList;
+import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.*;
+import javafx.scene.control.Button;
+import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
@@ -19,13 +27,18 @@ import top.octopusyan.config.ProxyConfig;
import top.octopusyan.config.ProxyConfig.ProxyServer;
import top.octopusyan.config.ProxyConfig.ProxyType;
import top.octopusyan.http.request.ProxySetup;
+import top.octopusyan.model.ProxySetupModel;
import top.octopusyan.utils.AlertUtil;
-import top.octopusyan.utils.ApplicatonStore;
+import top.octopusyan.utils.DomainUtil;
+import top.octopusyan.utils.FrpUtil;
import top.octopusyan.utils.ProxyUtil;
+import top.octopusyan.config.TextValidate;
+import java.awt.*;
+import java.awt.datatransfer.Clipboard;
+import java.awt.datatransfer.StringSelection;
import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.*;
import java.util.List;
/**
@@ -40,6 +53,9 @@ public class MainController extends BaseController implements Initial
public static final String PROXY_LIST_ITEM_STOP_CLASS = "proxyListItem-stop";
public static final String PROXY_LIST_ITEM_RUN_CLASS = "proxyListItem-run";
public static final String PROXY_LIST_ITEM_CLOSE_CLASS = "proxyListItem-close";
+ public static final String PROXY_LIST_ITEM_SELECT_CLASS = "proxyListItem-select";
+ public static final String INPUT_LEFT_CLASS = "inputText-left";
+ public static final String INPUT_CLASS = "inputText";
@FXML
public StackPane root;
@@ -48,11 +64,9 @@ public class MainController extends BaseController implements Initial
public JFXButton closeBtn, minimizeBtn;
@FXML
- public JFXButton startProxyBtn;
+ public JFXButton startProxyBtn, addProxyBtn;
@FXML
- public JFXButton addProxyBtn;
- @FXML
- public JFXComboBox