You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
using AIK.Common.Interface;
|
|
using AIK.Common.Language;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AIKKey
|
|
{
|
|
public class SettingsService : ISettingsService
|
|
{
|
|
public UserPreferences Load()
|
|
{
|
|
var prefs = new UserPreferences
|
|
{
|
|
Language = AIK.Common.Properties.Settings.Default.Language ?? "zh",
|
|
DeviceId = AIK.Common.Properties.Settings.Default.DeviceId ?? string.Empty
|
|
};
|
|
|
|
// 首次启动自动生成设备 UUID
|
|
if (string.IsNullOrEmpty(prefs.DeviceId))
|
|
{
|
|
prefs.DeviceId = Guid.NewGuid().ToString("D").ToLowerInvariant();
|
|
Save(prefs);
|
|
}
|
|
|
|
return prefs;
|
|
}
|
|
|
|
public void Save(UserPreferences settings)
|
|
{
|
|
AIK.Common.Properties.Settings.Default.Language = settings.Language;
|
|
AIK.Common.Properties.Settings.Default.DeviceId = settings.DeviceId;
|
|
AIK.Common.Properties.Settings.Default.Save(); // 安全写入用户目录
|
|
}
|
|
}
|
|
}
|
|
|