feat: 更新地理位置定位器设置
This commit is contained in:
parent
18ace08ea9
commit
f68ec04269
|
@ -108,7 +108,8 @@ public class AppInfo
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string? Ip { get; set; }
|
||||
[Display(Name = "地理位置定位器")]
|
||||
public string? IpLocator { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
|
|
|
@ -316,13 +316,13 @@ class DictService : IDict
|
|||
|
||||
public bool SaveAutoLockScreenInterval(int value) => SaveDict(new Dict { Category = "网站设置", Name = "自动锁屏时长", Code = value.ToString() });
|
||||
|
||||
public Dictionary<string, string> GetIps()
|
||||
public Dictionary<string, string> GetIpLocators()
|
||||
{
|
||||
var dicts = GetAll();
|
||||
return dicts.Where(d => d.Category == "地理位置服务").Select(d => new KeyValuePair<string, string>(d.Code, d.Name)).OrderBy(i => i.Value).ToDictionary(i => i.Key, i => i.Value);
|
||||
}
|
||||
|
||||
public string? GetCurrentIp()
|
||||
public string? GetIpLocator()
|
||||
{
|
||||
var dicts = GetAll();
|
||||
return dicts.FirstOrDefault(s => s.Category == "网站设置" && s.Name == "IP地理位置接口" && s.Define == EnumDictDefine.System)?.Code;
|
||||
|
|
|
@ -282,13 +282,13 @@ public interface IDict
|
|||
/// 获得地理位置服务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Dictionary<string, string> GetIps();
|
||||
Dictionary<string, string> GetIpLocators();
|
||||
|
||||
/// <summary>
|
||||
/// 获得当前地理位置服务
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
string? GetCurrentIp();
|
||||
string? GetIpLocator();
|
||||
|
||||
/// <summary>
|
||||
/// 设置当前地理位置服务
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
<ValidateForm OnValidSubmit="SaveAdressInfo" Model="AppInfo">
|
||||
<div class="row g-3 form-inline">
|
||||
<div class="col-6 col-sm-6">
|
||||
<Dropdown Items="@IPs" @bind-Value="AppInfo.Ip" ShowLabel="false"></Dropdown>
|
||||
<Dropdown Items="@IPLocators" @bind-Value="AppInfo.IpLocator" ShowLabel="false"></Dropdown>
|
||||
</div>
|
||||
<div class="col-6 col-sm-6 text-end">
|
||||
<Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
|
||||
|
|
|
@ -23,7 +23,7 @@ public partial class Settings
|
|||
private List<SelectedItem>? Themes { get; set; }
|
||||
|
||||
[NotNull]
|
||||
private List<SelectedItem>? IPs { get; set; }
|
||||
private List<SelectedItem>? IPLocators { get; set; }
|
||||
|
||||
[Inject]
|
||||
[NotNull]
|
||||
|
@ -54,7 +54,9 @@ public partial class Settings
|
|||
IsDemo = DictService.IsDemo();
|
||||
Logins = DictService.GetLogins().ToSelectedItemList();
|
||||
Themes = DictService.GetThemes().ToSelectedItemList();
|
||||
IPs = DictService.GetIps().ToSelectedItemList();
|
||||
IPLocators = DictService.GetIpLocators().ToSelectedItemList();
|
||||
IPLocators.Insert(0, new SelectedItem("", "未选择"));
|
||||
|
||||
AppInfo = new()
|
||||
{
|
||||
IsDemo = IsDemo,
|
||||
|
@ -76,7 +78,8 @@ public partial class Settings
|
|||
LoginExpired = DictService.GetLoginExpired(),
|
||||
AccessExpired = DictService.GetAccessExpired(),
|
||||
CookieExpired = DictService.GetCookieExpiresPeriod(),
|
||||
IPCacheExpired = DictService.GetIPCacheExpired()
|
||||
IPCacheExpired = DictService.GetIPCacheExpired(),
|
||||
IpLocator = DictService.GetIpLocator()
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -159,7 +162,7 @@ public partial class Settings
|
|||
|
||||
private async Task SaveAdressInfo(EditContext context)
|
||||
{
|
||||
var ret = DictService.SaveCurrentIp(AppInfo.Ip!);
|
||||
var ret = DictService.SaveCurrentIp(AppInfo.IpLocator!);
|
||||
await ShowToast(ret, "地理位置");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue