-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
235 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
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:pluginCore="clr-namespace:PluginCore;assembly=Core" | ||
xmlns:pluginManagerPage="clr-namespace:KitopiaAvalonia.Converter.PluginManagerPage" | ||
xmlns:pluginManagerPage1="clr-namespace:KitopiaAvalonia.Controls.PluginManagerPage" | ||
xmlns:mdxaml="https://github.com/whistyun/Markdown.Avalonia.Tight" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:DataType="pluginCore:PluginInfo" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
HorizontalContentAlignment="Stretch" | ||
VerticalContentAlignment="Stretch" | ||
x:Class="KitopiaAvalonia.Controls.PluginManagerPage.PluginDetail"> | ||
<UserControl.Resources> | ||
<pluginManagerPage:IconCtr x:Key="IconCtr" /> | ||
</UserControl.Resources> | ||
<Border BorderBrush="{DynamicResource SemiColorBorder}" BorderThickness="1" | ||
CornerRadius="{DynamicResource RadiusCardCornerRadius}" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" x:DataType="pluginCore:PluginInfo"> | ||
<Panel> | ||
<Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" | ||
ColumnDefinitions="80,*" x:DataType="pluginCore:PluginInfo" | ||
IsEnabled="{Binding !UnloadFailed}" | ||
RowDefinitions="*,48"> | ||
<Image Grid.Column="0" HorizontalAlignment="Center" Margin="0,15,0,0" | ||
VerticalAlignment="Top" Focusable="False" Width="64" | ||
Source="{Binding Icon,Converter={StaticResource IconCtr},ConverterParameter={Binding .}}" | ||
Height="64" /> | ||
<StackPanel Grid.Column="1" Margin="0,15,0,5" VerticalAlignment="Top" Spacing="5" | ||
HorizontalAlignment="Stretch"> | ||
<StackPanel Orientation="Horizontal" x:DataType="pluginCore:PluginInfo" Spacing="5"> | ||
<TextBlock VerticalAlignment="Center" | ||
HorizontalAlignment="Left" | ||
x:DataType="pluginCore:PluginInfo" | ||
Text="{Binding Name}" | ||
FontWeight="Normal" FontSize="18" | ||
Foreground="{DynamicResource DefaultForeground}"> | ||
</TextBlock> | ||
<TextBlock VerticalAlignment="Center" | ||
HorizontalAlignment="Left" | ||
x:DataType="pluginCore:PluginInfo" | ||
Text="{Binding Version}" | ||
FontWeight="Normal" FontSize="18" | ||
Foreground="{DynamicResource DefaultForeground}"> | ||
</TextBlock> | ||
<TextBlock Text=">" FontSize="18" | ||
x:DataType="pluginCore:PluginInfo" | ||
IsVisible="{Binding CanUpdata}"> | ||
<TextBlock.Foreground> | ||
<SolidColorBrush Color="{DynamicResource SemiOrange4Color}" /> | ||
</TextBlock.Foreground> | ||
</TextBlock> | ||
<TextBlock Text="{Binding CanUpdateVersion }" | ||
x:DataType="pluginCore:PluginInfo" FontSize="18" | ||
IsVisible="{Binding CanUpdata}"> | ||
<TextBlock.Foreground> | ||
<SolidColorBrush Color="{DynamicResource SemiOrange4Color}" /> | ||
</TextBlock.Foreground> | ||
</TextBlock> | ||
</StackPanel> | ||
<TextBlock VerticalAlignment="Center" | ||
MaxWidth="{Binding $parent.Bounds.Width}" | ||
TextWrapping="Wrap" | ||
x:DataType="pluginCore:PluginInfo" | ||
Text="{Binding Description}" /> | ||
<ScrollViewer IsHitTestVisible="False" | ||
VerticalAlignment="Stretch" | ||
HorizontalAlignment="Stretch" | ||
HorizontalScrollBarVisibility="Hidden"> | ||
|
||
<mdxaml:MarkdownScrollViewer x:DataType="pluginCore:PluginInfo" Markdown="{Binding $parent[pluginManagerPage1:PluginDetail].Markdown}" ></mdxaml:MarkdownScrollViewer> | ||
</ScrollViewer> | ||
<ContentPresenter HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
HorizontalContentAlignment="Stretch" | ||
VerticalContentAlignment="Stretch" | ||
Content="{Binding $parent[pluginManagerPage1:PluginDetail].Content}"> | ||
</ContentPresenter> | ||
|
||
</StackPanel> | ||
|
||
</Grid> | ||
|
||
|
||
</Panel> | ||
|
||
</Border> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
using Avalonia.Threading; | ||
using Core.SDKs.Services.Plugin; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using PluginCore; | ||
|
||
namespace KitopiaAvalonia.Controls.PluginManagerPage; | ||
|
||
public partial class PluginDetail : UserControl | ||
{ | ||
public static AvaloniaProperty<Control> ContentProperty = AvaloniaProperty.Register<PluginDetail, Control>(nameof(Content)); | ||
public Control Content | ||
{ | ||
get => (Control)GetValue(ContentProperty); | ||
set => SetValue(ContentProperty, value); | ||
} | ||
|
||
public static AvaloniaProperty<string> MarkdownProperty = AvaloniaProperty.Register<PluginDetail, string>(nameof(Markdown)); | ||
public string Markdown | ||
{ | ||
get => (string)GetValue(ContentProperty); | ||
set => SetValue(ContentProperty, value); | ||
} | ||
public PluginDetail() | ||
{ | ||
InitializeComponent(); | ||
|
||
} | ||
|
||
protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) | ||
{ | ||
base.OnAttachedToVisualTree(e); | ||
if (DataContext is not PluginInfo pluginInfo) | ||
{ | ||
return; | ||
} | ||
|
||
Task.Run(async () => | ||
{ | ||
var request = new HttpRequestMessage() | ||
{ | ||
RequestUri = new Uri($"https://www.ncserver.top:5111/api/plugin/{pluginInfo.Id}"), | ||
Method = HttpMethod.Get, | ||
}; | ||
request.Headers.Add("AllBeforeThisVersion", true.ToString()); | ||
var sendAsync = await PluginManager._httpClient.SendAsync(request); | ||
var stringAsync = await sendAsync.Content.ReadAsStringAsync(); | ||
var deserializeObject = (JObject)JsonConvert.DeserializeObject(stringAsync); | ||
var list = deserializeObject["data"]["description"].ToString(); | ||
await Dispatcher.UIThread.InvokeAsync(() => | ||
{ | ||
SetValue(MarkdownProperty, list); | ||
}); | ||
}); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters