Breakpoint
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using BITKit;
|
||||
@@ -36,6 +37,7 @@ public class SearchResult:ISearchEntry
|
||||
public interface ISearchEngine
|
||||
{
|
||||
SearchResult[] GetSearchResults(string key);
|
||||
void SaveChanges();
|
||||
void Add(SearchResult result);
|
||||
void Remove(string key, string id);
|
||||
}
|
||||
@@ -91,11 +93,22 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
QueueContainerFree();
|
||||
searchProgressBar.Show();
|
||||
var list = await Context.context.ToListAsync();
|
||||
Spawn(string.IsNullOrEmpty(key) ? list : list.Where(x => x.Key.Contains(key)));
|
||||
var result = (string.IsNullOrEmpty(key) ? list : list.Where(x => x.Key.Contains(key))).ToArray();
|
||||
|
||||
//Fallback
|
||||
if (result.Any() is false)
|
||||
{
|
||||
result = list.Where(x => x.Display.Contains(key!)).ToArray();
|
||||
}
|
||||
if (result.Any() is false)
|
||||
{
|
||||
result = list.Where(x => x.Id.Contains(key!)).ToArray();
|
||||
}
|
||||
|
||||
Spawn(result);
|
||||
_logBuilder.AppendLine($"已获取到集合");
|
||||
_logBuilder.AppendLine($"{string.Join("\n",list)}");
|
||||
searchProgressBar.Hide();
|
||||
//searchLogLabel.Text = _logBuilder.ToString();
|
||||
}
|
||||
|
||||
private void QuickSearch()
|
||||
@@ -109,12 +122,6 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
var index = i;
|
||||
var element = searchResults[i];
|
||||
quickSearchButton.GetPopup().AddItem(element.Key);
|
||||
// quickSearchButton.GetPopup().IdPressed = id =>
|
||||
// {
|
||||
// var entry = searchResults[index];
|
||||
// searchInput.Text = entry.Key;
|
||||
// Search(entry.Key);
|
||||
// };
|
||||
}
|
||||
}
|
||||
private void OnPressedIndex(long index)
|
||||
@@ -133,6 +140,9 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
|
||||
instance.titleLabel.Text = entry.Display ?? entry.Id ?? entry.Key;
|
||||
instance.Text = entry.Value;
|
||||
instance.updateTimeLabel.Text = entry.UpdateDate.ToString(CultureInfo.InvariantCulture);
|
||||
instance.createTimeLabel.Text = entry.CreateDate.ToString(CultureInfo.InvariantCulture);
|
||||
instance.headerLabel.Text = entry.Key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +155,7 @@ public partial class SearchEngine:Node,ISearchEngine
|
||||
}
|
||||
|
||||
public SearchResult[] GetSearchResults(string key)=>Context.context.Where(x=>x.Key.Contains(key)).ToArray();
|
||||
public void SaveChanges() => Context.SaveChanges();
|
||||
|
||||
public void Add(SearchResult result)
|
||||
{
|
||||
|
Reference in New Issue
Block a user