Skip to content

Commit 2fd1c87

Browse files
committed
feat: 文件编辑功能实装
1 parent b5710e8 commit 2fd1c87

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

Moder.Core/ViewsModels/Game/StateFileControlViewModel.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public sealed partial class StateFileControlViewModel : ObservableObject
2525
private readonly SystemFileItem _fileItem;
2626
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
2727
private readonly LeafConverterService _leafConverterService;
28+
29+
private static readonly UTF8Encoding Encoding = new(false);
2830

2931
public StateFileControlViewModel(
3032
GlobalResourceService resourceService,
@@ -158,6 +160,7 @@ private void SaveData()
158160
// TODO: 数值有效性检查, int, float, bool
159161
var rootNode = VoConvertToNode(_fileItem.Name, _rootNodeVo.Children.ToArray());
160162
var text = rootNode.PrintChildren();
163+
File.WriteAllText(_fileItem.FullPath, text, Encoding);
161164
var elapsedTime = Stopwatch.GetElapsedTime(timestamp);
162165
Log.Info("保存成功, 耗时: {Time} ms", elapsedTime.TotalMilliseconds);
163166
Log.Debug("Content: {Content}", text);

0 commit comments

Comments
 (0)