1. 在 AppSettings 类中添加了 DefaultPollingInterval 属性,用于存储全局默认轮询间隔值
2. 更新了 SettingViewModel 以包含对轮询间隔设置的支持,允许用户在设置页面中修改该值 3. 修改了 VariableItemViewModel,使其在初始化时从 AppSettings 加载默认轮询间隔值 4. 更新了 SettingView.xaml,在设置页面的"通用设置"部分添加了轮询间隔配置项
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using AutoMapper;
|
||||
using DMS.Core.Models;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@@ -15,6 +16,10 @@ namespace DMS.Infrastructure.Configurations
|
||||
|
||||
public class AppSettings
|
||||
{
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
|
||||
|
||||
public DatabaseSettings Database { get; set; } = new DatabaseSettings();
|
||||
public string Theme { get; set; } = "跟随系统";
|
||||
public bool EnableS7Service { get; set; } = true;
|
||||
@@ -22,15 +27,18 @@ namespace DMS.Infrastructure.Configurations
|
||||
public bool EnableOpcUaService { get; set; } = true;
|
||||
public bool MinimizeToTrayOnClose { get; set; } = true;
|
||||
public List<MenuBean> Menus { get; set; } = new List<MenuBean>();
|
||||
public int DefaultPollingInterval { get; set; } = 30000; // 默认轮询间隔30秒
|
||||
|
||||
private static readonly string SettingsFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appSettings.json");
|
||||
|
||||
public static AppSettings Load()
|
||||
public AppSettings Load()
|
||||
{
|
||||
if (File.Exists(SettingsFilePath))
|
||||
{
|
||||
string json = File.ReadAllText(SettingsFilePath);
|
||||
return JsonConvert.DeserializeObject<AppSettings>(json);
|
||||
AppSettings appSettings = JsonConvert.DeserializeObject<AppSettings>(json);
|
||||
|
||||
return appSettings;
|
||||
}
|
||||
return new AppSettings();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user