feat: Implement module dependency management and unsaved changes tracking

- Added `HasUnsavedChanges` property to `ClassConfigEditorControl` and `ClassMacrosEditorControl` to track unsaved changes.
- Introduced `ModuleDependencyService` for handling module dependencies, including capturing and importing configurations and macros.
- Implemented atomic file writing in `AtomicFile` to ensure safe file operations.
- Enhanced `MainForm` to check for unsaved changes before importing module dependencies and added feedback mechanisms for users.
- Updated `ModuleEditorControl` to support dependency capturing and module reloading.
- Created data structures for module dependency snapshots, configurations, and macros.
- Improved error handling and user notifications during module import processes.
This commit is contained in:
waynebian01
2026-08-14 17:36:45 +08:00
parent 41c257b8c1
commit 99300fb702
13 changed files with 1102 additions and 28 deletions

View File

@@ -24,6 +24,7 @@ public sealed class ModuleDefinition
public List<ModuleCountField> Counts { get; set; } = new();
public List<ModuleValueAdjustment> ValueAdjustments { get; set; } = new();
public List<ModuleRule> Rules { get; set; } = new();
public ModuleDependencySnapshot? Dependencies { get; set; }
[JsonIgnore]
public string? FilePath { get; set; }
@@ -44,7 +45,8 @@ public sealed class ModuleDefinition
Units = Units.Select(unit => unit.Clone()).ToList(),
Counts = Counts.Select(count => count.Clone()).ToList(),
ValueAdjustments = ValueAdjustments.Select(adjustment => adjustment.Clone()).ToList(),
Rules = Rules.Select(rule => rule.Clone()).ToList()
Rules = Rules.Select(rule => rule.Clone()).ToList(),
Dependencies = Dependencies?.Clone()
};
}
@@ -306,6 +308,20 @@ public sealed class ModuleStore
}
}
public void RejectModules(IEnumerable<string> moduleIds)
{
var rejected = new HashSet<string>(moduleIds, StringComparer.OrdinalIgnoreCase);
if (rejected.Count == 0)
{
return;
}
lock (_gate)
{
_modules.RemoveAll(module => rejected.Contains(module.Id));
}
}
public void Reload()
{
lock (_gate)