diff --git a/src/main/java/com/light/component/DownloadHBox.java b/src/main/java/com/light/component/DownloadHBox.java index 4bff0d3ec7e98b5d186c354128efef6f3f99ae1d..0572145243993e2a5cd40292745ae1ae7f53bd7b 100644 --- a/src/main/java/com/light/component/DownloadHBox.java +++ b/src/main/java/com/light/component/DownloadHBox.java @@ -2,6 +2,7 @@ package com.light.component; import atlantafx.base.theme.Styles; import com.light.exception.AuthException; +import com.light.exception.JGitException; import com.light.model.GitAuthInfo; import com.light.model.GitProject; import com.light.thread.FxAsyncTask; @@ -39,6 +40,8 @@ public class DownloadHBox extends HBox { private final CustomProgressMonitor customProgressMonitor = new CustomProgressMonitor(progressBar, null, text); private CredentialsProvider provider; + private boolean isAuthException = false; + /** * 构造方法 * @@ -124,8 +127,12 @@ public class DownloadHBox extends HBox { return newProject; } catch (AuthException e) { + isAuthException = true; authPane.refreshData(remoteUrl, (username, password) -> cloneRepo(JGitUtils.createCredential(username, password), true)); throw new AuthException(); + } catch (Exception e) { + isAuthException = false; + throw new JGitException(); } }, success -> { @@ -134,7 +141,7 @@ public class DownloadHBox extends HBox { FxApplicationContextUtils.DOWNLOAD_PROPERTY.set(String.valueOf(FxApplicationContextUtils.DOWNLOAD_NUMBER.decrementAndGet())); }, fail -> { - if (authPane != null) { + if (authPane != null && isAuthException) { authPane.show((Scene) FxApplicationContextUtils.GLOBAL_CONTEXT_MAP.get("scene")); } retryButton.setVisible(true); diff --git a/src/main/java/com/light/util/H2PoolUtils.java b/src/main/java/com/light/util/H2PoolUtils.java index 9914cb4103a53bae9c23307429d83de467dfbbf0..6ac268e27b9bb13e9cf28354d1fdd723f5ee7df8 100644 --- a/src/main/java/com/light/util/H2PoolUtils.java +++ b/src/main/java/com/light/util/H2PoolUtils.java @@ -256,10 +256,10 @@ public class H2PoolUtils { String sql2 = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_CURRENT_THEME','Primer Light','项目当前主题', " + "'" + dateTime + "', '" + dateTime + "')"; stmt.addBatch(sql2); - String sql3 = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_CURRENT_CLONE_DIR','D:','项目克隆路径', " + + String sql3 = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_CURRENT_CLONE_DIR','','项目克隆路径', " + "'" + dateTime + "', '" + dateTime + "')"; stmt.addBatch(sql3); - String sql4 = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_CURRENT_LOCAL_DIR','D:','本地项目路径', " + + String sql4 = "insert into git_project_dict(label, label_value, description, createtime, updatetime) values('GIT_CURRENT_LOCAL_DIR','','本地项目路径', " + "'" + dateTime + "', '" + dateTime + "')"; stmt.addBatch(sql4); stmt.executeBatch(); diff --git a/src/main/java/com/light/view/HomeView.java b/src/main/java/com/light/view/HomeView.java index 5a9176eee7b9b1e645b08c529b11fd81e2032efa..01d5ccb867c6a3c1cd90ba358d2187c237c56971 100644 --- a/src/main/java/com/light/view/HomeView.java +++ b/src/main/java/com/light/view/HomeView.java @@ -93,7 +93,7 @@ public class HomeView extends BorderPane { }); right.setOnMouseClicked(event -> { - dirChooser.setInitialDirectory(new File(H2PoolUtils.queryDictByLabel("GIT_CURRENT_CLONE_DIR", "D:") + File.separator)); + dirChooser.setInitialDirectory(new File(H2PoolUtils.queryDictByLabel("GIT_CURRENT_CLONE_DIR", "") + File.separator)); File file = dirChooser.showDialog(getScene().getWindow()); if (null != file) { targetFolderPath.set(file.getPath()); diff --git a/src/main/java/com/light/view/ManagerView.java b/src/main/java/com/light/view/ManagerView.java index bcbcae7c8238dd9b71f9a4146353932c9e24d8f6..6f6cd41a79f63cd98ce7008bdc9973f5890011e3 100644 --- a/src/main/java/com/light/view/ManagerView.java +++ b/src/main/java/com/light/view/ManagerView.java @@ -151,9 +151,10 @@ public class ManagerView extends StackPane { * 按钮 加载 */ addLocalButton.setOnAction(btn -> { - dirChooser.setInitialDirectory(new File(H2PoolUtils.queryDictByLabel("GIT_CURRENT_LOCAL_DIR", "D:") + File.separator)); + dirChooser.setInitialDirectory(new File(H2PoolUtils.queryDictByLabel("GIT_CURRENT_LOCAL_DIR", "") + File.separator)); File file = dirChooser.showDialog(getScene().getWindow()); if (null != file) { + H2PoolUtils.updateDictData("GIT_CURRENT_LOCAL_DIR", file.getPath()); FxAsyncTask.runOnce("加载本地项目", () -> { JGitUtils.parseLocalProjectPath(file); JGitUtils.parseLocalProject();