更新项目配置,新增设备同步模块,优化WebSocket和Swagger配置,增强SCADA系统的免登录接口,支持数据字典项和登录日志的免登录查询与记录。调整Java编译设置,确保更好的开发体验。

This commit is contained in:
geht
2026-04-28 10:23:58 +08:00
parent bbe46dcf2d
commit 142a0bdaba
1013 changed files with 41858 additions and 28 deletions

View File

@@ -0,0 +1,42 @@
using Prism.Dialogs;
using Prism.Mvvm;
using Prism.Commands;
using System;
namespace YY.Admin.ViewModels.Dialogs
{
public class AlertDialogViewModel : BindableBase, IDialogAware
{
private string _message;
public string Message
{
get => _message;
set => SetProperty(ref _message, value);
}
public DelegateCommand CloseCommand { get; }
public AlertDialogViewModel()
{
CloseCommand = new DelegateCommand(() =>
{
// 调用 RequestClose 属性触发关闭
RequestClose.Invoke(new DialogResult(ButtonResult.OK));
});
}
public bool CanCloseDialog() => true;
public void OnDialogOpened(IDialogParameters parameters)
{
Message = parameters.GetValue<string>("message");
}
public void OnDialogClosed() { }
public string Title => "提示";
// 这里实现的是属性,不是 event
public DialogCloseListener RequestClose { get; private set; }
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YY.Admin.ViewModels.Dialogs
{
public class ConfirmDialogViewModel : BindableBase, IDialogAware
{
public string Title => "确认";
private string _message;
public string Message
{
get => _message;
set => SetProperty(ref _message, value);
}
// 这是 Prism.Dialogs 版本的 RequestClose
public DialogCloseListener RequestClose { get; private set; }
public DelegateCommand YesCommand { get; }
public DelegateCommand NoCommand { get; }
public ConfirmDialogViewModel()
{
YesCommand = new DelegateCommand(() => CloseDialog(ButtonResult.Yes));
NoCommand = new DelegateCommand(() => CloseDialog(ButtonResult.No));
}
private void CloseDialog(ButtonResult result)
{
// 触发关闭
RequestClose.Invoke(new DialogResult(result));
}
public bool CanCloseDialog() => true;
public void OnDialogOpened(IDialogParameters parameters)
{
Message = parameters.GetValue<string>("message");
}
public void OnDialogClosed() { }
}
}

View File

@@ -0,0 +1,45 @@
using Prism.Dialogs;
using Prism.Mvvm;
using System;
using System.Windows.Threading;
namespace YY.Admin.ViewModels.Dialogs
{
public class ErrorDialogViewModel : BindableBase, IDialogAware
{
public string Title => "错误";
private string _message;
public string Message
{
get => _message;
set => SetProperty(ref _message, value);
}
// 用属性来实现,而不是 event
public DialogCloseListener RequestClose { get; private set; }
public ErrorDialogViewModel()
{
// 自动关闭定时器2秒
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(2) };
timer.Tick += (s, e) =>
{
timer.Stop();
RequestClose.Invoke(new DialogResult(ButtonResult.OK));
};
timer.Start();
}
public bool CanCloseDialog() => true;
public void OnDialogOpened(IDialogParameters parameters)
{
Message = parameters.GetValue<string>("message");
}
public void OnDialogClosed()
{
}
}
}

View File

@@ -0,0 +1,115 @@
using YY.Admin.Helper;
namespace YY.Admin.ViewModels.Dialogs
{
public class ServerSettingsDialogViewModel : BindableBase, IDialogAware
{
private const string DefaultWebSocketPath = "/websocket/scada-sync";
private string _loadedWebSocketUrl = string.Empty;
private string _loadedAutoWebSocketUrl = string.Empty;
public string Title => "服务器设置";
private string _ip = "127.0.0.1";
public string Ip
{
get => _ip;
set => SetProperty(ref _ip, value);
}
private int _port = 8080;
public int Port
{
get => _port;
set => SetProperty(ref _port, value);
}
private string _webSocketUrl = string.Empty;
public string WebSocketUrl
{
get => _webSocketUrl;
set => SetProperty(ref _webSocketUrl, value);
}
private string _basePath = "/jeecg-boot";
public string BasePath
{
get => _basePath;
set => SetProperty(ref _basePath, value);
}
private string _errorMessage = string.Empty;
public string ErrorMessage
{
get => _errorMessage;
set => SetProperty(ref _errorMessage, value);
}
public DelegateCommand SaveCommand { get; }
public DelegateCommand CancelCommand { get; }
public DialogCloseListener RequestClose { get; private set; }
public ServerSettingsDialogViewModel()
{
SaveCommand = new DelegateCommand(Save);
CancelCommand = new DelegateCommand(() => RequestClose.Invoke(new DialogResult(ButtonResult.Cancel)));
}
public bool CanCloseDialog() => true;
public void OnDialogClosed() { }
public void OnDialogOpened(IDialogParameters parameters)
{
var settings = ServerSettingsStore.Load();
_loadedAutoWebSocketUrl = ServerSettingsStore.BuildDefaultWebSocketUrl(settings.BaseScheme, settings.Ip, settings.Port, settings.BasePath, settings.WebSocketPath);
Ip = settings.Ip;
Port = settings.Port;
WebSocketUrl = string.IsNullOrWhiteSpace(settings.WebSocketUrl)
? _loadedAutoWebSocketUrl
: settings.WebSocketUrl;
_loadedWebSocketUrl = WebSocketUrl;
BasePath = string.IsNullOrWhiteSpace(settings.BasePath) ? "/jeecg-boot" : settings.BasePath;
ErrorMessage = string.Empty;
}
private void Save()
{
ErrorMessage = string.Empty;
if (string.IsNullOrWhiteSpace(Ip))
{
ErrorMessage = "IP 不能为空";
return;
}
if (Port <= 0 || Port > 65535)
{
ErrorMessage = "端口号必须在 1-65535 之间";
return;
}
try
{
var basePath = BasePath?.Trim() ?? "/jeecg-boot";
var shouldAutoRebuildWs = string.IsNullOrWhiteSpace(WebSocketUrl)
|| string.Equals(WebSocketUrl.Trim(), _loadedAutoWebSocketUrl, StringComparison.OrdinalIgnoreCase)
|| string.Equals(WebSocketUrl.Trim(), _loadedWebSocketUrl, StringComparison.OrdinalIgnoreCase);
var finalWsUrl = shouldAutoRebuildWs
? ServerSettingsStore.BuildDefaultWebSocketUrl("http", Ip.Trim(), Port, basePath, DefaultWebSocketPath)
: WebSocketUrl.Trim();
ServerSettingsStore.Save(new ServerSettingsStore.ServerSettingsModel
{
Ip = Ip.Trim(),
Port = Port,
BaseScheme = "http",
BasePath = basePath,
WebSocketUrl = finalWsUrl,
WebSocketPath = DefaultWebSocketPath
});
RequestClose.Invoke(new DialogResult(ButtonResult.OK));
}
catch (Exception ex)
{
ErrorMessage = $"保存失败:{ex.Message}";
}
}
}
}

View File

@@ -0,0 +1,45 @@
using Prism.Dialogs;
using Prism.Mvvm;
using System;
using System.Windows.Threading;
namespace YY.Admin.ViewModels.Dialogs
{
public class SuccessDialogViewModel : BindableBase, IDialogAware
{
public string Title => "成功";
private string _message;
public string Message
{
get => _message;
set => SetProperty(ref _message, value);
}
// Prism.Dialogs 版本的 RequestClose 是属性,不是 event
public DialogCloseListener RequestClose { get; private set; }
public SuccessDialogViewModel()
{
// 自动关闭定时器
var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1.5) };
timer.Tick += (s, e) =>
{
timer.Stop();
RequestClose.Invoke(new DialogResult(ButtonResult.OK));
};
timer.Start();
}
public bool CanCloseDialog() => true;
public void OnDialogOpened(IDialogParameters parameters)
{
Message = parameters.GetValue<string>("message");
}
public void OnDialogClosed()
{
}
}
}

View File

@@ -0,0 +1,45 @@
using Prism.Dialogs;
using Prism.Mvvm;
using Prism.Commands;
using System;
namespace YY.Admin.ViewModels.Dialogs
{
public class WarningDialogViewModel : BindableBase, IDialogAware
{
public string Title => "警告";
private string _message;
public string Message
{
get => _message;
set => SetProperty(ref _message, value);
}
// Prism.Dialogs 版本的 RequestClose 是属性
public DialogCloseListener RequestClose { get; private set; }
public DelegateCommand CloseCommand { get; }
public WarningDialogViewModel()
{
CloseCommand = new DelegateCommand(CloseDialog);
}
private void CloseDialog()
{
RequestClose.Invoke(new DialogResult(ButtonResult.OK));
}
public bool CanCloseDialog() => true;
public void OnDialogOpened(IDialogParameters parameters)
{
Message = parameters.GetValue<string>("message");
}
public void OnDialogClosed()
{
}
}
}