Skip to content

Commit

Permalink
优化 历史记录支持自定义情景
Browse files Browse the repository at this point in the history
  • Loading branch information
MakesYT committed Oct 22, 2023
1 parent 002af45 commit b10cf11
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
38 changes: 22 additions & 16 deletions Core/ViewModel/SearchWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,28 +119,34 @@ public void CheckClipboard(bool loadLast = false)
}

var data = Clipboard.GetDataObject()!;
if (data.GetDataPresent(DataFormats.Text))
try
{
var text = (string)data.GetData(DataFormats.Text)!;
if (text.StartsWith("\""))
if (data.GetDataPresent(DataFormats.Text))
{
text = text.Replace("\"", "");
}
var text = (string)data.GetData(DataFormats.Text)!;
if (text.StartsWith("\""))
{
text = text.Replace("\"", "");
}

//检测路径
if (text.Contains("\\") || text.Contains("/"))
{
Log.Debug("检测路径");
Dictionary<string, SearchViewItem> a = new();
AppTools.AppSolverA(a, text).Wait();
foreach (var (key, value) in a)
//检测路径
if (text.Contains("\\") || text.Contains("/"))
{
value.FileName = $"打开文件: {value.FileName} ?";
Items.Insert(0, value);
GetIconInItemsAsync(value);
Log.Debug("检测路径");
Dictionary<string, SearchViewItem> a = new();
AppTools.AppSolverA(a, text).Wait();
foreach (var (key, value) in a)
{
value.FileName = $"打开文件: {value.FileName} ?";
Items.Insert(0, value);
GetIconInItemsAsync(value);
}
}
}
}
catch (Exception e)
{
}


if (((IClipboardService)ServiceManager.Services!.GetService(typeof(IClipboardService))!).IsBitmap())
Expand Down Expand Up @@ -456,7 +462,7 @@ partial void OnSearchChanged(string? value)
}
}
var sortedDict = nowHasLastOpens.AsParallel().OrderByDescending(p => p.Value)
var sortedDict = nowHasLastOpens.OrderByDescending(p => p.Value)
.ToDictionary(p => p.Key, p => p.Value);
foreach (var (searchViewItem, i) in sortedDict)
{
Expand Down
1 change: 0 additions & 1 deletion Kitopia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core", "Core\Core.csproj", "{48AA7450-F61F-4D21-8B04-1649B1DED462}"
ProjectSection(ProjectDependencies) = postProject
{B27A1A07-DFEF-4802-99C6-A11AB41719CF} = {B27A1A07-DFEF-4802-99C6-A11AB41719CF}
{0F8C4EDA-81CD-409A-A8FC-D13B22334429} = {0F8C4EDA-81CD-409A-A8FC-D13B22334429}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestProject1", "TestProject1\TestProject1.csproj", "{12CEA1A5-F9A7-4272-A061-27FD9F7BE905}"
Expand Down
1 change: 1 addition & 0 deletions uToolkitopia/Services/SearchItemTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public void OpenSearchItem(SearchViewItem item)
case FileType.PDF文档:
case FileType.图像:
case FileType.文件:
case FileType.自定义情景:
{
if (ConfigManger.Config.lastOpens.ContainsKey(item.OnlyKey))
{
Expand Down

0 comments on commit b10cf11

Please sign in to comment.