Compare commits
3 Commits
735fbfb83d
...
6d5b4a33b9
| Author | SHA1 | Date |
|---|---|---|
|
|
6d5b4a33b9 | |
|
|
6d6935c84d | |
|
|
67d7e93217 |
|
|
@ -0,0 +1,32 @@
|
||||||
|
<UserControl x:Class="EleCho.MdViewer.Controls.CodeSpanControl"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:local="clr-namespace:EleCho.MdViewer.Controls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="30" d:DesignWidth="160">
|
||||||
|
<StackPanel Orientation="Horizontal" Margin="5">
|
||||||
|
<local:SelectableTextBlock Text="{Binding Text}" VerticalAlignment="Center"/>
|
||||||
|
<Button x:Name="Copy"
|
||||||
|
Content="复制"
|
||||||
|
Click="Copy_Click"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Padding="4,0"
|
||||||
|
Opacity="1"
|
||||||
|
Height="20"
|
||||||
|
Background="#AAFFFFFF"
|
||||||
|
BorderThickness="1">
|
||||||
|
<Button.Style>
|
||||||
|
<Style TargetType="Button">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" Value="True">
|
||||||
|
<Setter Property="Opacity" Value="0.8"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Button.Style>
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
||||||
|
|
@ -0,0 +1,51 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace EleCho.MdViewer.Controls
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// CodeSpanControl.xaml 的交互逻辑
|
||||||
|
/// </summary>
|
||||||
|
public partial class CodeSpanControl : UserControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Text
|
||||||
|
/// </summary>
|
||||||
|
public string Text
|
||||||
|
{
|
||||||
|
get => (string)GetValue(TextProperty);
|
||||||
|
|
||||||
|
set => SetValue(TextProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Text property
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty TextProperty =
|
||||||
|
DependencyProperty.Register("Text", typeof(string), typeof(CodeSpanControl), new PropertyMetadata(string.Empty));
|
||||||
|
|
||||||
|
|
||||||
|
public CodeSpanControl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.DataContext = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Copy_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -428,7 +428,8 @@ public class MarkdownWpfRenderer
|
||||||
CornerRadius = new CornerRadius(8),
|
CornerRadius = new CornerRadius(8),
|
||||||
Margin = new Thickness(0, 0, 0, NormalSize)
|
Margin = new Thickness(0, 0, 0, NormalSize)
|
||||||
};
|
};
|
||||||
|
if (!fencedCodeBlock.Info.StartsWith("Excel", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
var codeContentElement = new SelectableTextBlock()
|
var codeContentElement = new SelectableTextBlock()
|
||||||
{
|
{
|
||||||
TextWrapping = TextWrapping.Wrap,
|
TextWrapping = TextWrapping.Wrap,
|
||||||
|
|
@ -458,6 +459,16 @@ public class MarkdownWpfRenderer
|
||||||
WpfSyntaxHighLighting writer = new(styleDict);
|
WpfSyntaxHighLighting writer = new(styleDict);
|
||||||
writer.FormatTextBlock(fencedCodeBlock.Lines.ToString(), language, codeContentElement);
|
writer.FormatTextBlock(fencedCodeBlock.Lines.ToString(), language, codeContentElement);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var codeSpanControl = new CodeSpanControl();
|
||||||
|
codeSpanControl.SetResourceReference(Control.ForegroundProperty, MarkdownResKey.MainForeground);
|
||||||
|
codeSpanControl.SetResourceReference(Control.BackgroundProperty, MarkdownResKey.CodeBlockBackground);
|
||||||
|
codeSpanControl.Text = fencedCodeBlock.Lines.ToString();
|
||||||
|
codeElement.Child = codeSpanControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return codeElement;
|
return codeElement;
|
||||||
}
|
}
|
||||||
|
|
@ -566,7 +577,7 @@ public class MarkdownWpfRenderer
|
||||||
SelectableTextBlock paragraphElement = new SelectableTextBlock()
|
SelectableTextBlock paragraphElement = new SelectableTextBlock()
|
||||||
{
|
{
|
||||||
TextWrapping = TextWrapping.Wrap,
|
TextWrapping = TextWrapping.Wrap,
|
||||||
Margin = new Thickness(0, 0, 0, NormalSize),
|
Margin = new Thickness(0, NormalSize, 0, NormalSize),
|
||||||
|
|
||||||
FontSize = NormalSize,
|
FontSize = NormalSize,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ class PromptUtil
|
||||||
4. 一定要保证文档格式的正确性,避免出现无法显示的内容。
|
4. 一定要保证文档格式的正确性,避免出现无法显示的内容。
|
||||||
|
|
||||||
5. 尽量使用比较简短与易懂的公式来回答用户的问题,避免用户无法理解。
|
5. 尽量使用比较简短与易懂的公式来回答用户的问题,避免用户无法理解。
|
||||||
|
6. 当你输出公式时,请使用以下格式进行输出:
|
||||||
|
```Excel_{{列}}
|
||||||
|
=SUM(A1:A100)
|
||||||
|
|
||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,12 @@
|
||||||
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
|
||||||
<OptimizationPreference>Size</OptimizationPreference>
|
<OptimizationPreference>Size</OptimizationPreference>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Remove="Web\**" />
|
||||||
|
<EmbeddedResource Remove="Web\**" />
|
||||||
|
<None Remove="Web\**" />
|
||||||
|
<Page Remove="Web\**" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Remove="HL\SQL.xshd" />
|
<None Remove="HL\SQL.xshd" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
@ -69,9 +75,6 @@
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.2.24473.5" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-rc.2.24473.5" />
|
||||||
<PackageReference Include="TinyPinyin" Version="1.1.0" />
|
<PackageReference Include="TinyPinyin" Version="1.1.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="Web\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\EleCho.MdViewer\src\EleCho.MdViewer\EleCho.MdViewer.csproj" />
|
<ProjectReference Include="..\EleCho.MdViewer\src\EleCho.MdViewer\EleCho.MdViewer.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ public class Excel2Prompt
|
||||||
/// <param name="columns"></param>
|
/// <param name="columns"></param>
|
||||||
/// <param name="startCell">A</param>
|
/// <param name="startCell">A</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static string ConverterToPrompt(IEnumerable<dynamic> excelData, Dictionary<string,string> columns, string startCell)
|
public static string ConverterToPrompt(IEnumerable<dynamic> excelData, Dictionary<string, string> columns, string startCell,string sheetName)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
示例:
|
示例:
|
||||||
|
|
@ -37,7 +37,7 @@ public class Excel2Prompt
|
||||||
- Missing values: 7007
|
- Missing values: 7007
|
||||||
*/
|
*/
|
||||||
var prompts = new List<string>();
|
var prompts = new List<string>();
|
||||||
prompts.Add("This Excel file contains the following columns:");
|
prompts.Add($"This Excel file contains the following columns:");
|
||||||
var dataList = excelData.ToList();
|
var dataList = excelData.ToList();
|
||||||
|
|
||||||
// 解析 startCell,获取起始列的索引
|
// 解析 startCell,获取起始列的索引
|
||||||
|
|
@ -70,6 +70,8 @@ public class Excel2Prompt
|
||||||
$" - Sample values: ['{string.Join("', '", sampleValues)}']";
|
$" - Sample values: ['{string.Join("', '", sampleValues)}']";
|
||||||
prompts.Add(prompt);
|
prompts.Add(prompt);
|
||||||
}
|
}
|
||||||
|
prompts.Add($"Sheet Name: {sheetName}");
|
||||||
|
prompts.Add($"Max Row: {excelData.Count()}");
|
||||||
|
|
||||||
return string.Join(Environment.NewLine + Environment.NewLine, prompts);
|
return string.Join(Environment.NewLine + Environment.NewLine, prompts);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,7 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
|
||||||
|
|
||||||
MaxRow = ExcelData.Count();
|
MaxRow = ExcelData.Count();
|
||||||
|
|
||||||
ExcelPromptString = Excel2Prompt.ConverterToPrompt(ExcelData, _columnMappings, StartCell);
|
ExcelPromptString = Excel2Prompt.ConverterToPrompt(excelData, _columnMappings, StartCell,currentSheetName);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -347,10 +347,16 @@ public partial class ImportViewModel : ObservableRecipient, IViewModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private const string TEST_AI_CONTENT = @"
|
private static string TEST_AI_CONTENT = @"
|
||||||
<think>
|
```Excel_H
|
||||||
1231231
|
1231231122222222222222222222
|
||||||
</think>
|
123
|
||||||
|
1
|
||||||
|
23
|
||||||
|
12
|
||||||
|
3
|
||||||
|
12
|
||||||
|
```
|
||||||
";
|
";
|
||||||
#region Props
|
#region Props
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue