删除逻辑bug --淦

邮箱登录
修改本地服务名称
This commit is contained in:
octopusYan 2022-04-24 14:40:46 +08:00
parent c1651beebd
commit 6a702a1f89
5 changed files with 52 additions and 26 deletions

View File

@ -63,7 +63,7 @@ public class ProxyConfig {
UDP,
STCP,
XTCP,
;
}
public static String getServerPath(String serverName) {

View File

@ -113,7 +113,7 @@ public class TextValidate {
RegexValidator validator = new RegexValidator(message);
validator.setRegexPattern("[a-zA-Z0-9_-]{" + min + "," + max + "}$");
validator.setRegexPattern("[\\w@-_\\.]{" + min + "," + max + "}$");
return validator;
}

View File

@ -16,6 +16,7 @@ import javafx.scene.input.KeyCode;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import okhttp3.Call;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.kordamp.ikonli.javafx.FontIcon;
@ -162,8 +163,8 @@ public class LoginController extends BaseController<StackPane> implements Initia
// 添加文本校验
accountTextField.getValidators().add(TextValidate.AccoountRequired);
accountTextField.getValidators().add(TextValidate.AccoountValidator);
accountTextField.getValidators().add(TextValidate.getLengthValidator(6, 18, "账号"));
// accountTextField.getValidators().add(TextValidate.AccoountValidator);
accountTextField.getValidators().add(TextValidate.getLengthValidator(6, 25, "账号"));
passwordTextField.getValidators().add(TextValidate.PasswordRequired);
seePwdTextField.getValidators().add(TextValidate.PasswordRequired);
@ -261,6 +262,11 @@ public class LoginController extends BaseController<StackPane> implements Initia
.api(Api.Login)
.param(new LoginParam(accountTextField.getText(), tmpPwd.get()))
.request(new OnHttpListener<String>() {
@Override
public void onStart(Call call) {
Platform.runLater(() -> loginBtn.setDisable(true));
}
@Override
public void onSucceed(String result) {
// 登录出错
@ -288,6 +294,11 @@ public class LoginController extends BaseController<StackPane> implements Initia
public void onFail(Exception e) {
}
@Override
public void onEnd(Call call) {
Platform.runLater(() -> loginBtn.setDisable(false));
}
});
}

View File

@ -538,7 +538,7 @@ public class MainController extends BaseController<StackPane> implements Initial
ProxySetup setup = proxySetupModel.get();
// 整理服务设置
String serverName = getAccount() + "_" + setup.getSort();
String serverName = setup.getProxy_name() + "_" + setup.getSort();
setup.setServer_name(ApplicatonStore.getUserToken() + "." + EncryptionUtil.MD5_16(serverName));
setup.setId(null);
setup.setRuning(false);
@ -724,7 +724,7 @@ public class MainController extends BaseController<StackPane> implements Initial
private void initProxyListView() {
ObservableList<ProxySetup> proxyList = proxyList();
for (ProxySetup proxy : proxyList.subList(proxyListView.getItems().size(), proxyList.size())) {
for (ProxySetup proxy : proxyList) {
setProxyListView(proxyList.indexOf(proxy), proxy);
}
// 设置选中
@ -745,29 +745,46 @@ public class MainController extends BaseController<StackPane> implements Initial
// 运行状态
itemView.setStatus(setup.isRuning());
// 点击删除
itemView.getDeleteBtn().setOnMouseClicked(event -> {
if(items.size() == 1) {
AlertUtil.error("最后一个连接不可删除!").show();
return;
}
// 关闭连接
if (proxyList().get(index).isRuning()) {
frpUtilMap.get(String.valueOf(index)).stop();
}
// 调用删除接口
if (setup.getId() != null) {
ProxyManager.delete(setup.getId());
}
// 列表删除
items.remove(itemView);
});
itemView.getDeleteBtn().setOnMouseClicked(event -> deleteProxyListItem(itemView));
// 是否选中
if (selectProxy() == index) itemView.getStyleClass().add(PROXY_LIST_ITEM_SELECT_CLASS);
// 添加
if (isNew) items.add(index, itemView);
}
private void deleteProxyListItem(ProxyListItemView itemView) {
ObservableList<ProxyListItemView> items = proxyListView.getItems();
int index = items.indexOf(itemView);
if (index < 0) return;
if (items.size() == 1) {
AlertUtil.error("最后一个连接不可删除!").show();
return;
}
ProxySetup setup = proxyList().get(index);
// 关闭连接
String key = String.valueOf(setup.getId());
FrpManager frpManager = frpUtilMap.get(key);
if (setup.isRuning() || frpManager != null) {
frpManager.stop();
frpUtilMap.remove(key);
}
// 调用删除接口
if (setup.getId() != null) {
ProxyManager.delete(setup.getId());
}
// 列表删除
items.remove(itemView);
proxyList().remove(setup);
// 重新选择
if (selectProxy() == index) {
proxyListView.getSelectionModel().select(-1);
proxyListView.getSelectionModel().select(index < items.size() ? index : items.size() - 1);
} else if (selectProxy() > index)
selectProxy(selectProxy() - 1);
}
/**
* 启动代理
*/

View File

@ -174,7 +174,7 @@ public class FrpManager {
// 基础配置
StringBuilder stringBuilder = new StringBuilder("[");
// 服务名称
StringBuilder serverName = new StringBuilder(ApplicatonStore.getAccount() + "_" + setup.getSort());
StringBuilder serverName = new StringBuilder(setup.getProxyName()).append("_").append(setup.getSort());
// p2p 服务名
if (isp2p) {
if (setup.isProvider()) {
@ -184,8 +184,6 @@ public class FrpManager {
// 访问者
serverName = new StringBuilder(setup.getServerName()).append("_visitor");
}
} else {
serverName.append(ApplicatonStore.getAccount()).append("_").append(setup.getSort());
}
stringBuilder.append(serverName).append("]\n");
stringBuilder.append("privilege_mode = true\n")