From eba18352049c0dc48cd07b2d299f83cf366c58f2 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Sat, 3 Dec 2022 12:27:26 +0800 Subject: [PATCH 01/26] =?UTF-8?q?=F0=9F=8E=87=20Style:=20using?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ViewModels/PluginDetailWindowViewModel.cs | 2 -- Views/PluginDetailWindow.axaml.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/ViewModels/PluginDetailWindowViewModel.cs b/ViewModels/PluginDetailWindowViewModel.cs index c5eaccc9..4bed39e2 100644 --- a/ViewModels/PluginDetailWindowViewModel.cs +++ b/ViewModels/PluginDetailWindowViewModel.cs @@ -4,12 +4,10 @@ using KitX_Dashboard.Commands; using Serilog; using System; -using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; using System.Linq; using System.Text; -using System.Threading.Tasks; namespace KitX_Dashboard.ViewModels { diff --git a/Views/PluginDetailWindow.axaml.cs b/Views/PluginDetailWindow.axaml.cs index 4395fa8d..3c3a1bea 100644 --- a/Views/PluginDetailWindow.axaml.cs +++ b/Views/PluginDetailWindow.axaml.cs @@ -1,7 +1,7 @@ using Avalonia.Controls; +using Common.BasicHelper.UI.Screen; using KitX.Web.Rules; using KitX_Dashboard.ViewModels; -using Common.BasicHelper.UI.Screen; namespace KitX_Dashboard.Views { From 96df40624cb7ee5c24f4aec29aada32b186165f8 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Sat, 3 Dec 2022 12:28:41 +0800 Subject: [PATCH 02/26] =?UTF-8?q?=F0=9F=94=A7=20=F0=9F=92=BE=20Fix,=20Feat?= =?UTF-8?q?:=20=E4=BF=AE=E5=A4=8D=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=A4=9A=E9=87=8D=E5=AF=BC=E5=85=A5=E4=B8=8E?= =?UTF-8?q?=E5=88=A0=E4=B8=8D=E6=8E=89=E7=9A=84=E9=97=AE=E9=A2=98,=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E8=AF=A6=E6=83=85=E9=A1=B5UI=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/PluginsManager.cs | 78 ++++++++++++++++++++++------------ Views/PluginDetailWindow.axaml | 13 +++--- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/Services/PluginsManager.cs b/Services/PluginsManager.cs index 55c4fd82..9d7ff6c9 100644 --- a/Services/PluginsManager.cs +++ b/Services/PluginsManager.cs @@ -174,20 +174,24 @@ internal static void ImportPlugin(string[] kxpfiles, bool inGraphic = false) Console.WriteLine($"No config file found!"); if (!inGraphic) Environment.Exit(ErrorCodes.ConfigFileDidntExists); } - string pluginsavedir = config?.App.LocalPluginsFileDirectory; + string pluginsavedir = config?.App?.LocalPluginsFileDirectory; + if (pluginsavedir != null) + pluginsavedir = Path.GetFullPath(pluginsavedir); string thisplugindir = $"{pluginsavedir}/" + $"{pluginStruct.PublisherName}_{pluginStruct.AuthorName}/" + $"{pluginStruct.Name}/" + $"{pluginStruct.Version}/"; + thisplugindir = Path.GetFullPath(thisplugindir); if (Directory.Exists(thisplugindir)) Directory.Delete(thisplugindir, true); _ = Directory.CreateDirectory(thisplugindir); _ = decoder.Decode(thisplugindir); - Program.PluginsList.Plugins.Add(new Plugin() - { - InstallPath = thisplugindir - }); + if (!Program.PluginsList.Plugins.Exists(x => x.InstallPath.Equals(thisplugindir))) + Program.PluginsList.Plugins.Add(new() + { + InstallPath = thisplugindir + }); } catch (Exception e) { @@ -222,34 +226,56 @@ internal static void KeepCheckAndRemoveOrDelete() }; timer.Elapsed += (_, _) => { - bool isPluginsListUpdated = false; - - if (pluginsToRemoveFromDB.Count > 0) + try { - isPluginsListUpdated = true; - while (pluginsToRemoveFromDB.Count > 0) + bool isPluginsListUpdated = false; + + if (pluginsToRemoveFromDB.Count > 0) { - Program.PluginsList.Plugins.Remove(pluginsToRemoveFromDB.Dequeue()); + isPluginsListUpdated = true; + while (pluginsToRemoveFromDB.Count > 0) + { + Plugin pg = pluginsToRemoveFromDB.Dequeue(); + Program.PluginsList.Plugins.RemoveAt( + Program.PluginsList.Plugins.FindIndex( + x => + { + if (x.InstallPath != null) + return x.InstallPath.Equals(pg.InstallPath); + else return false; + })); + } } - } - if (pluginsToDelete.Count > 0) - { - isPluginsListUpdated = true; - while (pluginsToDelete.Count > 0) + if (pluginsToDelete.Count > 0) { - Plugin pg = pluginsToDelete.Dequeue(); - Program.PluginsList.Plugins.Remove(pg); - string pgfiledir = Path.GetFullPath( - $"{Program.Config.App.LocalPluginsFileDirectory}/" + - $"{pg.PluginDetails.PublisherName}_{pg.PluginDetails.AuthorName}/" + - $"{pg.PluginDetails.Name}/{pg.PluginDetails.Version}/" - ); - Directory.Delete(pgfiledir, true); + isPluginsListUpdated = true; + while (pluginsToDelete.Count > 0) + { + Plugin pg = pluginsToDelete.Dequeue(); + Program.PluginsList.Plugins.RemoveAt( + Program.PluginsList.Plugins.FindIndex( + x => + { + if (x.InstallPath != null) + return x.InstallPath.Equals(pg.InstallPath); + else return false; + })); + string pgfiledir = Path.GetFullPath( + $"{Program.Config.App.LocalPluginsFileDirectory}/" + + $"{pg.PluginDetails.PublisherName}_{pg.PluginDetails.AuthorName}/" + + $"{pg.PluginDetails.Name}/{pg.PluginDetails.Version}/" + ); + Directory.Delete(pgfiledir, true); + } } - } - if (isPluginsListUpdated) EventHandlers.Invoke(nameof(EventHandlers.PluginsListChanged)); + if (isPluginsListUpdated) EventHandlers.Invoke(nameof(EventHandlers.PluginsListChanged)); + } + catch (Exception ex) + { + Log.Error("In PluginsManager.KeepCheckAndRemoveOrDelete()", ex); + } }; timer.Start(); } diff --git a/Views/PluginDetailWindow.axaml b/Views/PluginDetailWindow.axaml index 8a61a368..2ea66332 100644 --- a/Views/PluginDetailWindow.axaml +++ b/Views/PluginDetailWindow.axaml @@ -12,6 +12,7 @@ d:DesignWidth="800" Background="Transparent" ExtendClientAreaToDecorationsHint="True" + Icon="avares://KitX.Assets/KitX-Icon-32x32.png" TransparencyLevelHint="AcrylicBlur" mc:Ignorable="d"> @@ -29,11 +30,11 @@ - + - + @@ -185,14 +186,12 @@ - - - - - + + + From 902b8eb61378a60699a746c630ad2587bb06ccf0 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Sat, 3 Dec 2022 16:22:59 +0800 Subject: [PATCH 03/26] =?UTF-8?q?=F0=9F=94=A7=20Fix:=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9=E6=8F=92=E4=BB=B6=E5=88=97=E8=A1=A8=E7=9A=84=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/PluginsManager.cs | 40 ++++++++++++++++----------- ViewModels/Pages/RepoPageViewModel.cs | 35 +++++++++++++---------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/Services/PluginsManager.cs b/Services/PluginsManager.cs index 9d7ff6c9..8fc5c585 100644 --- a/Services/PluginsManager.cs +++ b/Services/PluginsManager.cs @@ -57,6 +57,8 @@ internal static void Execute(string msg, IPEndPoint endPoint) internal static readonly Queue pluginsToDelete = new(); + internal static readonly object PluginsListOperationLock = new(); + /// /// 持续检查并移除 /// @@ -236,14 +238,17 @@ internal static void KeepCheckAndRemoveOrDelete() while (pluginsToRemoveFromDB.Count > 0) { Plugin pg = pluginsToRemoveFromDB.Dequeue(); - Program.PluginsList.Plugins.RemoveAt( - Program.PluginsList.Plugins.FindIndex( - x => - { - if (x.InstallPath != null) - return x.InstallPath.Equals(pg.InstallPath); - else return false; - })); + lock (PluginsListOperationLock) + { + Program.PluginsList.Plugins.RemoveAt( + Program.PluginsList.Plugins.FindIndex( + x => + { + if (x.InstallPath != null) + return x.InstallPath.Equals(pg.InstallPath); + else return false; + })); + } } } @@ -253,14 +258,17 @@ internal static void KeepCheckAndRemoveOrDelete() while (pluginsToDelete.Count > 0) { Plugin pg = pluginsToDelete.Dequeue(); - Program.PluginsList.Plugins.RemoveAt( - Program.PluginsList.Plugins.FindIndex( - x => - { - if (x.InstallPath != null) - return x.InstallPath.Equals(pg.InstallPath); - else return false; - })); + lock (PluginsListOperationLock) + { + Program.PluginsList.Plugins.RemoveAt( + Program.PluginsList.Plugins.FindIndex( + x => + { + if (x.InstallPath != null) + return x.InstallPath.Equals(pg.InstallPath); + else return false; + })); + } string pgfiledir = Path.GetFullPath( $"{Program.Config.App.LocalPluginsFileDirectory}/" + $"{pg.PluginDetails.PublisherName}_{pg.PluginDetails.AuthorName}/" + diff --git a/ViewModels/Pages/RepoPageViewModel.cs b/ViewModels/Pages/RepoPageViewModel.cs index c6482170..4068f0ff 100644 --- a/ViewModels/Pages/RepoPageViewModel.cs +++ b/ViewModels/Pages/RepoPageViewModel.cs @@ -142,24 +142,29 @@ internal void RefreshPlugins(object _) //LiteDatabase? pgdb = Program.PluginsDataBase; PluginBars.Clear(); - foreach (var item in Program.PluginsList.Plugins) + lock (PluginsManager.PluginsListOperationLock) { - try + foreach (var item in Program.PluginsList.Plugins) { - Plugin plugin = new() + try { - InstallPath = item.InstallPath, - PluginDetails = JsonSerializer.Deserialize( - File.ReadAllText(Path.GetFullPath($"{item.InstallPath}/PluginStruct.json"))), - RequiredLoaderStruct = JsonSerializer.Deserialize( - File.ReadAllText(Path.GetFullPath($"{item.InstallPath}/LoaderStruct.json"))), - InstalledDevices = new() - }; - PluginBars.Add(new(plugin, ref pluginBars)); - } - catch (Exception ex) - { - Log.Error("In RefreshPlugins()", ex); + Plugin plugin = new() + { + InstallPath = item.InstallPath, + PluginDetails = JsonSerializer.Deserialize( + File.ReadAllText( + Path.GetFullPath($"{item.InstallPath}/PluginStruct.json"))), + RequiredLoaderStruct = JsonSerializer.Deserialize( + File.ReadAllText( + Path.GetFullPath($"{item.InstallPath}/LoaderStruct.json"))), + InstalledDevices = new() + }; + PluginBars.Add(new(plugin, ref pluginBars)); + } + catch (Exception ex) + { + Log.Error("In RefreshPlugins()", ex); + } } } } From c1c1777e081ad6de1fd482b68df76a880d30f5f9 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Mon, 5 Dec 2022 01:12:55 +0800 Subject: [PATCH 04/26] =?UTF-8?q?=F0=9F=92=BE=20Feat:=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=9A=84=E5=AF=BC=E5=85=A5=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=97=E6=B3=95,=20=E9=81=BF=E5=85=8D=E4=BA=8C=E6=AC=A1?= =?UTF-8?q?=E8=A7=A3=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Services/PluginsManager.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Services/PluginsManager.cs b/Services/PluginsManager.cs index 8fc5c585..b49ddf67 100644 --- a/Services/PluginsManager.cs +++ b/Services/PluginsManager.cs @@ -152,18 +152,12 @@ internal static void ImportPlugin(string[] kxpfiles, bool inGraphic = false) if (workbase == null) throw new Exception("Can not get path of \"KitX\""); } - string releaseDir = Path.GetFullPath($"{workbase}/{GlobalInfo.KXPTempReleasePath}"); foreach (var item in kxpfiles) { try { - if (Directory.Exists(releaseDir)) - Directory.Delete(releaseDir, true); - _ = Directory.CreateDirectory(releaseDir); - KitX.KXP.Helper.Decoder decoder = new(item); - Tuple rst = decoder.Decode(releaseDir); - Directory.Delete(releaseDir, true); + Tuple rst = decoder.GetLoaderAndPluginStruct(); LoaderStruct loaderStruct = JsonSerializer.Deserialize(rst.Item1); PluginStruct pluginStruct = JsonSerializer.Deserialize(rst.Item2); AppConfig? config = null; From 3667e6bf96b6381646eb27673428d7259f66a0fc Mon Sep 17 00:00:00 2001 From: StardustSeemsInk <114210472+StardustSeemsInk@users.noreply.github.com> Date: Mon, 5 Dec 2022 07:32:57 +0800 Subject: [PATCH 05/26] =?UTF-8?q?=F0=9F=94=A7=20Fix:=20=E4=BF=AE=E5=A4=8DL?= =?UTF-8?q?og=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=AF=A6=E7=BB=86=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.axaml.cs | 2 +- Services/DevicesManager.cs | 2 +- ViewModels/Pages/Controls/PluginBarViewModel.cs | 2 +- ViewModels/Pages/RepoPageViewModel.cs | 4 ++-- Views/Pages/RepoPage.axaml.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/App.axaml.cs b/App.axaml.cs index 1c87dc09..eae81b39 100644 --- a/App.axaml.cs +++ b/App.axaml.cs @@ -146,7 +146,7 @@ public override void OnFrameworkInitializationCompleted() } catch (Exception ex) { - Log.Error("In AnouncementManager.CheckNewAccnouncements()", ex); + Log.Error(ex, "In AnouncementManager.CheckNewAccnouncements()"); } }).Start(); diff --git a/Services/DevicesManager.cs b/Services/DevicesManager.cs index d28465dd..da827c2b 100644 --- a/Services/DevicesManager.cs +++ b/Services/DevicesManager.cs @@ -208,7 +208,7 @@ internal static void Watch4MainDevice() { receivedDeviceInfoStruct4Watch?.Clear(); receivedDeviceInfoStruct4Watch = null; - Log.Error("In Watch4MainDevice", ex); + Log.Error(ex, "In Watch4MainDevice"); } }).Start(); } diff --git a/ViewModels/Pages/Controls/PluginBarViewModel.cs b/ViewModels/Pages/Controls/PluginBarViewModel.cs index 9e288181..6b6138d2 100644 --- a/ViewModels/Pages/Controls/PluginBarViewModel.cs +++ b/ViewModels/Pages/Controls/PluginBarViewModel.cs @@ -168,7 +168,7 @@ internal void Launch(object _) } catch (Exception ex) { - Log.Error("In PluginBarViewModel.Launch()", ex); + Log.Error(ex, "In PluginBarViewModel.Launch()"); } }).Start(); } diff --git a/ViewModels/Pages/RepoPageViewModel.cs b/ViewModels/Pages/RepoPageViewModel.cs index 4068f0ff..5918e943 100644 --- a/ViewModels/Pages/RepoPageViewModel.cs +++ b/ViewModels/Pages/RepoPageViewModel.cs @@ -127,7 +127,7 @@ internal async void ImportPlugin(object win) } catch (Exception ex) { - Log.Error("In RepoPageViewModel.ImportPlugin()", ex); + Log.Error(ex, "In RepoPageViewModel.ImportPlugin()"); } }).Start(); } @@ -163,7 +163,7 @@ internal void RefreshPlugins(object _) } catch (Exception ex) { - Log.Error("In RefreshPlugins()", ex); + Log.Error(ex, "In RefreshPlugins()"); } } } diff --git a/Views/Pages/RepoPage.axaml.cs b/Views/Pages/RepoPage.axaml.cs index 628f264d..c17860a2 100644 --- a/Views/Pages/RepoPage.axaml.cs +++ b/Views/Pages/RepoPage.axaml.cs @@ -47,7 +47,7 @@ private void Drop(object sender, DragEventArgs e) } catch (Exception ex) { - Log.Error("In RepoPage.Drop()", ex); + Log.Error(ex, "In RepoPage.Drop()"); } }).Start(); } From 4c18436d4f9ef1d12c3f55909af59a9dab0eb36a Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Mon, 5 Dec 2022 18:36:40 +0800 Subject: [PATCH 06/26] =?UTF-8?q?=F0=9F=92=BE=20Feat:=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E6=8F=92=E4=BB=B6=E9=80=BB=E8=BE=91,=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AF=B9=E8=87=AA=E5=8A=A0=E8=BD=BD=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Controls/PluginBarViewModel.cs | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/ViewModels/Pages/Controls/PluginBarViewModel.cs b/ViewModels/Pages/Controls/PluginBarViewModel.cs index 9e288181..795772d7 100644 --- a/ViewModels/Pages/Controls/PluginBarViewModel.cs +++ b/ViewModels/Pages/Controls/PluginBarViewModel.cs @@ -146,24 +146,28 @@ internal void Launch(object _) try { string? loaderName = PluginDetail?.RequiredLoaderStruct.LoaderName; - string loaderFile = $"{Program.Config.Loaders.InstallPath}/{loaderName}/{loaderName}"; - if (OperatingSystem.IsWindows()) - loaderFile += ".exe"; - loaderFile = Path.GetFullPath(loaderFile); - var pd = PluginDetail?.PluginDetails; string pluginPath = $"{PluginDetail?.InstallPath}/{pd?.RootStartupFileName}"; string pluginFile = Path.GetFullPath(pluginPath); - - Log.Information($"Launch: {pluginFile} through {loaderFile}"); - - if (File.Exists(loaderFile) && File.Exists(pluginFile)) + string connectStr = $"{DevicesServer.DefaultDeviceInfoStruct.IPv4}" + + $":{GlobalInfo.PluginServerPort}"; + if (PluginDetail != null && PluginDetail.RequiredLoaderStruct.SelfLoad) + Process.Start(pluginFile, $"--connect {connectStr}"); + else { - string arg = $"--load \"{pluginFile}\" " + - $"--connect {DevicesServer.DefaultDeviceInfoStruct.IPv4}:" + - $"{GlobalInfo.PluginServerPort}"; - Log.Information($"Launch Argument: {arg}"); - Process.Start(loaderFile, arg); + string loaderFile = $"{Program.Config.Loaders.InstallPath}/{loaderName}/{loaderName}"; + if (OperatingSystem.IsWindows()) + loaderFile += ".exe"; + loaderFile = Path.GetFullPath(loaderFile); + + Log.Information($"Launch: {pluginFile} through {loaderFile}"); + + if (File.Exists(loaderFile) && File.Exists(pluginFile)) + { + string arg = $"--load \"{pluginFile}\" --connect {connectStr}"; + Log.Information($"Launch Argument: {arg}"); + Process.Start(loaderFile, arg); + } } } catch (Exception ex) From 40a2409c55f596ce532d7cac95f9aec218133470 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Mon, 5 Dec 2022 18:37:35 +0800 Subject: [PATCH 07/26] =?UTF-8?q?=F0=9F=92=BE=20=F0=9F=94=A7=20Feat,=20Fix?= =?UTF-8?q?:=20=E6=8F=92=E4=BB=B6=E8=AF=A6=E6=83=85=E9=A1=B5=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=AF=B9=E5=BA=94=E7=94=A8=E4=B8=BB=E9=A2=98=E7=9A=84?= =?UTF-8?q?=E6=94=AF=E6=8C=81,=20=E5=90=8C=E6=97=B6=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ViewModels/PluginDetailWindowViewModel.cs | 32 +++++++++++++++++++++-- Views/PluginDetailWindow.axaml | 4 +-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/ViewModels/PluginDetailWindowViewModel.cs b/ViewModels/PluginDetailWindowViewModel.cs index 4bed39e2..70528a54 100644 --- a/ViewModels/PluginDetailWindowViewModel.cs +++ b/ViewModels/PluginDetailWindowViewModel.cs @@ -1,21 +1,28 @@ -using Avalonia.Controls; +using Avalonia; +using Avalonia.Controls; +using Avalonia.Media; using Avalonia.Media.Imaging; +using FluentAvalonia.Styling; using KitX.Web.Rules; using KitX_Dashboard.Commands; +using KitX_Dashboard.Services; using Serilog; using System; using System.Collections.ObjectModel; +using System.ComponentModel; using System.IO; using System.Linq; using System.Text; namespace KitX_Dashboard.ViewModels { - internal class PluginDetailWindowViewModel : ViewModelBase + internal class PluginDetailWindowViewModel : ViewModelBase, INotifyPropertyChanged { public PluginDetailWindowViewModel() { InitCommands(); + + InitEvents(); } internal void InitCommands() @@ -23,6 +30,12 @@ internal void InitCommands() FinishCommand = new(Finish); } + internal void InitEvents() + { + EventHandlers.ThemeConfigChanged += + () => PropertyChanged?.Invoke(this, new(nameof(TintColor))); + } + internal PluginStruct? PluginDetail { get; set; } internal string? DisplayName @@ -103,6 +116,19 @@ internal string? TotalDescriptionInMarkdown internal string? LastUpdateDate => PluginDetail?.LastUpdateDate.ToString("yyyy.MM.dd"); + internal Color TintColor => Program.Config.App.Theme switch + { + "Light" => Colors.WhiteSmoke, + "Dark" => Colors.Black, + "Follow" => AvaloniaLocator.Current.GetService()?.RequestedTheme switch + { + "Light" => Colors.WhiteSmoke, + "Dark" => Colors.Black, + _ => Color.Parse(Program.Config.App.ThemeColor) + }, + _ => Color.Parse(Program.Config.App.ThemeColor), + }; + private readonly ObservableCollection functions = new(); private readonly ObservableCollection tags = new(); @@ -177,5 +203,7 @@ internal void Finish(object parent) { (parent as Window)?.Close(); } + + public new event PropertyChangedEventHandler? PropertyChanged; } } diff --git a/Views/PluginDetailWindow.axaml b/Views/PluginDetailWindow.axaml index 2ea66332..ba7bd198 100644 --- a/Views/PluginDetailWindow.axaml +++ b/Views/PluginDetailWindow.axaml @@ -25,7 +25,7 @@ @@ -80,7 +80,7 @@ From eb15b31530e06d05a2bd454ea292e545fe3c4746 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Tue, 6 Dec 2022 00:10:59 +0800 Subject: [PATCH 08/26] =?UTF-8?q?=F0=9F=93=9D=20=F0=9F=8E=87=20Chore,=20St?= =?UTF-8?q?yle:=20=E6=9B=B4=E6=96=B0=20NuGet=20=E5=8C=85,=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=B8=80=E4=BA=9B=E7=BC=96=E8=AF=91=E5=99=A8=E5=BB=BA?= =?UTF-8?q?=E8=AE=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.axaml.cs | 2 ++ KitX Dashboard.csproj | 2 +- ViewModels/Pages/Controls/DevelopingViewModel.cs | 7 +------ .../Pages/Controls/Settings_UpdateViewModel.cs | 10 ---------- ViewModels/PluginDetailWindowViewModel.cs | 12 ++++++------ 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/App.axaml.cs b/App.axaml.cs index eae81b39..841dfdf0 100644 --- a/App.axaml.cs +++ b/App.axaml.cs @@ -20,6 +20,7 @@ using System.Threading; #pragma warning disable CS8604 // 引用类型参数可能为 null。 +#pragma warning disable CA2211 // Non-constant fields should not be visible namespace KitX_Dashboard { @@ -158,6 +159,7 @@ public override void OnFrameworkInitializationCompleted() } } +#pragma warning restore CA2211 // Non-constant fields should not be visible #pragma warning restore CS8604 // 引用类型参数可能为 null。 // .....'',;;::cccllllllllllllcccc:::;;,,,''...'',,'.. diff --git a/KitX Dashboard.csproj b/KitX Dashboard.csproj index eb5283f0..a4710816 100644 --- a/KitX Dashboard.csproj +++ b/KitX Dashboard.csproj @@ -140,7 +140,7 @@ - + diff --git a/ViewModels/Pages/Controls/DevelopingViewModel.cs b/ViewModels/Pages/Controls/DevelopingViewModel.cs index f6a9e15e..bb1cafb4 100644 --- a/ViewModels/Pages/Controls/DevelopingViewModel.cs +++ b/ViewModels/Pages/Controls/DevelopingViewModel.cs @@ -4,12 +4,7 @@ internal class DevelopingViewModel : ViewModelBase { public DevelopingViewModel() { - InitCommands(); - } - - private void InitCommands() - { - + } } } diff --git a/ViewModels/Pages/Controls/Settings_UpdateViewModel.cs b/ViewModels/Pages/Controls/Settings_UpdateViewModel.cs index 75713d98..31799ffd 100644 --- a/ViewModels/Pages/Controls/Settings_UpdateViewModel.cs +++ b/ViewModels/Pages/Controls/Settings_UpdateViewModel.cs @@ -35,8 +35,6 @@ internal Settings_UpdateViewModel() InitEvents(); InitCommands(); - - InitData(); } /// @@ -62,14 +60,6 @@ internal void InitCommands() CheckUpdateCommand = new(CheckUpdate); } - /// - /// 初始化数据 - /// - internal void InitData() - { - - } - internal int canUpdateCount = 0; /// diff --git a/ViewModels/PluginDetailWindowViewModel.cs b/ViewModels/PluginDetailWindowViewModel.cs index 70528a54..aaea6d1a 100644 --- a/ViewModels/PluginDetailWindowViewModel.cs +++ b/ViewModels/PluginDetailWindowViewModel.cs @@ -33,7 +33,7 @@ internal void InitCommands() internal void InitEvents() { EventHandlers.ThemeConfigChanged += - () => PropertyChanged?.Invoke(this, new(nameof(TintColor))); + () => PropertyChanged?.Invoke(this, new(nameof(ViewModels.PluginDetailWindowViewModel.TintColor))); } internal PluginStruct? PluginDetail { get; set; } @@ -116,7 +116,7 @@ internal string? TotalDescriptionInMarkdown internal string? LastUpdateDate => PluginDetail?.LastUpdateDate.ToString("yyyy.MM.dd"); - internal Color TintColor => Program.Config.App.Theme switch + internal static Color TintColor => Program.Config.App.Theme switch { "Light" => Colors.WhiteSmoke, "Dark" => Colors.Black, @@ -165,11 +165,11 @@ internal void InitFunctionsAndTags() { StringBuilder sb = new(); sb.Append(func.ReturnValueType); - sb.Append(" "); + sb.Append(' '); if (func.DisplayNames.ContainsKey(langKey)) sb.Append(func.DisplayNames[langKey]); else sb.Append(func.Name); - sb.Append("("); + sb.Append('('); if (func.Parameters.Count != func.ParametersType.Count) throw new InvalidDataException("Parameters return type count " + "didn't match parameters count."); @@ -178,14 +178,14 @@ internal void InitFunctionsAndTags() { sb.Append(func.ParametersType[index]); ++index; - sb.Append(" "); + sb.Append(' '); if (param.Value.ContainsKey(langKey)) sb.Append(param.Value[langKey]); else sb.Append(param.Key); if (index != func.Parameters.Count) sb.Append(", "); } - sb.Append(")"); + sb.Append(')'); Functions.Add(sb.ToString()); } foreach (var tag in PluginDetail.Value.Tags) From 53ced61752a78d461bc685a687da7543d871466a Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Tue, 6 Dec 2022 01:06:27 +0800 Subject: [PATCH 09/26] =?UTF-8?q?=F0=9F=93=9D=20Chore:=20...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KitX Dashboard.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KitX Dashboard.csproj b/KitX Dashboard.csproj index a4710816..bf059548 100644 --- a/KitX Dashboard.csproj +++ b/KitX Dashboard.csproj @@ -130,8 +130,8 @@ - - + + From e4b6c85914866efe0335a03b1c11661fa3e954e9 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Thu, 15 Dec 2022 12:09:05 +0800 Subject: [PATCH 10/26] =?UTF-8?q?=F0=9F=92=BE=20Feat(Settings):=20Show=20l?= =?UTF-8?q?og=20usage=20and=20empty=20logs.=20Close#199.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Languages/en-us.axaml | 3 + Languages/fr-fr.axaml | 3 + Languages/ja-jp.axaml | 3 + Languages/ko-kr.axaml | 3 + Languages/ru-ru.axaml | 3 + Languages/zh-cn.axaml | 3 + Languages/zh-tw.axaml | 5 +- .../Controls/Settings_PerformenceViewModel.cs | 59 +++++++++++++++++++ .../Pages/Controls/Settings_Performence.axaml | 42 ++++++++++++- 9 files changed, 122 insertions(+), 2 deletions(-) diff --git a/Languages/en-us.axaml b/Languages/en-us.axaml index 49816ab1..e9be8753 100644 --- a/Languages/en-us.axaml +++ b/Languages/en-us.axaml @@ -21,6 +21,8 @@ Task Size Developing ... + Empty + Refresh Verbose Debug Infomation @@ -111,6 +113,7 @@ Native IP Filter Greeting Text Update Interval Log File Relative Settings + The log file has taken up space Log File Max Size Log File Max Count Log File Flush Interval diff --git a/Languages/fr-fr.axaml b/Languages/fr-fr.axaml index fc577653..6f5cb95c 100644 --- a/Languages/fr-fr.axaml +++ b/Languages/fr-fr.axaml @@ -21,6 +21,8 @@ Tâche Taille En développement + vide + rafraîchir détaillé débogage informations @@ -111,6 +113,7 @@ Règles de filtrage IP natives Mise à jour du message d'accueil retardée Paramètres liés au fichier journal + Le fichier journal a pris de la place Limite de taille du fichier journal limite du fichier journal Délai du cache du fichier journal diff --git a/Languages/ja-jp.axaml b/Languages/ja-jp.axaml index a4ad8414..d32df8aa 100644 --- a/Languages/ja-jp.axaml +++ b/Languages/ja-jp.axaml @@ -21,6 +21,8 @@ 仕事 サイズ 開発中 + 空の + リフレッシュする 详细 调试 情報 @@ -111,6 +113,7 @@ ネイティブ IP フィルタリング ルール あいさつ更新が遅れる ログファイル関連の設定 + ログファイルがスペースを占有しています ログ ファイルのサイズ制限 ログ ファイルの制限 ログ ファイル キャッシュの遅延 diff --git a/Languages/ko-kr.axaml b/Languages/ko-kr.axaml index 66c1f497..75bb8d82 100644 --- a/Languages/ko-kr.axaml +++ b/Languages/ko-kr.axaml @@ -21,6 +21,8 @@ 크기 개발 중 + 비어 있는 + 새로 고침 상세한 디버깅 정보 @@ -111,6 +113,7 @@ 기본 IP 필터링 규칙 인사말 업데이트가 지연되었습니다. 로그 파일 관련 설정 + 로그 파일이 공간을 차지했습니다. 로그 파일 크기 제한 로그 파일 제한 로그 파일 캐시 지연 diff --git a/Languages/ru-ru.axaml b/Languages/ru-ru.axaml index 2adacd1a..9f32f4f7 100644 --- a/Languages/ru-ru.axaml +++ b/Languages/ru-ru.axaml @@ -21,6 +21,8 @@ Задача размер В развитие + пустой + обновить подробный отладка Информация @@ -111,6 +113,7 @@ Собственные правила IP-фильтрации Обновление приветствия отложено Настройки, связанные с файлом журнала + Файл журнала занял место Ограничение размера файла журнала лимит файла журнала Задержка кеша файла журнала diff --git a/Languages/zh-cn.axaml b/Languages/zh-cn.axaml index 3fb115ce..ace335c3 100644 --- a/Languages/zh-cn.axaml +++ b/Languages/zh-cn.axaml @@ -21,6 +21,8 @@ 任务 大小 该部分正在开发中 + 清空 + 刷新 详细 调试 信息 @@ -111,6 +113,7 @@ 本机IP过滤规则 招呼语更新延迟 日志文件相关设置 + 日志文件已占用空间 日志文件体积限制 日志文件数量限制 日志文件缓存延时 diff --git a/Languages/zh-tw.axaml b/Languages/zh-tw.axaml index c63e2dca..f39bc338 100644 --- a/Languages/zh-tw.axaml +++ b/Languages/zh-tw.axaml @@ -21,6 +21,8 @@ 任務 大小 該部分正在開發中 + 清空 + 刷新 詳細 調試 信息 @@ -111,11 +113,12 @@ 本機IP過濾器 招呼語更新延遲 日志文檔相關設定 + 日誌文件已佔用空間 日志文檔大小限制 日志文檔數量限制 日志文檔緩衝延時 日志級別 - 更新檢查每綫程處理文件數量 + 更新檢查每綫程處理文件數量 更新 檢查更新 組件名稱 diff --git a/ViewModels/Pages/Controls/Settings_PerformenceViewModel.cs b/ViewModels/Pages/Controls/Settings_PerformenceViewModel.cs index 8d594bf6..200753cd 100644 --- a/ViewModels/Pages/Controls/Settings_PerformenceViewModel.cs +++ b/ViewModels/Pages/Controls/Settings_PerformenceViewModel.cs @@ -1,12 +1,16 @@ using Avalonia; using Avalonia.Controls; +using Common.BasicHelper.IO; +using KitX_Dashboard.Commands; using KitX_Dashboard.Data; using KitX_Dashboard.Models; using KitX_Dashboard.Services; using Serilog; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; +using System.Threading; #pragma warning disable CS8604 // 引用类型参数可能为 null。 @@ -18,6 +22,8 @@ internal class Settings_PerformenceViewModel : ViewModelBase, INotifyPropertyCha internal Settings_PerformenceViewModel() { InitEvents(); + + InitCommands(); } private void InitEvents() @@ -52,6 +58,12 @@ private void InitEvents() }; } + private void InitCommands() + { + EmptyLogsCommand = new(EmptyLogs); + RefreshLogsUsageCommand = new(RefreshLogsUsage); + } + /// /// 保存变更 /// @@ -110,6 +122,13 @@ internal static bool LogReletiveAreaExpanded } } + /// + /// 日志文件空间占用 + /// 单位, MB + /// + internal static int LogFileSizeUsage => (int)(DirectoryHelper.GetDirectorySize + (Path.GetFullPath(Program.Config.Log.LogFilePath)) / 1000 / 1024); + /// /// 单个文件体积限制上限 /// @@ -243,6 +262,46 @@ internal SurpportLogLevel? CurrentLogLevel } } + /// + /// 清空日志命令 + /// + internal DelegateCommand? EmptyLogsCommand { get; set; } + + /// + /// 刷新日志占用命令 + /// + internal DelegateCommand? RefreshLogsUsageCommand { get; set; } + + private void EmptyLogs(object obj) + { + try + { + new Thread(() => + { + DirectoryInfo dir = new(Path.GetFullPath(Program.Config.Log.LogFilePath)); + foreach (var file in dir.GetFiles()) + { + try + { + File.Delete(file.FullName); + } + catch (Exception ex) + { + Log.Error(ex, $"In Settings_Performence.EmptyLogs(): {ex.Message}"); + } + } + PropertyChanged?.Invoke(this, new(nameof(LogFileSizeUsage))); + }).Start(); + } + catch (Exception ex) + { + Log.Error(ex, $"In Settings_Performence.EmptyLogs(): {ex.Message}"); + } + } + + private void RefreshLogsUsage(object obj) => + PropertyChanged?.Invoke(this, new(nameof(LogFileSizeUsage))); + public new event PropertyChangedEventHandler? PropertyChanged; } } diff --git a/Views/Pages/Controls/Settings_Performence.axaml b/Views/Pages/Controls/Settings_Performence.axaml index cf330745..800f1840 100644 --- a/Views/Pages/Controls/Settings_Performence.axaml +++ b/Views/Pages/Controls/Settings_Performence.axaml @@ -129,7 +129,47 @@ - + + + + + + + + + + + public static void Exit() { + Log.CloseAndFlush(); + Program.WebManager?.Stop(); Program.WebManager?.Dispose(); diff --git a/KitX Dashboard.csproj b/KitX Dashboard.csproj index bf059548..0741e22b 100644 --- a/KitX Dashboard.csproj +++ b/KitX Dashboard.csproj @@ -125,16 +125,16 @@ - + - + - + - + From 18c9c285ba1c58d0e5c7c9ef1403b7b5d2c3e5b0 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Thu, 15 Dec 2022 13:07:22 +0800 Subject: [PATCH 12/26] =?UTF-8?q?=F0=9F=8E=87=20Style:=20=E7=94=A8=20Style?= =?UTF-8?q?=20=E7=AE=80=E5=8C=96=E4=BB=A3=E7=A0=81=E8=A1=8C=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Controls/Settings_Performence.axaml | 153 ++++++------------ 1 file changed, 53 insertions(+), 100 deletions(-) diff --git a/Views/Pages/Controls/Settings_Performence.axaml b/Views/Pages/Controls/Settings_Performence.axaml index 800f1840..2b3c33a8 100644 --- a/Views/Pages/Controls/Settings_Performence.axaml +++ b/Views/Pages/Controls/Settings_Performence.axaml @@ -10,6 +10,30 @@ d:DesignWidth="800" mc:Ignorable="d"> + + + + + + + @@ -22,19 +46,12 @@ IsIconVisible="False" IsOpen="True"> - + - + - @@ -47,19 +64,12 @@ IsIconVisible="False" IsOpen="True"> - + - + - @@ -72,19 +82,12 @@ IsIconVisible="False" IsOpen="True"> - + - + - + @@ -95,19 +98,12 @@ IsIconVisible="False" IsOpen="True"> - + - + - - + @@ -139,9 +133,7 @@ - + - @@ -174,13 +161,9 @@ IsIconVisible="False" IsOpen="True"> - + - + - @@ -206,19 +186,12 @@ IsIconVisible="False" IsOpen="True"> - + - + - @@ -231,25 +204,16 @@ IsIconVisible="False" IsOpen="True"> - + - + - @@ -262,13 +226,9 @@ IsIconVisible="False" IsOpen="True"> - + - + - + @@ -300,19 +258,14 @@ IsIconVisible="False" IsOpen="True"> - + - Date: Thu, 15 Dec 2022 18:05:37 +0800 Subject: [PATCH 13/26] =?UTF-8?q?=F0=9F=92=BE=20=F0=9F=93=9D=20Feat,=20Cho?= =?UTF-8?q?re:=20=E6=8B=9B=E5=91=BC=E8=AF=AD=E5=8F=B3=E9=94=AE=E5=88=B7?= =?UTF-8?q?=E6=96=B0,=20Windows=20=E5=B9=B3=E5=8F=B0=E5=BC=95=E5=85=A5?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5=E5=B9=B6?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=A4=9A=E5=8F=91=E5=B8=83=E7=9B=AE=E6=A0=87?= =?UTF-8?q?=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KitX Dashboard.csproj | 9 ++- Program.cs | 6 +- .../linux-arm-single-cut.pubxml | 25 ++++--- .../PublishProfiles/linux-arm-single.pubxml | 25 ++++--- .../linux-arm64-single-cut.pubxml | 25 ++++--- .../PublishProfiles/linux-arm64-single.pubxml | 25 ++++--- .../linux-x64-single-cut.pubxml | 25 ++++--- .../PublishProfiles/linux-x64-single.pubxml | 25 ++++--- .../PublishProfiles/osx-x64-single-cut.pubxml | 25 ++++--- .../PublishProfiles/osx-x64-single.pubxml | 25 ++++--- .../PublishProfiles/win-x64-single-cut.pubxml | 27 +++---- .../PublishProfiles/win-x64-single.pubxml | 27 +++---- Properties/PublishProfiles/win-x64.pubxml | 25 ++++--- .../PublishProfiles/win-x86-single-cut.pubxml | 27 +++---- .../PublishProfiles/win-x86-single.pubxml | 27 +++---- Properties/PublishProfiles/win-x86.pubxml | 25 ++++--- ViewModels/MainWindowViewModel.cs | 36 ++++++++- Views/MainWindow.axaml | 74 +++++++++---------- Views/MainWindow.axaml.cs | 2 +- 19 files changed, 270 insertions(+), 215 deletions(-) diff --git a/KitX Dashboard.csproj b/KitX Dashboard.csproj index 0741e22b..68a0a773 100644 --- a/KitX Dashboard.csproj +++ b/KitX Dashboard.csproj @@ -1,7 +1,9 @@  WinExe - net6.0 + True + net6.0 + net6.0-windows10.0.17763.0 enable copyused true @@ -13,6 +15,10 @@ 3.22.04.$([System.DateTime]::UtcNow.Date.Subtract($([System.DateTime]::Parse("2005-07-16"))).TotalDays) + + IsBuild4WindowsPlatform + + @@ -129,6 +135,7 @@ + diff --git a/Program.cs b/Program.cs index 15a40d44..2fbaef45 100644 --- a/Program.cs +++ b/Program.cs @@ -1,5 +1,6 @@ using Avalonia; using Avalonia.ReactiveUI; +using DesktopNotifications.Avalonia; using KitX_Dashboard.Data; using KitX_Dashboard.Services; using KitX_Dashboard.Views; @@ -147,10 +148,13 @@ public static void Main(string[] args) /// Avalonia 配置项, 请不要删除; 同时也用于可视化设计器 public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect().LogToTrace().UseReactiveUI() +#if (IsBuild4WindowsPlatform == true) + .SetupDesktopNotifications() +#endif .With(new Win32PlatformOptions { UseWindowsUIComposition = true, - EnableMultitouch = true + EnableMultitouch = true, }) .With(new MacOSPlatformOptions { diff --git a/Properties/PublishProfiles/linux-arm-single-cut.pubxml b/Properties/PublishProfiles/linux-arm-single-cut.pubxml index d3b878fe..8ab4175a 100644 --- a/Properties/PublishProfiles/linux-arm-single-cut.pubxml +++ b/Properties/PublishProfiles/linux-arm-single-cut.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-linux-arm-single-cut\ - FileSystem - net6.0 - linux-arm - true - false - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-linux-arm-single-cut\ + FileSystem + net6.0 + linux-arm + true + false + true + False + + diff --git a/Properties/PublishProfiles/linux-arm-single.pubxml b/Properties/PublishProfiles/linux-arm-single.pubxml index c3557162..259063a9 100644 --- a/Properties/PublishProfiles/linux-arm-single.pubxml +++ b/Properties/PublishProfiles/linux-arm-single.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-linux-arm-single\ - FileSystem - net6.0 - linux-arm - true - false - false - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-linux-arm-single\ + FileSystem + net6.0 + linux-arm + true + false + false + False + + diff --git a/Properties/PublishProfiles/linux-arm64-single-cut.pubxml b/Properties/PublishProfiles/linux-arm64-single-cut.pubxml index 7c139c18..74438287 100644 --- a/Properties/PublishProfiles/linux-arm64-single-cut.pubxml +++ b/Properties/PublishProfiles/linux-arm64-single-cut.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-linux-arm64-single-cut\ - FileSystem - net6.0 - linux-arm64 - true - false - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-linux-arm64-single-cut\ + FileSystem + net6.0 + linux-arm64 + true + false + true + False + + diff --git a/Properties/PublishProfiles/linux-arm64-single.pubxml b/Properties/PublishProfiles/linux-arm64-single.pubxml index 4de84fa1..107b2de0 100644 --- a/Properties/PublishProfiles/linux-arm64-single.pubxml +++ b/Properties/PublishProfiles/linux-arm64-single.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-linux-arm64-single\ - FileSystem - net6.0 - linux-arm64 - true - false - false - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-linux-arm64-single\ + FileSystem + net6.0 + linux-arm64 + true + false + false + False + + diff --git a/Properties/PublishProfiles/linux-x64-single-cut.pubxml b/Properties/PublishProfiles/linux-x64-single-cut.pubxml index 86037ba9..191e1ac6 100644 --- a/Properties/PublishProfiles/linux-x64-single-cut.pubxml +++ b/Properties/PublishProfiles/linux-x64-single-cut.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-linux-x64-single-cut\ - FileSystem - net6.0 - linux-x64 - true - false - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-linux-x64-single-cut\ + FileSystem + net6.0 + linux-x64 + true + false + true + False + + diff --git a/Properties/PublishProfiles/linux-x64-single.pubxml b/Properties/PublishProfiles/linux-x64-single.pubxml index a0d80c5d..fef21fa6 100644 --- a/Properties/PublishProfiles/linux-x64-single.pubxml +++ b/Properties/PublishProfiles/linux-x64-single.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-linux-x64-single\ - FileSystem - net6.0 - linux-x64 - true - false - false - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-linux-x64-single\ + FileSystem + net6.0 + linux-x64 + true + false + false + False + + diff --git a/Properties/PublishProfiles/osx-x64-single-cut.pubxml b/Properties/PublishProfiles/osx-x64-single-cut.pubxml index e3e62105..c34eacae 100644 --- a/Properties/PublishProfiles/osx-x64-single-cut.pubxml +++ b/Properties/PublishProfiles/osx-x64-single-cut.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-osx-x64-single-cut\ - FileSystem - net6.0 - osx-x64 - true - false - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-osx-x64-single-cut\ + FileSystem + net6.0 + osx-x64 + true + false + true + False + + diff --git a/Properties/PublishProfiles/osx-x64-single.pubxml b/Properties/PublishProfiles/osx-x64-single.pubxml index fd090cd7..ae7928e2 100644 --- a/Properties/PublishProfiles/osx-x64-single.pubxml +++ b/Properties/PublishProfiles/osx-x64-single.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-osx-x64-single\ - FileSystem - net6.0 - osx-x64 - true - false - false - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-osx-x64-single\ + FileSystem + net6.0 + osx-x64 + true + false + false + False + + diff --git a/Properties/PublishProfiles/win-x64-single-cut.pubxml b/Properties/PublishProfiles/win-x64-single-cut.pubxml index e38d1644..28f8f21c 100644 --- a/Properties/PublishProfiles/win-x64-single-cut.pubxml +++ b/Properties/PublishProfiles/win-x64-single-cut.pubxml @@ -3,16 +3,17 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-win-x64-single-cut\ - FileSystem - net6.0 - win-x64 - true - false - true - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-win-x64-single-cut\ + FileSystem + net6.0 + win-x64 + true + false + true + true + True + + diff --git a/Properties/PublishProfiles/win-x64-single.pubxml b/Properties/PublishProfiles/win-x64-single.pubxml index 8cb67fad..b8ca66e8 100644 --- a/Properties/PublishProfiles/win-x64-single.pubxml +++ b/Properties/PublishProfiles/win-x64-single.pubxml @@ -3,16 +3,17 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-win-x64-single\ - FileSystem - net6.0 - win-x64 - true - false - true - false - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-win-x64-single\ + FileSystem + net6.0 + win-x64 + true + false + true + false + True + + diff --git a/Properties/PublishProfiles/win-x64.pubxml b/Properties/PublishProfiles/win-x64.pubxml index f9c8d4d4..d1c8975f 100644 --- a/Properties/PublishProfiles/win-x64.pubxml +++ b/Properties/PublishProfiles/win-x64.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-win-x64\ - FileSystem - net6.0 - win-x64 - false - false - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-win-x64\ + FileSystem + net6.0 + win-x64 + false + false + true + True + + diff --git a/Properties/PublishProfiles/win-x86-single-cut.pubxml b/Properties/PublishProfiles/win-x86-single-cut.pubxml index a6429432..c9478614 100644 --- a/Properties/PublishProfiles/win-x86-single-cut.pubxml +++ b/Properties/PublishProfiles/win-x86-single-cut.pubxml @@ -3,16 +3,17 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-win-x86-single-cut\ - FileSystem - net6.0 - win-x86 - true - false - true - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-win-x86-single-cut\ + FileSystem + net6.0 + win-x86 + true + false + true + true + True + + diff --git a/Properties/PublishProfiles/win-x86-single.pubxml b/Properties/PublishProfiles/win-x86-single.pubxml index c1d99955..edbc238e 100644 --- a/Properties/PublishProfiles/win-x86-single.pubxml +++ b/Properties/PublishProfiles/win-x86-single.pubxml @@ -3,16 +3,17 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-win-x86-single\ - FileSystem - net6.0 - win-x86 - true - false - true - false - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-win-x86-single\ + FileSystem + net6.0 + win-x86 + true + false + true + false + True + + diff --git a/Properties/PublishProfiles/win-x86.pubxml b/Properties/PublishProfiles/win-x86.pubxml index 66b241a8..5849b77f 100644 --- a/Properties/PublishProfiles/win-x86.pubxml +++ b/Properties/PublishProfiles/win-x86.pubxml @@ -3,15 +3,16 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - - Release - Any CPU - ..\KitX Publish\kitx-win-x86\ - FileSystem - net6.0 - win-x86 - false - false - true - - \ No newline at end of file + + Release + Any CPU + ..\KitX Publish\kitx-win-x86\ + FileSystem + net6.0 + win-x86 + false + false + true + True + + diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index 7b6ce5c1..bb7a6a62 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -1,15 +1,21 @@ -using Avalonia.Controls; +using Avalonia; +using Avalonia.Controls; +using DesktopNotifications; using KitX_Dashboard.Commands; using KitX_Dashboard.Data; using KitX_Dashboard.Services; using KitX_Dashboard.Views; +using Serilog; using System; +using System.IO; using System.Threading; namespace KitX_Dashboard.ViewModels { internal class MainWindowViewModel : ViewModelBase { + private static bool _firstTime2RefreshGreeting = true; + public MainWindowViewModel() { InitCommands(); @@ -19,12 +25,15 @@ internal void InitCommands() { TrayIconClickedCommand = new(TrayIconClicked); ExitCommand = new(Exit); + RefreshGreetingCommand = new(RefreshGreeting); } internal DelegateCommand? TrayIconClickedCommand { get; set; } internal DelegateCommand? ExitCommand { get; set; } + internal DelegateCommand? RefreshGreetingCommand { get; set; } + internal void TrayIconClicked(object mainWindow) { MainWindow? win = mainWindow as MainWindow; @@ -47,6 +56,31 @@ internal void Exit(object mainWindow) Environment.Exit(0); }).Start(); } + + internal void RefreshGreeting(object mainWindow) + { + MainWindow? win = mainWindow as MainWindow; + win?.UpdateGreetingText(); + if (_firstTime2RefreshGreeting) + { + _firstTime2RefreshGreeting = false; + try + { + var notificationManager = + AvaloniaLocator.Current.GetService() + ?? throw new InvalidDataException("Missing notification manager."); + notificationManager.ShowNotification(new() + { + Title = GlobalInfo.AppName, + Body = "(ノω<。)ノ))☆.。", + }); + } + catch (Exception ex) + { + Log.Warning(ex, ex.Message); + } + } + } } } diff --git a/Views/MainWindow.axaml b/Views/MainWindow.axaml index 90e2fb63..f668d172 100644 --- a/Views/MainWindow.axaml +++ b/Views/MainWindow.axaml @@ -18,7 +18,17 @@ Icon="avares://KitX.Assets/KitX-Icon-32x32.png" mc:Ignorable="d"> - + + + + @@ -50,8 +60,6 @@ - - - + @@ -80,14 +85,11 @@ Tag="Page_Lib" ToolTip.Tip="{DynamicResource Text_MainWindow_NavigationView_Lib}"> - + @@ -96,14 +98,11 @@ Tag="Page_Repo" ToolTip.Tip="{DynamicResource Text_MainWindow_NavigationView_Repo}"> - + @@ -112,14 +111,11 @@ Tag="Page_Device" ToolTip.Tip="{DynamicResource Text_MainWindow_NavigationView_Devices}"> - + @@ -131,14 +127,11 @@ Tag="Page_Market" ToolTip.Tip="{DynamicResource Text_MainWindow_NavigationView_Market}"> - + @@ -147,14 +140,11 @@ Tag="Page_Account" ToolTip.Tip="{DynamicResource Text_MainWindow_NavigationView_Account}"> - + @@ -163,14 +153,11 @@ Tag="Page_Settings" ToolTip.Tip="{DynamicResource Text_MainWindow_NavigationView_Settings}"> - + @@ -179,9 +166,18 @@ + TextWrapping="Wrap"> + + + + + + diff --git a/Views/MainWindow.axaml.cs b/Views/MainWindow.axaml.cs index 3bb7186b..392e6952 100644 --- a/Views/MainWindow.axaml.cs +++ b/Views/MainWindow.axaml.cs @@ -178,7 +178,7 @@ private static void SaveChanges() /// /// 更新招呼语 /// - private void UpdateGreetingText() + internal void UpdateGreetingText() { try { From c948ad2644ff8a8f39927658e7a01527823dc5e0 Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Thu, 15 Dec 2022 18:06:03 +0800 Subject: [PATCH 14/26] =?UTF-8?q?=F0=9F=92=BE=20Feat(Languages):=20?= =?UTF-8?q?=E5=88=86=E9=92=9F,=20=E5=B0=8F=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Languages/en-us.axaml | 2 ++ Languages/fr-fr.axaml | 2 ++ Languages/ja-jp.axaml | 2 ++ Languages/ko-kr.axaml | 2 ++ Languages/ru-ru.axaml | 2 ++ Languages/zh-cn.axaml | 2 ++ Languages/zh-tw.axaml | 2 ++ 7 files changed, 14 insertions(+) diff --git a/Languages/en-us.axaml b/Languages/en-us.axaml index e9be8753..41d6acc1 100644 --- a/Languages/en-us.axaml +++ b/Languages/en-us.axaml @@ -13,6 +13,8 @@ Exit Show Main Window s + minute + hour Tip Delete Replace diff --git a/Languages/fr-fr.axaml b/Languages/fr-fr.axaml index 6f5cb95c..f4957f18 100644 --- a/Languages/fr-fr.axaml +++ b/Languages/fr-fr.axaml @@ -13,6 +13,8 @@ quitter Afficher la fenêtre principale deuxième + minute + Heure indice effacer remplacer diff --git a/Languages/ja-jp.axaml b/Languages/ja-jp.axaml index d32df8aa..a23bc6a5 100644 --- a/Languages/ja-jp.axaml +++ b/Languages/ja-jp.axaml @@ -13,6 +13,8 @@ 終了する メインウィンドウを表示 2番目 + + 時間 ヒント 消去 交換 diff --git a/Languages/ko-kr.axaml b/Languages/ko-kr.axaml index 75bb8d82..04a2c17d 100644 --- a/Languages/ko-kr.axaml +++ b/Languages/ko-kr.axaml @@ -13,6 +13,8 @@ 그만두다 메인 창 표시 + + 힌트 삭제 바꾸다 diff --git a/Languages/ru-ru.axaml b/Languages/ru-ru.axaml index 9f32f4f7..59114e88 100644 --- a/Languages/ru-ru.axaml +++ b/Languages/ru-ru.axaml @@ -13,6 +13,8 @@ покидать Показать главное окно второй + минута + Час намекать Удалить заменять diff --git a/Languages/zh-cn.axaml b/Languages/zh-cn.axaml index ace335c3..eedbc87e 100644 --- a/Languages/zh-cn.axaml +++ b/Languages/zh-cn.axaml @@ -13,6 +13,8 @@ 退出 显示主窗口 + 分钟 + 小时 提示 删除 替换 diff --git a/Languages/zh-tw.axaml b/Languages/zh-tw.axaml index f39bc338..a99c018d 100644 --- a/Languages/zh-tw.axaml +++ b/Languages/zh-tw.axaml @@ -13,6 +13,8 @@ 退出 顯示主窗口 + 分鐘 + 小時 提示 刪除 替換 From 1f171854d73fe8200bc3f49aabc4151eac0db6bc Mon Sep 17 00:00:00 2001 From: Dynesshely Date: Thu, 15 Dec 2022 18:06:30 +0800 Subject: [PATCH 15/26] =?UTF-8?q?=F0=9F=8E=87=20Style:=20=E7=94=A8=20Style?= =?UTF-8?q?=20=E5=87=8F=E5=B0=91=E9=87=8D=E5=A4=8D=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=E7=BC=96=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Pages/Controls/Settings_Performence.axaml | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/Views/Pages/Controls/Settings_Performence.axaml b/Views/Pages/Controls/Settings_Performence.axaml index 2b3c33a8..03451488 100644 --- a/Views/Pages/Controls/Settings_Performence.axaml +++ b/Views/Pages/Controls/Settings_Performence.axaml @@ -23,7 +23,7 @@ - @@ -48,7 +48,7 @@ - + - + - + @@ -100,9 +100,14 @@ - + + - + @@ -135,9 +140,7 @@ - +