Skip to content

Commit

Permalink
修复 搜索Pin无效
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Jul 25, 2024
1 parent a389c55 commit a98ec84
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions Core/ViewModel/SearchWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public void ReloadApps(bool logging = false)

if (!EverythingIsOk.Value)
{
ServiceManager.Services.GetService<IAppToolService>()!.AutoStartEverything(_collection, () => {
ServiceManager.Services.GetService<IAppToolService>()!.AutoStartEverything(_collection, () =>
{
Thread.Sleep(1500);
var everythingService = ServiceManager.Services.GetService<IEverythingService>()!;
EverythingIsOk = everythingService.isRun();
Expand All @@ -107,8 +108,8 @@ public void ReloadApps(bool logging = false)
}

keys.AddRange(ServiceManager.Services.GetService<IAppToolService>()
.GetPinyin(scenario.Name)
.Keys);
.GetPinyin(scenario.Name)
.Keys);
var viewItem1 = new SearchViewItem()
{
ItemDisplayName = "执行自定义情景:" + scenario.Name,
Expand Down Expand Up @@ -138,19 +139,19 @@ public void CheckClipboard(bool loadLast = false)
}

if (Items.Count > 0 && (Items[0].FileType == FileType.剪贴板图像 || Items[0]
.ItemDisplayName.StartsWith("打开")))
.ItemDisplayName.StartsWith("打开")))
{
Items.RemoveAt(0);
}

var data = ServiceManager.Services.GetService<IClipboardService>()
.HasText();
.HasText();
try
{
if (data)
{
var text = ServiceManager.Services.GetService<IClipboardService>()
.GetText();
.GetText();
if (text.StartsWith("\""))
{
text = text.Replace("\"", "");
Expand All @@ -162,7 +163,7 @@ public void CheckClipboard(bool loadLast = false)
Log.Debug("检测路径");
ConcurrentDictionary<string, SearchViewItem> a = new();
ServiceManager.Services.GetService<IAppToolService>()!.AppSolverA(a, text)
.Wait();
.Wait();
foreach (var (key, value) in a)
{
if (value.FileType == FileType.文件夹)
Expand Down Expand Up @@ -206,7 +207,7 @@ public void CheckClipboard(bool loadLast = false)
});
}
else if (Items.Count > 0 && Items.First()
.FileType == FileType.剪贴板图像)
.FileType == FileType.剪贴板图像)
{
Log.Debug("剪贴板没有图像信息,但第一项是图片信息删除");

Expand Down Expand Up @@ -260,7 +261,7 @@ private void LoadLast()
{
Log.Debug("加载历史");
var sortedDict = ConfigManger.Config.lastOpens.OrderByDescending(p => p.Value)
.ToDictionary(p => p.Key, p => p.Value);
.ToDictionary(p => p.Key, p => p.Value);
foreach (var (key, value) in sortedDict)
{
if (limit >= ConfigManger.Config.maxHistory)
Expand Down Expand Up @@ -315,7 +316,8 @@ partial void OnSearchChanged(string? value)
}

//Log.Debug("搜索");
_searchDelayAction.Debounce(ConfigManger.Config.inputSmoothingMilliseconds, _scheduler, () => {
_searchDelayAction.Debounce(ConfigManger.Config.inputSmoothingMilliseconds, _scheduler, () =>
{
//Log.Debug("搜索开始");
if (string.IsNullOrEmpty(Search))
{
Expand Down Expand Up @@ -366,7 +368,7 @@ partial void OnSearchChanged(string? value)
var operators = new[] { '*', '+', '-', '/', '^' };
var pattern = @"[\u4e00-\u9fa5a-zA-Z]+";
if (Regex.Match(value, pattern, RegexOptions.NonBacktracking)
.Value == "" &&
.Value == "" &&
value.IndexOfAny(operators) > -1)
{
try
Expand Down Expand Up @@ -402,7 +404,7 @@ partial void OnSearchChanged(string? value)
#region 从文件索引检索并排序

var filtered = _pinyinSearcher.Search(value)
.ToList();
.ToList();
/*foreach (var item in CustomScenarioManger.CustomScenarios)
{
if (item.IsHaveInputValue&& !nowInSelectMode)
Expand Down Expand Up @@ -460,7 +462,7 @@ partial void OnSearchChanged(string? value)
}*/

var sorted = filtered.OrderByDescending(x => x.Weight)
.ToList();
.ToList();

#endregion

Expand All @@ -479,7 +481,7 @@ partial void OnSearchChanged(string? value)
}

var sortedDict = nowHasLastOpens.OrderByDescending(p => p.Value)
.ToDictionary(p => p.Key, p => p.Value);
.ToDictionary(p => p.Key, p => p.Value);
foreach (var (searchViewItem, i) in sortedDict)
{
//Log.Debug("添加搜索结果" + searchViewItem.OnlyKey);
Expand Down Expand Up @@ -533,7 +535,7 @@ partial void OnSearchChanged(string? value)
Log.Debug("检测路径");
ConcurrentDictionary<string, SearchViewItem> a = new();
ServiceManager.Services.GetService<IAppToolService>()!.AppSolverA(a, originalValue)
.Wait();
.Wait();
foreach (var (key, value) in a)
{
if (value.FileType == FileType.文件夹)
Expand Down Expand Up @@ -636,7 +638,7 @@ partial void OnSearchChanged(string? value)
}

var first = value.Split(" ")
.First();
.First();
foreach (var se in knownCommand)
{
if (se.Equals(first))
Expand Down Expand Up @@ -677,7 +679,8 @@ public void SetSelectMode(bool flag, Action<SearchViewItem> action)
[RelayCommand]
public void OpenFile(SearchViewItem? item)
{
Task.Run(() => {
Task.Run(() =>
{
if (nowInSelectMode)
{
selectAction.Invoke(item);
Expand Down Expand Up @@ -723,8 +726,6 @@ private void Pin(object searchViewItem)
{
var item = (SearchViewItem)searchViewItem;
Log.Debug("添加常驻" + item.OnlyKey);
var index = Items.IndexOf(item);
Items[index].IsPined = !Items[index].IsPined;
//Items.ResetItem(index);

ServiceManager.Services.GetService<ISearchItemTool>()!.Pin(item);
Expand Down

0 comments on commit a98ec84

Please sign in to comment.