Skip to content

Commit

Permalink
Merge pull request #217 from jitwxs/dev
Browse files Browse the repository at this point in the history
optimized tips when input keywords illegal
  • Loading branch information
jitwxs authored Aug 25, 2024
2 parents bd61911 + e565982 commit 6f49726
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions MusicLyricApp/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,14 @@ private void ReloadConfig()
private void ReloadInputIdText()
{
var inputText = Search_Text.Text.Trim();
var inputStrList = new List<string>();

// 判断是否是目录
if (Directory.Exists(inputText))
{
var searchSource = _globalSearchInfo.SettingBean.Param.SearchSource;
var searchType = _globalSearchInfo.SettingBean.Param.SearchType;

var subFileNameList = new List<string>();

var directoryInfo = new DirectoryInfo(inputText);
foreach (var info in directoryInfo.GetFileSystemInfos())
{
Expand All @@ -182,26 +181,28 @@ private void ReloadInputIdText()
{
// check filename is legal param
GlobalUtils.CheckInputId(name, searchSource, searchType);
subFileNameList.Add(name);
inputStrList.Add(name);
}
catch (MusicLyricException ignore)
{
}
}
}

_globalSearchInfo.InputIds = subFileNameList.ToArray();
}
else
{
// 不是目录,认为是实际的 ID
var ids = Search_Text.Text.Trim().Split(',');
_globalSearchInfo.InputIds = new string[ids.Length];
for (var i = 0; i < ids.Length; i++)
foreach (var name in Search_Text.Text.Trim().Split(','))
{
_globalSearchInfo.InputIds[i] = ids[i].Trim();
if (string.IsNullOrWhiteSpace(name))
{
continue;
}
inputStrList.Add(name.Trim());
}
}

_globalSearchInfo.InputIds = inputStrList.ToArray();
}

/// <summary>
Expand Down Expand Up @@ -275,7 +276,7 @@ private Dictionary<string, ResultVo<SaveVo>> SearchBySongId(List<SearchInfo.Inpu
var inputs = _globalSearchInfo.InputIds;
if (inputs.Length < 1)
{
throw new MusicLyricException(ErrorMsg.INPUT_ID_ILLEGAL);
throw new MusicLyricException(ErrorMsg.SEARCH_RESULT_EMPTY);
}

foreach (var input in inputs)
Expand Down

0 comments on commit 6f49726

Please sign in to comment.