mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
add ability to customize geetest url
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) DGP Studio. All rights reserved.
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using System.Runtime.Versioning;
|
||||||
|
|
||||||
namespace Snap.Hutao.Model.Entity;
|
namespace Snap.Hutao.Model.Entity;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -86,10 +88,16 @@ internal sealed partial class SettingEntry
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启动游戏 多倍启动
|
/// 启动游戏 多倍启动
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Obsolete("不再支持多开")]
|
||||||
public const string MultipleInstances = "Launch.MultipleInstances";
|
public const string MultipleInstances = "Launch.MultipleInstances";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 语言
|
/// 语言
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string Culture = "Culture";
|
public const string Culture = "Culture";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义极验接口
|
||||||
|
/// </summary>
|
||||||
|
public const string GeetestCustomCompositeUrl = "GeetestCustomCompositeUrl";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2274,6 +2274,87 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 请输入请求接口的 Url 复合模板 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlCompositInputHint {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlCompositInputHint", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 接口需要返回形如上方所示的 Json 数据,多余的数据会被忽略 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlReturnDataDescription1 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlReturnDataDescription1", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 "code" 为 0 时,指示验证成功,其他的值均视为验证失败 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlReturnDataDescription2 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlReturnDataDescription2", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 返回数据 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlReturnDataHeader {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlReturnDataHeader", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 {0} 将在实际请求时替换为 gt 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlSampleDescription1 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlSampleDescription1", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 {1} 将在实际请求时替换为 challenge 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlSampleDescription2 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlSampleDescription2", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 将会通过 GET 方式对接口发送请求 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlSampleDescription3 {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlSampleDescription3", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 示例 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlSampleHeader {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlSampleHeader", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 配置无感验证接口 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewDialogGeetestCustomUrlTitle {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewDialogGeetestCustomUrlTitle", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 导出 App 的本地化字符串。
|
/// 查找类似 导出 App 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -4911,6 +4992,33 @@ namespace Snap.Hutao.Resource.Localization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 配置 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewPageSettingGeetestCustomUrlAction {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewPageSettingGeetestCustomUrlAction", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 配置当请求触发人机验证时使用的验证接口 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewPageSettingGeetestCustomUrlDescription {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewPageSettingGeetestCustomUrlDescription", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 配置验证请求接口 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
internal static string ViewPageSettingGeetestCustomUrlHeader {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ViewPageSettingGeetestCustomUrlHeader", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 胡桃账号 的本地化字符串。
|
/// 查找类似 胡桃账号 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -911,6 +911,33 @@
|
|||||||
<data name="ViewDialogGachaLogUrlTitle" xml:space="preserve">
|
<data name="ViewDialogGachaLogUrlTitle" xml:space="preserve">
|
||||||
<value>手动输入祈愿记录 Url</value>
|
<value>手动输入祈愿记录 Url</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlCompositInputHint" xml:space="preserve">
|
||||||
|
<value>请输入请求接口的 Url 复合模板</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlReturnDataDescription1" xml:space="preserve">
|
||||||
|
<value>接口需要返回形如上方所示的 Json 数据,多余的数据会被忽略</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlReturnDataDescription2" xml:space="preserve">
|
||||||
|
<value>"code" 为 0 时,指示验证成功,其他的值均视为验证失败</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlReturnDataHeader" xml:space="preserve">
|
||||||
|
<value>返回数据</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlSampleDescription1" xml:space="preserve">
|
||||||
|
<value>{0} 将在实际请求时替换为 gt</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlSampleDescription2" xml:space="preserve">
|
||||||
|
<value>{1} 将在实际请求时替换为 challenge</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlSampleDescription3" xml:space="preserve">
|
||||||
|
<value>将会通过 GET 方式对接口发送请求</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlSampleHeader" xml:space="preserve">
|
||||||
|
<value>示例</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewDialogGeetestCustomUrlTitle" xml:space="preserve">
|
||||||
|
<value>配置无感验证接口</value>
|
||||||
|
</data>
|
||||||
<data name="ViewDialogImportExportApp" xml:space="preserve">
|
<data name="ViewDialogImportExportApp" xml:space="preserve">
|
||||||
<value>导出 App</value>
|
<value>导出 App</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -1790,6 +1817,15 @@
|
|||||||
<data name="ViewPageSettingGameHeader" xml:space="preserve">
|
<data name="ViewPageSettingGameHeader" xml:space="preserve">
|
||||||
<value>游戏</value>
|
<value>游戏</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ViewPageSettingGeetestCustomUrlAction" xml:space="preserve">
|
||||||
|
<value>配置</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewPageSettingGeetestCustomUrlDescription" xml:space="preserve">
|
||||||
|
<value>配置当请求触发人机验证时使用的验证接口</value>
|
||||||
|
</data>
|
||||||
|
<data name="ViewPageSettingGeetestCustomUrlHeader" xml:space="preserve">
|
||||||
|
<value>配置验证请求接口</value>
|
||||||
|
</data>
|
||||||
<data name="ViewPageSettingHutaoPassportHeader" xml:space="preserve">
|
<data name="ViewPageSettingHutaoPassportHeader" xml:space="preserve">
|
||||||
<value>胡桃账号</value>
|
<value>胡桃账号</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ internal sealed partial class AppOptions : DbStoreOptions
|
|||||||
private BackdropType? backdropType;
|
private BackdropType? backdropType;
|
||||||
private CultureInfo? currentCulture;
|
private CultureInfo? currentCulture;
|
||||||
private bool? isAdvancedLaunchOptionsEnabled;
|
private bool? isAdvancedLaunchOptionsEnabled;
|
||||||
|
private string? geetestCustomCompositeUrl;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 游戏路径
|
/// 游戏路径
|
||||||
@@ -100,6 +101,12 @@ internal sealed partial class AppOptions : DbStoreOptions
|
|||||||
set => SetOption(ref isAdvancedLaunchOptionsEnabled, SettingEntry.IsAdvancedLaunchOptionsEnabled, value);
|
set => SetOption(ref isAdvancedLaunchOptionsEnabled, SettingEntry.IsAdvancedLaunchOptionsEnabled, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GeetestCustomCompositeUrl
|
||||||
|
{
|
||||||
|
get => GetOption(ref geetestCustomCompositeUrl, SettingEntry.GeetestCustomCompositeUrl);
|
||||||
|
set => SetOption(ref geetestCustomCompositeUrl, SettingEntry.GeetestCustomCompositeUrl, value);
|
||||||
|
}
|
||||||
|
|
||||||
private static NameValue<string> ToNameValue(CultureInfo info)
|
private static NameValue<string> ToNameValue(CultureInfo info)
|
||||||
{
|
{
|
||||||
return new(info.NativeName, info.Name);
|
return new(info.NativeName, info.Name);
|
||||||
|
|||||||
@@ -142,6 +142,7 @@
|
|||||||
<None Remove="View\Dialog\GachaLogImportDialog.xaml" />
|
<None Remove="View\Dialog\GachaLogImportDialog.xaml" />
|
||||||
<None Remove="View\Dialog\GachaLogRefreshProgressDialog.xaml" />
|
<None Remove="View\Dialog\GachaLogRefreshProgressDialog.xaml" />
|
||||||
<None Remove="View\Dialog\GachaLogUrlDialog.xaml" />
|
<None Remove="View\Dialog\GachaLogUrlDialog.xaml" />
|
||||||
|
<None Remove="View\Dialog\GeetestCustomUrlDialog.xaml" />
|
||||||
<None Remove="View\Dialog\LaunchGameAccountNameDialog.xaml" />
|
<None Remove="View\Dialog\LaunchGameAccountNameDialog.xaml" />
|
||||||
<None Remove="View\Dialog\LaunchGamePackageConvertDialog.xaml" />
|
<None Remove="View\Dialog\LaunchGamePackageConvertDialog.xaml" />
|
||||||
<None Remove="View\Dialog\SignInWebViewDialog.xaml" />
|
<None Remove="View\Dialog\SignInWebViewDialog.xaml" />
|
||||||
@@ -325,6 +326,12 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Update="View\Dialog\GeetestCustomUrlDialog.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Update="View\Control\Webview2Viewer.xaml">
|
<Page Update="View\Control\Webview2Viewer.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
@@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="InputText"
|
|
||||||
Margin="0,0,0,8"
|
Margin="0,0,0,8"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
PlaceholderText="{shcm:ResourceString Name=ViewDialogAchievementArchiveCreateInputPlaceholder}"/>
|
PlaceholderText="{shcm:ResourceString Name=ViewDialogAchievementArchiveCreateInputPlaceholder}"
|
||||||
|
Text="{x:Bind Text, Mode=TwoWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</ContentDialog>
|
</ContentDialog>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Snap.Hutao.View.Dialog;
|
|||||||
/// 成就存档创建对话框
|
/// 成就存档创建对话框
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HighQuality]
|
[HighQuality]
|
||||||
|
[DependencyProperty("Text", typeof(string))]
|
||||||
internal sealed partial class AchievementArchiveCreateDialog : ContentDialog
|
internal sealed partial class AchievementArchiveCreateDialog : ContentDialog
|
||||||
{
|
{
|
||||||
private readonly ITaskContext taskContext;
|
private readonly ITaskContext taskContext;
|
||||||
@@ -33,8 +34,6 @@ internal sealed partial class AchievementArchiveCreateDialog : ContentDialog
|
|||||||
{
|
{
|
||||||
await taskContext.SwitchToMainThreadAsync();
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
ContentDialogResult result = await ShowAsync();
|
ContentDialogResult result = await ShowAsync();
|
||||||
string text = InputText.Text ?? string.Empty;
|
return new(result == ContentDialogResult.Primary, Text ?? string.Empty);
|
||||||
|
|
||||||
return new(result == ContentDialogResult.Primary, text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<TextBox
|
<TextBox
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
PlaceholderText="{shcm:ResourceString Name=ViewDialogCultivateProjectInputPlaceholder}"
|
PlaceholderText="{shcm:ResourceString Name=ViewDialogCultivateProjectInputPlaceholder}"
|
||||||
Text="{x:Bind Text, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
|
Text="{x:Bind Text, Mode=TwoWay}"/>
|
||||||
<CheckBox
|
<CheckBox
|
||||||
Margin="0,8,0,0"
|
Margin="0,8,0,0"
|
||||||
Content="{shcm:ResourceString Name=ViewDialogCultivateProjectAttachUid}"
|
Content="{shcm:ResourceString Name=ViewDialogCultivateProjectAttachUid}"
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<ContentDialog
|
||||||
|
x:Class="Snap.Hutao.View.Dialog.GeetestCustomUrlDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:shcm="using:Snap.Hutao.Control.Markup"
|
||||||
|
Title="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlTitle}"
|
||||||
|
CloseButtonText="{shcm:ResourceString Name=ContentDialogCancelCloseButtonText}"
|
||||||
|
DefaultButton="Primary"
|
||||||
|
PrimaryButtonText="{shcm:ResourceString Name=ContentDialogConfirmPrimaryButtonText}"
|
||||||
|
Style="{StaticResource DefaultContentDialogStyle}"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<StackPanel>
|
||||||
|
<TextBlock
|
||||||
|
Margin="1,0,0,5"
|
||||||
|
Style="{StaticResource BaseTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlReturnDataHeader}"/>
|
||||||
|
<Border
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Padding="0,8,8,8"
|
||||||
|
Style="{ThemeResource BorderCardStyle}">
|
||||||
|
<TextBlock FontFamily="{StaticResource CascadiaMonoAndMiSans}" Style="{StaticResource CaptionTextBlockStyle}">
|
||||||
|
<TextBlock.Inlines>
|
||||||
|
<Run Text="{} {"/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text=" "code": 0,"/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text=" "data": {"/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text=" "gt": "same gt below","/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text=" "challenge": "same challenge below","/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text=" "validate": "validation result""/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text=" }"/>
|
||||||
|
<LineBreak/>
|
||||||
|
<Run Text="{}}"/>
|
||||||
|
</TextBlock.Inlines>
|
||||||
|
</TextBlock>
|
||||||
|
</Border>
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlReturnDataDescription1}"/>
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlReturnDataDescription2}"/>
|
||||||
|
|
||||||
|
<TextBlock
|
||||||
|
Margin="1,15,0,5"
|
||||||
|
Style="{StaticResource BaseTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlSampleHeader}"/>
|
||||||
|
<Border
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Padding="8"
|
||||||
|
Style="{ThemeResource BorderCardStyle}">
|
||||||
|
<TextBlock
|
||||||
|
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="https://my.api.com/geetest?gt={0}&challenge={1}"/>
|
||||||
|
</Border>
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlSampleDescription1}"/>
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,2,0,0"
|
||||||
|
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlSampleDescription2}"/>
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,2,0,0"
|
||||||
|
FontFamily="{StaticResource CascadiaMonoAndMiSans}"
|
||||||
|
Style="{StaticResource CaptionTextBlockStyle}"
|
||||||
|
Text="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlSampleDescription3}"/>
|
||||||
|
<TextBox
|
||||||
|
Margin="0,16,0,0"
|
||||||
|
PlaceholderText="{shcm:ResourceString Name=ViewDialogGeetestCustomUrlCompositInputHint}"
|
||||||
|
Text="{x:Bind Text, Mode=TwoWay}"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
</ContentDialog>
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
// Copyright (c) DGP Studio. All rights reserved.
|
||||||
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
|
using Microsoft.UI.Xaml.Controls;
|
||||||
|
using Snap.Hutao.Service;
|
||||||
|
|
||||||
|
namespace Snap.Hutao.View.Dialog;
|
||||||
|
|
||||||
|
[DependencyProperty("Text", typeof(string))]
|
||||||
|
internal sealed partial class GeetestCustomUrlDialog : ContentDialog
|
||||||
|
{
|
||||||
|
private readonly ITaskContext taskContext;
|
||||||
|
|
||||||
|
public GeetestCustomUrlDialog(IServiceProvider serviceProvider)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
XamlRoot = serviceProvider.GetRequiredService<MainWindow>().Content.XamlRoot;
|
||||||
|
Text = serviceProvider.GetRequiredService<AppOptions>().GeetestCustomCompositeUrl;
|
||||||
|
taskContext = serviceProvider.GetRequiredService<ITaskContext>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async ValueTask<ValueResult<bool, string>> GetUrlAsync()
|
||||||
|
{
|
||||||
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
|
ContentDialogResult result = await ShowAsync();
|
||||||
|
return new(result == ContentDialogResult.Primary, Text ?? string.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -112,17 +112,6 @@
|
|||||||
SelectedItem="{Binding SelectedBackdropType, Mode=TwoWay}"/>
|
SelectedItem="{Binding SelectedBackdropType, Mode=TwoWay}"/>
|
||||||
</cwc:SettingsCard>
|
</cwc:SettingsCard>
|
||||||
|
|
||||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingGachaLogHeader}"/>
|
|
||||||
<cwc:SettingsCard
|
|
||||||
Description="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleDescription}"
|
|
||||||
Header="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleHeader}"
|
|
||||||
HeaderIcon="{shcm:FontIcon Glyph=}">
|
|
||||||
<ToggleSwitch
|
|
||||||
IsOn="{Binding Options.IsEmptyHistoryWishVisible, Mode=TwoWay}"
|
|
||||||
OffContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOff}"
|
|
||||||
OnContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOn}"/>
|
|
||||||
</cwc:SettingsCard>
|
|
||||||
|
|
||||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingGameHeader}"/>
|
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingGameHeader}"/>
|
||||||
<InfoBar
|
<InfoBar
|
||||||
IsClosable="False"
|
IsClosable="False"
|
||||||
@@ -146,6 +135,27 @@
|
|||||||
HeaderIcon="{shcm:FontIcon Glyph=}"
|
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||||
IsClickEnabled="True"/>
|
IsClickEnabled="True"/>
|
||||||
|
|
||||||
|
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingGachaLogHeader}"/>
|
||||||
|
<cwc:SettingsCard
|
||||||
|
Description="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleDescription}"
|
||||||
|
Header="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleHeader}"
|
||||||
|
HeaderIcon="{shcm:FontIcon Glyph=}">
|
||||||
|
<ToggleSwitch
|
||||||
|
IsOn="{Binding Options.IsEmptyHistoryWishVisible, Mode=TwoWay}"
|
||||||
|
OffContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOff}"
|
||||||
|
OnContent="{shcm:ResourceString Name=ViewPageSettingEmptyHistoryVisibleOn}"/>
|
||||||
|
</cwc:SettingsCard>
|
||||||
|
|
||||||
|
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="无感验证"/>
|
||||||
|
<cwc:SettingsCard
|
||||||
|
ActionIcon="{shcm:FontIcon Glyph=}"
|
||||||
|
ActionIconToolTip="{shcm:ResourceString Name=ViewPageSettingGeetestCustomUrlAction}"
|
||||||
|
Command="{Binding ConfigureGeetestUrlCommand}"
|
||||||
|
Description="{shcm:ResourceString Name=ViewPageSettingGeetestCustomUrlDescription}"
|
||||||
|
Header="{shcm:ResourceString Name=ViewPageSettingGeetestCustomUrlHeader}"
|
||||||
|
HeaderIcon="{shcm:FontIcon Glyph=}"
|
||||||
|
IsClickEnabled="True"/>
|
||||||
|
|
||||||
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingStorageHeader}"/>
|
<TextBlock Style="{StaticResource SettingsSectionHeaderTextBlockStyle}" Text="{shcm:ResourceString Name=ViewPageSettingStorageHeader}"/>
|
||||||
<cwc:SettingsCard
|
<cwc:SettingsCard
|
||||||
ActionIcon="{shcm:FontIcon Glyph=}"
|
ActionIcon="{shcm:FontIcon Glyph=}"
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ using Snap.Hutao.Service.Hutao;
|
|||||||
using Snap.Hutao.Service.Navigation;
|
using Snap.Hutao.Service.Navigation;
|
||||||
using Snap.Hutao.Service.Notification;
|
using Snap.Hutao.Service.Notification;
|
||||||
using Snap.Hutao.Service.User;
|
using Snap.Hutao.Service.User;
|
||||||
|
using Snap.Hutao.View.Dialog;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -41,7 +42,7 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
|
|||||||
private readonly IUserService userService;
|
private readonly IUserService userService;
|
||||||
private readonly IInfoBarService infoBarService;
|
private readonly IInfoBarService infoBarService;
|
||||||
private readonly ITaskContext taskContext;
|
private readonly ITaskContext taskContext;
|
||||||
private readonly AppOptions options;
|
private readonly AppOptions appOptions;
|
||||||
private readonly RuntimeOptions runtimeOptions;
|
private readonly RuntimeOptions runtimeOptions;
|
||||||
private readonly HutaoUserOptions hutaoUserOptions;
|
private readonly HutaoUserOptions hutaoUserOptions;
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 应用程序设置
|
/// 应用程序设置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public AppOptions Options { get => options; }
|
public AppOptions Options { get => appOptions; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 胡桃选项
|
/// 胡桃选项
|
||||||
@@ -231,4 +232,18 @@ internal sealed partial class SettingViewModel : Abstraction.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Command("ConfigureGeetestUrlCommand")]
|
||||||
|
private async Task ConfigureGeetestUrlAsync()
|
||||||
|
{
|
||||||
|
GeetestCustomUrlDialog dialog = await contentDialogFactory.CreateInstanceAsync<GeetestCustomUrlDialog>().ConfigureAwait(false);
|
||||||
|
(bool isOk, string template) = await dialog.GetUrlAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
if (isOk)
|
||||||
|
{
|
||||||
|
await taskContext.SwitchToMainThreadAsync();
|
||||||
|
appOptions.GeetestCustomCompositeUrl = template;
|
||||||
|
infoBarService.Success("无感验证复合 Url 配置成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT license.
|
// Licensed under the MIT license.
|
||||||
|
|
||||||
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
using Snap.Hutao.Core.DependencyInjection.Annotation.HttpClient;
|
||||||
|
using Snap.Hutao.Service;
|
||||||
using Snap.Hutao.Service.Hutao;
|
using Snap.Hutao.Service.Hutao;
|
||||||
using Snap.Hutao.Web.Hutao.GachaLog;
|
using Snap.Hutao.Web.Hutao.GachaLog;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
@@ -15,14 +16,19 @@ internal sealed partial class HomaGeetestClient
|
|||||||
private readonly HttpClient httpClient;
|
private readonly HttpClient httpClient;
|
||||||
private readonly JsonSerializerOptions options;
|
private readonly JsonSerializerOptions options;
|
||||||
private readonly ILogger<HomaGeetestClient> logger;
|
private readonly ILogger<HomaGeetestClient> logger;
|
||||||
private readonly HutaoUserOptions hutaoUserOptions;
|
private readonly AppOptions appOptions;
|
||||||
|
|
||||||
public async ValueTask<GeetestResponse> VerifyAsync(string gt, string challenge, CancellationToken token)
|
public async ValueTask<GeetestResponse> VerifyAsync(string gt, string challenge, CancellationToken token)
|
||||||
{
|
{
|
||||||
await httpClient.TrySetTokenAsync(hutaoUserOptions).ConfigureAwait(false);
|
string template = appOptions.GeetestCustomCompositeUrl;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(template))
|
||||||
|
{
|
||||||
|
return new() { Code = -1 };
|
||||||
|
}
|
||||||
|
|
||||||
GeetestResponse? resp = await httpClient
|
GeetestResponse? resp = await httpClient
|
||||||
.TryCatchGetFromJsonAsync<GeetestResponse>(HutaoEndpoints.GeetestVerify(gt, challenge), options, logger, token)
|
.TryCatchGetFromJsonAsync<GeetestResponse>(template.Format(gt, challenge), options, logger, token)
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
ArgumentNullException.ThrowIfNull(resp);
|
ArgumentNullException.ThrowIfNull(resp);
|
||||||
|
|||||||
Reference in New Issue
Block a user