优化渲染逻辑和界面布局
在 `MarkdownWpfRenderer.cs` 中,更新了 `RenderHtmlBlock` 方法以处理以 `<think>` 开头的文本,返回包含进度条和可选择文本块的 `Expander` 控件。更新了 `App.xaml`,移除了 `mu:ThemeDictionary` 的 `ColorMode` 属性。修改了 `AiMessageControll.xaml`,将布局从 `StackPanel` 更改为 `DockPanel`,并添加了 `ButtonGroup`。在 `ImportViewModel.cs` 中,调整了调试模式下的消息处理逻辑,确保正确处理用户输入的消息。
This commit is contained in:
parent
0ab9b35fde
commit
735fbfb83d
|
@ -379,15 +379,22 @@ public class MarkdownWpfRenderer
|
||||||
if (text.StartsWith("<think>"))
|
if (text.StartsWith("<think>"))
|
||||||
{
|
{
|
||||||
text = text.Replace("<think>", "").Replace("</think>", "");
|
text = text.Replace("<think>", "").Replace("</think>", "");
|
||||||
|
var htmlText = new SelectableTextBlock();
|
||||||
|
htmlText.Text = text;
|
||||||
|
var expander = new Expander();
|
||||||
|
var header = new StackPanel();
|
||||||
|
header.Children.Add(new ProgressBar() { IsIndeterminate = true, Width = 30 });
|
||||||
|
expander.Header = header;
|
||||||
|
expander.Content = htmlText;
|
||||||
|
return expander;
|
||||||
}
|
}
|
||||||
var htmlText = new SelectableTextBlock();
|
else
|
||||||
htmlText.Text = text;
|
{
|
||||||
var expander = new Expander();
|
var htmlText = new SelectableTextBlock();
|
||||||
var header = new StackPanel();
|
htmlText.Text = text;
|
||||||
header.Children.Add(new ProgressBar() { IsIndeterminate = true,Width = 30 });
|
return htmlText;
|
||||||
expander.Header = header;
|
}
|
||||||
expander.Content = htmlText;
|
|
||||||
return expander;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public FrameworkElement RenderMathBlock(MathBlock mathBlock, CancellationToken cancellationToken)
|
public FrameworkElement RenderMathBlock(MathBlock mathBlock, CancellationToken cancellationToken)
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/SkinDefault.xaml" />
|
||||||
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
|
<ResourceDictionary Source="pack://application:,,,/HandyControl;component/Themes/Theme.xaml" />
|
||||||
<mu:ControlsDictionary />
|
<mu:ControlsDictionary />
|
||||||
<mu:ThemeDictionary ColorMode="Light" />
|
<mu:ThemeDictionary />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
|
|
|
@ -88,18 +88,28 @@
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</TabControl>
|
</TabControl>
|
||||||
|
|
||||||
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
<DockPanel>
|
||||||
<TextBlock
|
<hc:ButtonGroup Margin="5,0">
|
||||||
Margin="0,5,5,0"
|
<Button
|
||||||
FontSize="10"
|
Height="20"
|
||||||
Foreground="#99000000"
|
hc:IconElement.Geometry="{StaticResource WindowRestoreGeometry}"
|
||||||
Text="{Binding Content.Length, StringFormat='字数: {0}'}" />
|
Background="Transparent"
|
||||||
<TextBlock
|
FontSize="10"
|
||||||
Margin="0,5,0,0"
|
Foreground="#99000000" />
|
||||||
FontSize="10"
|
</hc:ButtonGroup>
|
||||||
Foreground="#99000000"
|
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal">
|
||||||
Text="{Binding Timestamp, StringFormat='{}{0:HH:mm}'}" />
|
<TextBlock
|
||||||
</StackPanel>
|
Margin="0,5,5,0"
|
||||||
|
FontSize="10"
|
||||||
|
Foreground="#99000000"
|
||||||
|
Text="{Binding Content.Length, StringFormat='字数: {0}'}" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="0,5,0,0"
|
||||||
|
FontSize="10"
|
||||||
|
Foreground="#99000000"
|
||||||
|
Text="{Binding Timestamp, StringFormat='{}{0:HH:mm}'}" />
|
||||||
|
</StackPanel>
|
||||||
|
</DockPanel>
|
||||||
<hc:Divider
|
<hc:Divider
|
||||||
Height="10"
|
Height="10"
|
||||||
Margin="0,3"
|
Margin="0,3"
|
||||||
|
|
|
@ -321,8 +321,9 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
|
||||||
};
|
};
|
||||||
|
|
||||||
Messages.Add(aiChat);
|
Messages.Add(aiChat);
|
||||||
#if !DEBUG
|
var promptedMsg = PromptUtil.UsePrompt(message,ExcelPromptString);
|
||||||
var results = TEST_AI_CONTENT.Split('\n');
|
#if DEBUG
|
||||||
|
var results = promptedMsg.Split('\n');
|
||||||
foreach(var result in results)
|
foreach(var result in results)
|
||||||
{
|
{
|
||||||
aiChat.Content += result;
|
aiChat.Content += result;
|
||||||
|
@ -330,7 +331,6 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
|
||||||
await Task.Delay(5);
|
await Task.Delay(5);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
var promptedMsg = PromptUtil.UsePrompt(message,ExcelPromptString);
|
|
||||||
history.Add(new Microsoft.Extensions.AI.ChatMessage
|
history.Add(new Microsoft.Extensions.AI.ChatMessage
|
||||||
{
|
{
|
||||||
Role = Microsoft.Extensions.AI.ChatRole.User,
|
Role = Microsoft.Extensions.AI.ChatRole.User,
|
||||||
|
|
Loading…
Reference in New Issue