Skip to content

Commit

Permalink
fix provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Cricle committed May 26, 2021
1 parent 03d3a13 commit 7f90792
Show file tree
Hide file tree
Showing 16 changed files with 125 additions and 52 deletions.
12 changes: 6 additions & 6 deletions Platforms/Anf.ChannelModel/Helpers/RSA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Anf.ChannelModel.Helpers
{
public partial class RSA
{
private static readonly Encoding Encoding_UTF8 = Encoding.UTF8;
private static readonly Encoding UTF8 = Encoding.UTF8;

public RSAKey GetKey(int keyLen = 1024)
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public string EncryptByPrivateKey(string data, string privateKey)
var engine = new Pkcs1Encoding(new RsaEngine());

engine.Init(true, GetPrivateKeyParameter(privateKey));
var byteData = Encoding_UTF8.GetBytes(data);
var byteData = UTF8.GetBytes(data);
var ResultData = engine.ProcessBlock(byteData, 0, byteData.Length);
return Convert.ToBase64String(ResultData);
}
Expand All @@ -103,7 +103,7 @@ public string DecryptByPrivateKey(string data, string privateKey)
engine.Init(false, GetPrivateKeyParameter(privateKey));
byte[] byteData = Convert.FromBase64String(data);
var ResultData = engine.ProcessBlock(byteData, 0, byteData.Length);
return Encoding_UTF8.GetString(ResultData);
return UTF8.GetString(ResultData);
}

/// <summary>
Expand All @@ -118,7 +118,7 @@ public string EncryptByPublicKey(string data, string publicKey)
var engine = new Pkcs1Encoding(new RsaEngine());

engine.Init(true, GetPublicKeyParameter(publicKey));
byte[] byteData = Encoding_UTF8.GetBytes(data);
byte[] byteData = UTF8.GetBytes(data);
var ResultData = engine.ProcessBlock(byteData, 0, byteData.Length);
return Convert.ToBase64String(ResultData);
}
Expand All @@ -136,9 +136,9 @@ public string DecryptByPublicKey(string data, string publicKey)
var engine = new Pkcs1Encoding(new RsaEngine());

engine.Init(false, GetPublicKeyParameter(publicKey));
byte[] byteData = Convert.FromBase64String(data);
var byteData = Convert.FromBase64String(data);
var ResultData = engine.ProcessBlock(byteData, 0, byteData.Length);
return Encoding_UTF8.GetString(ResultData);
return UTF8.GetString(ResultData);
}
}
}
9 changes: 5 additions & 4 deletions Platforms/Anf.Desktop/Anf.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseD2D>true</UseD2D>
<EnableCache>true</EnableCache>
<ApplicationIcon>..\..\assets\Anf.ico</ApplicationIcon>
<MSIXBuild>true</MSIXBuild>
<MSIXBuild>false</MSIXBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(MSIXBuild)'!='true'">
<TargetFrameworks>net472;net5.0;</TargetFrameworks>
Expand All @@ -29,9 +29,9 @@
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Ao.SavableConfig" Version="2.2.3" />
<PackageReference Include="Ao.SavableConfig.Binder" Version="2.2.3" />
<PackageReference Include="Ao.SavableConfig.Json" Version="2.2.3" />
<PackageReference Include="Ao.SavableConfig" Version="2.3.0" />
<PackageReference Include="Ao.SavableConfig.Binder" Version="2.3.0" />
<PackageReference Include="Ao.SavableConfig.Json" Version="2.3.0" />
<PackageReference Include="Avalonia" Version="0.10.4" />
<PackageReference Include="Avalonia.Controls.PanAndZoom" Version="3.4.0" />
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="5.0.0" />
Expand All @@ -41,6 +41,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="5.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="1.7.2" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition="'$(UseFody)'=='true'">
<PackageReference Include="Costura.Fody" Version="5.1.0">
Expand Down
6 changes: 3 additions & 3 deletions Platforms/Anf.Desktop/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,16 @@ private AnfSettings CreateSettings(IServiceProvider provider)
var root = provider.GetRequiredService<SavableConfigurationRoot>();
var instType = ProxyHelper.Default.CreateComplexProxy<AnfSettings>(true);
var inst = (AnfSettings)instType.Build(root);
var disposable = root.BindTwoWay(inst, JsonChangeTransferCondition.Instance);
_ = root.BindTwoWay(inst, JsonChangeTransferCondition.Instance);
return inst;
}

private SavableConfigurationRoot BuildConfiguration()
{
var configBuilder = new SavableConfiurationBuilder();
var configBuilder = new ConfigurationBuilder();
configBuilder.SetBasePath(Workstation);
configBuilder.AddJsonFile(XComicConst.SettingFileFolder, true, true);
return configBuilder.Build();
return configBuilder.BuildSavable();
}

public override void OnFrameworkInitializationCompleted()
Expand Down
8 changes: 5 additions & 3 deletions Platforms/Anf.Desktop/Converters/StartupTypeBoolConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ namespace Anf.Desktop.Converters
{
public class StartupTypeStringConverter : IValueConverter
{
private static IReadOnlyDictionary<StartupTypes, string> nameForModels = new Dictionary<StartupTypes, string>
public static IReadOnlyCollection<StartupTypes> IncludeTypes = Enum.GetValues(typeof(StartupTypes)).OfType<StartupTypes>().ToArray();
public static IReadOnlyDictionary<StartupTypes, string> NameForModels = new Dictionary<StartupTypes, string>
{
[StartupTypes.None] = "空白",
[StartupTypes.Proposal] = "推介",
[StartupTypes.Providers] = "提供者"
};
private static IReadOnlyDictionary<string, StartupTypes> modelForNames = nameForModels.ToDictionary(x => x.Value, x => x.Key);
private static IReadOnlyDictionary<string, StartupTypes> modelForNames = NameForModels.ToDictionary(x => x.Value, x => x.Key);

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is StartupTypes type)
{
return nameForModels[type];
return NameForModels[type];
}
return null;
}
Expand All @@ -36,6 +37,7 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return modelForNames[str];
}
return null;

}
}
public class StartupTypeBoolConverter : IValueConverter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal class DesktopStoreComicVisiting : StoreComicVisiting<Bitmap>
public DesktopStoreComicVisiting(IServiceProvider host, IResourceFactoryCreator<Bitmap> resourceFactoryCreator) : base(host, resourceFactoryCreator)
{
anfSettings = AppEngine.GetRequiredService<AnfSettings>();
EnableRemote = true;
EnableRemote = false;
}
private readonly AnfSettings anfSettings;
public override bool UseStore { get => anfSettings.Performace.UseStore; set => anfSettings.Performace.UseStore = value; }
Expand Down
20 changes: 15 additions & 5 deletions Platforms/Anf.Desktop/SettingsControlView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,43 @@
<ToggleSwitch Classes="control part forcehover"
Margin="3,0"
IsChecked="{Binding ThemeSettings.EnableAcrylicBlur,Mode=TwoWay}"
Grid.Column="1"/>
Grid.Column="1"
ToolTip.Tip="高对比背景的时候会看不清文字!"/>
<TextBlock Grid.Row="1" Text="黑主题" VerticalAlignment="Center"/>
<ToggleSwitch Classes="control part forcehover"
Margin="3,0"
IsChecked="{Binding ThemeSettings.EnableDrakTheme,Mode=TwoWay}"
Grid.Column="1"
Grid.Row="1"/>
Grid.Row="1"
ToolTip.Tip="晚上用好呀!"/>
<TextBlock Grid.Row="2" Text="立即全部" VerticalAlignment="Center"/>
<ToggleSwitch Classes="control part forcehover"
Margin="3,0"
IsChecked="{Binding ReadingSettings.LoadAll,Mode=TwoWay}"
Grid.Column="1"
Grid.Row="2"
ToolTip.Tip="加载时立即加载全部而不是被动加载(省内存省流量OvO"/>
<TextBlock Grid.Row="3" Text="并行解析" VerticalAlignment="Center"/>
<ToggleSwitch Classes="control part forcehover"
Margin="3,0"
IsChecked="{Binding PerformaceSettings.EnableRemoteFetch,Mode=TwoWay}"
Grid.Column="1"
Grid.Row="3"
ToolTip.Tip="能加速解析,但会耗费更多流量"/>
<TextBlock Grid.Row="4" Text="本地存储" VerticalAlignment="Center"/>
<ToggleSwitch Classes="control part forcehover"
Margin="3,0"
IsChecked="{Binding PerformaceSettings.EnableStore,Mode=TwoWay}"
Grid.Column="1"
Grid.Row="4"/>
Grid.Row="4"
ToolTip.Tip="在一定时间内,第二次解析会使用本地存储"/>
<TextBlock Grid.Row="5" Text="不显示异常" VerticalAlignment="Center"/>
<ToggleSwitch Classes="control part forcehover"
Margin="3,0"
IsChecked="{Binding DotShowException,Mode=TwoWay}"
Grid.Column="1"
Grid.Row="5"/>

Grid.Row="5"
ToolTip.Tip="看不懂,不显示"/>
</Grid>
</Border>
</Popup>
Expand Down
5 changes: 5 additions & 0 deletions Platforms/Anf.Desktop/ViewModels/DesktopHomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Anf.Platform.Settings;
using Anf.Platform.Models.Impl;
using Anf.Networks;
using System.Linq;

namespace Anf.Desktop.ViewModels
{
Expand Down Expand Up @@ -61,6 +62,10 @@ private async void UpdateIfNeedAsync()
{
case StartupTypes.Proposal:
ProposalSnapshots.Clear();
if (SelectedProposal is null)
{
SelectedProposal = ProposalEngine.FirstOrDefault();
}
await UpdateProposalAsync(StartupSettings.DisplayProposalCount);
break;
case StartupTypes.Providers:
Expand Down
34 changes: 26 additions & 8 deletions Platforms/Anf.Desktop/Views/HomePage.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<vm:AvalonHomeViewModel></vm:AvalonHomeViewModel>
</Design.DataContext>
<UserControl.Resources>
<conv:StartupTypeStringConverter x:Key="StartupTypeStringConverter"/>
<conv:SearchProviderConverter x:Key="SearchProviderConverter"/>
<conv:StartupTypeBoolConverter x:Key="StartupTypeBoolConverter"/>
<DataTemplate x:Key="CsiDt">
Expand All @@ -27,6 +28,7 @@
<MenuItem Header="-" IsEnabled="False"/>
<MenuItem Header="复制">
<MenuItem Header="标题" Command="{Binding DataContext.CopyCommand,ElementName=HomePg}" CommandParameter="{Binding Snapshot.Name}"/>
<MenuItem Header="封面" Command="{Binding DataContext.CopyCommand,ElementName=HomePg}" CommandParameter="{Binding Snapshot.ImageUri}"/>
</MenuItem>
</ContextMenu>
</Grid.ContextMenu>
Expand Down Expand Up @@ -160,13 +162,18 @@
</Grid>
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Margin="16,0"
IsVisible="{Binding StartupSettings.StartupType,ConverterParameter={x:Static s:StartupTypes.Proposal}, Converter={StaticResource StartupTypeBoolConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Border HorizontalAlignment="Left"
VerticalAlignment="Center">
<StackPanel HorizontalAlignment="Left"
VerticalAlignment="Center"
Orientation="Horizontal"
Grid.Row="1">
<TextBlock VerticalAlignment="Center" Margin="0,0,8,0">推介引擎</TextBlock>
<ComboBox SelectedIndex="0"
Items="{Binding ProposalEngine}"
SelectedItem="{Binding SelectedProposal,Mode=TwoWay}">
Expand All @@ -176,18 +183,18 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Border>
</StackPanel>
<StackPanel IsVisible="{Binding ProposalLoading}"
Orientation="Vertical"
Grid.Row="1"
Grid.Row="2"
VerticalAlignment="Center"
HorizontalAlignment="Center">
<ProgressBar IsIndeterminate="{Binding ProposalLoading}" MaxWidth="200"/>
<TextBlock>正在加载推介</TextBlock>
</StackPanel>
<Border IsVisible="{Binding ProposalLoading,Converter={StaticResource RevBoolConverter}}">
<ScrollViewer Grid.Row="3"
HorizontalScrollBarVisibility="Auto"
<Border Grid.Row="2"
IsVisible="{Binding ProposalLoading,Converter={StaticResource RevBoolConverter}}">
<ScrollViewer HorizontalScrollBarVisibility="Auto"
Margin="0,20,0,0">
<ListBox Background="{x:Null}"
Items="{Binding ProposalSnapshots}"
Expand All @@ -203,8 +210,19 @@
</ListBox>
</ScrollViewer>
</Border>

</Grid>
<Border HorizontalAlignment="Left"
VerticalAlignment="Bottom"
Margin="8,0,0,8">
<ComboBox SelectedItem="{Binding StartupSettings.StartupType}"
Items="{x:Static conv:StartupTypeStringConverter.IncludeTypes}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource StartupTypeStringConverter}}"></TextBlock>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</Border>
</Grid>
</Grid>
<Grid Grid.Row="3"
Expand Down
1 change: 1 addition & 0 deletions Platforms/Anf.Desktop/Views/VisitingView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<ContextMenu x:Key="ControlMenu">
<MenuItem Header="{Binding DataContext.CurrentChapter.Title,ElementName=Rep}" IsEnabled="False"/>
<MenuItem Header="复制">
<MenuItem Header="名字" Command="{Binding DataContext.CopyTitleCommand,ElementName=Rep,Mode=OneTime}"/>
<MenuItem Header="实体" Command="{Binding DataContext.CopyComicEntityCommand,ElementName=Rep,Mode=OneTime}"/>
<MenuItem Header="地址" Command="{Binding DataContext.CopyComicCommand,ElementName=Rep,Mode=OneTime}"/>
<MenuItem Header="章节" Command="{Binding DataContext.CopyChapterCommand,ElementName=Rep,Mode=OneTime}"/>
Expand Down
2 changes: 1 addition & 1 deletion Platforms/Anf.Desktop/anf.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"Startup": {
"StartupType": "Providers",
"DisplayProposalCount": "10"
"DisplayProposalCount": "20"
},
"Performace": {
"EnableCDN": "False",
Expand Down
8 changes: 8 additions & 0 deletions Platforms/Anf.Platform/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public HomeViewModel()
private bool hasAvaliableCondition;
private bool proposalLoading;
private IProposalDescription selectedProposal;
private bool hasSelectedProposal;

public bool HasSelectedProposal
{
get { return hasSelectedProposal; }
private set => Set(ref hasSelectedProposal, value);
}

public IProposalDescription SelectedProposal
{
Expand All @@ -79,6 +86,7 @@ public IProposalDescription SelectedProposal
{
OnSelectedProposalChanged(value);
}
HasSelectedProposal = value != null;
}
}

Expand Down
6 changes: 6 additions & 0 deletions Platforms/Anf.Platform/ViewModels/VisitingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ private set

public RelayCommand OpenComicCommand { get; protected set; }
public RelayCommand OpenChapterCommand { get; protected set; }
public RelayCommand CopyTitleCommand { get; protected set; }
public RelayCommand CopyComicCommand { get; protected set; }
public RelayCommand CopyChapterCommand { get; protected set; }
public RelayCommand CopyComicEntityCommand { get; protected set; }
Expand Down Expand Up @@ -254,6 +255,10 @@ public void CopyComic()
{
PlatformService.Copy(ComicEntity.ComicUrl);
}
public void CopyTitle()
{
PlatformService.Copy(ComicEntity.Name);
}
public void CopyComicEntity()
{
var str = JsonHelper.Serialize(ComicEntity);
Expand Down Expand Up @@ -440,6 +445,7 @@ private void InitVisiting()

OpenComicCommand = new RelayCommand(() => _ = OpenComicAsync());
OpenChapterCommand = new RelayCommand(() => _ = OpenChapterAsync());
CopyTitleCommand = new RelayCommand(CopyTitle);
CopyComicCommand = new RelayCommand(CopyComic);
CopyComicEntityCommand = new RelayCommand(CopyComicEntity);
CopyChapterCommand = new RelayCommand(CopyChapter);
Expand Down
2 changes: 1 addition & 1 deletion Platforms/Anf.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void ConfigureServices(IServiceCollection services)
{
configuration.RootPath = "ClientApp/dist";
});
services.AddApplicationInsightsTelemetry(Configuration["APPINSIGHTS_CONNECTIONSTRING"]);
services.AddApplicationInsightsTelemetry(Configuration["APPINSIGHTSCONNECTIONSTRING"]);
services.AddSignalR()
.AddAzureSignalR();
services.AddDbContext<AnfDbContext>((x, y) =>
Expand Down
3 changes: 0 additions & 3 deletions Platforms/Anf.Web/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
}
},
"AllowedHosts": "*",
"ApplicationInsights": {
"ConnectionString": "InstrumentationKey=3da9282c-dc94-41d0-a068-68fdc6808c94;IngestionEndpoint=https://australiacentral-0.in.applicationinsights.azure.com/"
},
"Azure": {
"SignalR": {
"Enabled": "true"
Expand Down
Loading

0 comments on commit 7f90792

Please sign in to comment.