From 0190c2111d5c678ddaa8b00fb98cf262c406db19 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 9 Sep 2024 18:47:53 +0800 Subject: [PATCH] enhance: workspace tooltip (#445) --- src/Resources/Locales/en_US.axaml | 1 + src/Resources/Locales/zh_CN.axaml | 1 + src/Resources/Locales/zh_TW.axaml | 1 + src/ViewModels/Launcher.cs | 1 + src/ViewModels/Preference.cs | 10 ++++++---- src/Views/Launcher.axaml | 8 +++++++- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index ae321269..72661eb6 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -626,6 +626,7 @@ VIEW ASSUME UNCHANGED Template: ${0}$ Right-click the selected file(s), and make your choice to resolve conflicts. + WORKSPACE: Configure... WORKTREE Copy Path diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index 30037ef2..9ab76245 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -628,6 +628,7 @@ 查看忽略变更文件 模板:${0}$ 请选中冲突文件,打开右键菜单,选择合适的解决方式 + 工作区: 配置工作区... 本地工作树 复制工作树路径 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index a2e5e1ce..90059b41 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -629,6 +629,7 @@ 檢視不追蹤變更的檔案 範本: ${0}$ 請選擇發生衝突的檔案,開啟右鍵選單,選擇合適的解決方式 + 工作區: 配置工作區... 本機工作區 複製工作區路徑 diff --git a/src/ViewModels/Launcher.cs b/src/ViewModels/Launcher.cs index 254b5948..c734e726 100644 --- a/src/ViewModels/Launcher.cs +++ b/src/ViewModels/Launcher.cs @@ -125,6 +125,7 @@ namespace SourceGit.ViewModels var last = Pages[0]; if (last.Data is Repository repo) { + ActiveWorkspace.Repositories.Remove(repo.FullPath); Models.AutoFetchManager.Instance.RemoveRepository(repo.FullPath); repo.Close(); diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 06262970..a157a033 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -18,7 +18,9 @@ namespace SourceGit.ViewModels if (_instance == null) { _isLoading = true; - if (!File.Exists(_savePath)) + + var path = Path.Combine(Native.OS.DataDir, "preference.json"); + if (!File.Exists(path)) { _instance = new Preference(); } @@ -26,7 +28,7 @@ namespace SourceGit.ViewModels { try { - _instance = JsonSerializer.Deserialize(File.ReadAllText(_savePath), JsonCodeGen.Default.Preference); + _instance = JsonSerializer.Deserialize(File.ReadAllText(path), JsonCodeGen.Default.Preference); } catch { @@ -429,8 +431,9 @@ namespace SourceGit.ViewModels public void Save() { + var file = Path.Combine(Native.OS.DataDir, "preference.json"); var data = JsonSerializer.Serialize(this, JsonCodeGen.Default.Preference); - File.WriteAllText(_savePath, data); + File.WriteAllText(file, data); } private RepositoryNode FindNodeRecursive(string id, List collection) @@ -482,7 +485,6 @@ namespace SourceGit.ViewModels private static Preference _instance = null; private static bool _isLoading = false; - private static readonly string _savePath = Path.Combine(Native.OS.DataDir, "preference.json"); private string _locale = "en_US"; private string _theme = "Default"; diff --git a/src/Views/Launcher.axaml b/src/Views/Launcher.axaml index e659773f..3d1b1bfd 100644 --- a/src/Views/Launcher.axaml +++ b/src/Views/Launcher.axaml @@ -70,7 +70,13 @@ -