78 lines
3.3 KiB
Plaintext
78 lines
3.3 KiB
Plaintext
@page "/manage/setting/login"
|
|
@page "/manage/setting"
|
|
@using Newtonsoft.Json.Linq
|
|
@using log4net
|
|
@layout SettingLayout
|
|
<div class="main">
|
|
<div class="top-row px-4">
|
|
<RadzenButton Icon="account_circle" Style="margin-left: auto;" Click="@SaveMethod">
|
|
<ChildContent>
|
|
@myText.SaveSet
|
|
</ChildContent>
|
|
</RadzenButton>
|
|
</div>
|
|
<div class="content px-4">
|
|
<RadzenCard class="rz-my-6">
|
|
<RadzenStack Orientation="Orientation.Horizontal" AlignItems="AlignItems.Start" Wrap="FlexWrap.Wrap">
|
|
<RadzenStack Orientation="Orientation.Vertical" Gap="4px">
|
|
@myText.LoginMode
|
|
<RadzenRadioButtonList Value=@loginValue TValue="int" Change=@(args => loginValue = args)>
|
|
<Items>
|
|
<RadzenRadioButtonListItem Text="@myText.SingleLogin" Value="1" />
|
|
<RadzenRadioButtonListItem Text="@myText.MultiLogin" Value="2" />
|
|
</Items>
|
|
</RadzenRadioButtonList>
|
|
</RadzenStack>
|
|
@* <RadzenStack Orientation="Orientation.Vertical" Gap="4px">
|
|
优先登录
|
|
<RadzenRadioButtonList Value=@preValue TValue="int" Change=@(args => preValue = args)>
|
|
<Items>
|
|
<RadzenRadioButtonListItem Text="操作人" Value="1" />
|
|
<RadzenRadioButtonListItem Text="审核人" Value="2" />
|
|
</Items>
|
|
</RadzenRadioButtonList>
|
|
</RadzenStack> *@
|
|
</RadzenStack>
|
|
</RadzenCard>
|
|
</div>
|
|
</div>
|
|
|
|
@inject Microsoft.Extensions.Options.IOptions<Pojo.Config.setting> setting;
|
|
@inject Microsoft.Extensions.Options.IOptions<Pojo.Config.SettingConfig> setting;
|
|
@inject NotificationService _message
|
|
@inject Toolbelt.Blazor.I18nText.I18nText I18nText;
|
|
|
|
|
|
@code {
|
|
|
|
private I18nText.local myText = new I18nText.local();
|
|
private readonly ILog logger = LogManager.GetLogger(typeof(LoginDialog));
|
|
int loginValue = 1;
|
|
// int preValue = 1;
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
loginValue = setting.Value.loginMode;
|
|
myText = await I18nText.GetTextTableAsync<I18nText.local>(this);
|
|
base.OnInitializedAsync();
|
|
}
|
|
//保存
|
|
async Task SaveMethod()
|
|
{
|
|
// 获取当前工作目录
|
|
string currentDirectory = Directory.GetCurrentDirectory();
|
|
// setting.Value.fridgeState = fridgeStateValue;
|
|
// setting.Value.alertState = alertStateValue;
|
|
// setting.Value.temperatureRange = temperatureRange;
|
|
string filePath = Path.Combine(currentDirectory, "appsettings.json");
|
|
string jsonString = File.ReadAllText(filePath);
|
|
var jsonNode = JObject.Parse(jsonString);
|
|
jsonNode["setting"]["loginMode"] = loginValue;
|
|
var options = new JsonSerializerOptions { WriteIndented = true };
|
|
File.WriteAllText(filePath, jsonNode.ToString(Newtonsoft.Json.Formatting.Indented));
|
|
_message.Notify(
|
|
new NotificationMessage { Severity = NotificationSeverity.Success, Summary = myText.Tips, Detail = myText.LoginMode, Duration = 4000 }
|
|
);
|
|
logger.Info($"修改用户登录设置");
|
|
}
|
|
}
|