From ffa321a5fc1f183568ca08a1ec56ac6c9775127f Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Thu, 10 Jul 2025 17:48:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E8=AE=B0=E5=BF=86=E4=B8=8A=E6=AC=A1?= =?UTF-8?q?=E8=A2=AB=E9=80=89=E6=8B=A9=E7=9A=84=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 18 ++++++++++++ H5MotaUpdate.csproj | 15 ++++++++++ Properties/Settings.Designer.cs | 50 +++++++++++++++++++++++++++++++++ Properties/Settings.settings | 12 ++++++++ ViewModels/MainViewModel.cs | 13 +++++++++ 5 files changed, 108 insertions(+) create mode 100644 App.config create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings diff --git a/App.config b/App.config new file mode 100644 index 0000000..164954a --- /dev/null +++ b/App.config @@ -0,0 +1,18 @@ + + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/H5MotaUpdate.csproj b/H5MotaUpdate.csproj index b5d81a9..ddbd334 100644 --- a/H5MotaUpdate.csproj +++ b/H5MotaUpdate.csproj @@ -13,4 +13,19 @@ + + + True + True + Settings.settings + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs new file mode 100644 index 0000000..f60979d --- /dev/null +++ b/Properties/Settings.Designer.cs @@ -0,0 +1,50 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace H5MotaUpdate.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.11.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string LastSourceFolderPath { + get { + return ((string)(this["LastSourceFolderPath"])); + } + set { + this["LastSourceFolderPath"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string LastDestFolderPath { + get { + return ((string)(this["LastDestFolderPath"])); + } + set { + this["LastDestFolderPath"] = value; + } + } + } +} diff --git a/Properties/Settings.settings b/Properties/Settings.settings new file mode 100644 index 0000000..a29f701 --- /dev/null +++ b/Properties/Settings.settings @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 9ff7680..948b40b 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -91,10 +91,17 @@ namespace H5MotaUpdate.ViewModels { using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) { + // 设置初始路径为上一次选择的路径 + folderBrowserDialog.SelectedPath = Properties.Settings.Default.LastSourceFolderPath; + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SourceRootDirectory = folderBrowserDialog.SelectedPath; + // 保存本次选择的路径 + Properties.Settings.Default.LastSourceFolderPath = SourceRootDirectory; + Properties.Settings.Default.Save(); } + VersionString = VersionUtils.GetVersion(SourceRootDirectory); } } @@ -106,9 +113,15 @@ namespace H5MotaUpdate.ViewModels { using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) { + // 设置初始路径为上一次选择的路径 + folderBrowserDialog.SelectedPath = Properties.Settings.Default.LastDestFolderPath; + if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { DestRootDirectory = folderBrowserDialog.SelectedPath; + // 保存本次选择的路径 + Properties.Settings.Default.LastDestFolderPath = DestRootDirectory; + Properties.Settings.Default.Save(); } } }