新增打印模板管理功能,包含免密接口和实时通知机制,支持桌面端打印模板的查询和列表展示。更新相关控制器、服务和视图,优化用户体验并增强系统的实时数据同步能力。
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
namespace YY.Admin.Services.Service.Print;
|
||||
|
||||
/// <summary>
|
||||
/// 运行时可修改的 PrintDot 连接设置(由设置页写入,PrintDotService 优先读取)。
|
||||
/// </summary>
|
||||
public class PrintDotSettings
|
||||
{
|
||||
private static readonly string SettingsPath = System.IO.Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||
"YY.Admin", "print-dot-settings.json");
|
||||
|
||||
public string WsUrl { get; set; } = "ws://127.0.0.1:1122/ws";
|
||||
public string SelectedPrinter { get; set; } = string.Empty;
|
||||
|
||||
private static PrintDotSettings? _current;
|
||||
public static PrintDotSettings? Current => _current;
|
||||
|
||||
public static PrintDotSettings Load()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (System.IO.File.Exists(SettingsPath))
|
||||
{
|
||||
var json = System.IO.File.ReadAllText(SettingsPath);
|
||||
_current = System.Text.Json.JsonSerializer.Deserialize<PrintDotSettings>(json) ?? new PrintDotSettings();
|
||||
return _current;
|
||||
}
|
||||
}
|
||||
catch { /* 读取失败使用默认值 */ }
|
||||
_current = new PrintDotSettings();
|
||||
return _current;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
var dir = System.IO.Path.GetDirectoryName(SettingsPath)!;
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
var json = System.Text.Json.JsonSerializer.Serialize(this, new System.Text.Json.JsonSerializerOptions { WriteIndented = true });
|
||||
System.IO.File.WriteAllText(SettingsPath, json);
|
||||
_current = this;
|
||||
}
|
||||
catch { /* 忽略保存失败 */ }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user