Skip to content

Commit aa90c36

Browse files
committed
优化手动查询历史记录中异常项的显示效果
1 parent 4d9ee05 commit aa90c36

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

Firefly/Extensions/StringExtensions.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ public static string TrimSlash(this string text)
130130
return text;
131131
}
132132

133+
public static string Truncate(this string? value, int length)
134+
{
135+
if (!String.IsNullOrEmpty(value))
136+
{
137+
value = value.Trim();
138+
139+
if (value.Length > length)
140+
{
141+
return value[..length] + "...";
142+
}
143+
}
144+
145+
return value ?? String.Empty;
146+
}
147+
133148
private static bool MatchAnyFunc(Func<string, StringComparison, bool> func, IEnumerable<string> values, StringComparison comparison = StringComparison.OrdinalIgnoreCase)
134149
{
135150
bool b = false;

Firefly/Models/CccfQuerySession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public override string ToString()
145145
}
146146

147147
sb.Append(" > ");
148-
sb.Append(QueryResponse?.ToString() ?? "???");
148+
sb.Append(QueryResponse?.ToString() ?? $"??? {{@{PageNumber}: {QueryResultMessage.Truncate(50)}}}");
149149

150150
return sb.ToString();
151151
}

Firefly/Views/CccfMainQueryView.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@
183183
<Setter Property="Foreground" Value="{DynamicResource PrimaryBrush}" />
184184
<Setter Property="IsHitTestVisible" Value="False" />
185185
</Trigger>
186+
187+
<DataTrigger Binding="{Binding HasError}"
188+
Value="{StaticResource True}">
189+
<Setter Property="Foreground" Value="{DynamicResource DangerBrush}" />
190+
</DataTrigger>
186191
</Style.Triggers>
187192
</Style>
188193
</ContextMenu.ItemContainerStyle>
@@ -204,6 +209,13 @@
204209
<Setter Property="Command" Value="{Binding Data.GoForwardCommand, Source={StaticResource CccfQueryViewModelProxy}}" />
205210
<Setter Property="CommandParameter" Value="{Binding}" />
206211
<Setter Property="Padding" Value="-16,0,-32,0" />
212+
213+
<Style.Triggers>
214+
<DataTrigger Binding="{Binding HasError}"
215+
Value="{StaticResource True}">
216+
<Setter Property="Foreground" Value="{DynamicResource DangerBrush}" />
217+
</DataTrigger>
218+
</Style.Triggers>
207219
</Style>
208220
</ContextMenu.ItemContainerStyle>
209221
</ContextMenu>

0 commit comments

Comments
 (0)