diff --git a/GetStoreApp/Extensions/DataType/Constant/ConfigKey.cs b/GetStoreApp/Extensions/DataType/Constant/ConfigKey.cs index 0b8760f9f..75ea29243 100644 --- a/GetStoreApp/Extensions/DataType/Constant/ConfigKey.cs +++ b/GetStoreApp/Extensions/DataType/Constant/ConfigKey.cs @@ -37,6 +37,8 @@ public static class ConfigKey public const string WebKernelKey = "WebKernel"; + public const string QueryLinksModeKey = "QueryLinksMode"; + public const string WindowWidthKey = "WindowWidth"; public const string WindowHeightKey = "WindowHeight"; diff --git a/GetStoreApp/GetStoreAppResource.res b/GetStoreApp/GetStoreAppResource.res index 35306bd11..4e5f81c28 100644 Binary files a/GetStoreApp/GetStoreAppResource.res and b/GetStoreApp/GetStoreAppResource.res differ diff --git a/GetStoreApp/Helpers/Controls/Store/HttpParseHelper.cs b/GetStoreApp/Helpers/Controls/Store/HttpParseHelper.cs index 44e512b32..8693b44ee 100644 --- a/GetStoreApp/Helpers/Controls/Store/HttpParseHelper.cs +++ b/GetStoreApp/Helpers/Controls/Store/HttpParseHelper.cs @@ -19,14 +19,14 @@ public static partial class HtmlParseHelper private static Regex ResultDataListRegex = ResultDataListRegularExpression(); - private static string ParseContent = string.Empty; + private static string parseContent = string.Empty; /// /// 初始化HtmlParseService类时添加HtmlReqeustHelper生成的字符串数据 /// - public static void InitializeParseData(RequestModel HttpRequestData) + public static void InitializeParseData(RequestModel httpRequestData) { - ParseContent = HttpRequestData.RequestContent; + parseContent = httpRequestData.RequestContent; } /// @@ -34,16 +34,16 @@ public static void InitializeParseData(RequestModel HttpRequestData) /// public static string HtmlParseCID() { - if (!string.IsNullOrEmpty(ParseContent)) + if (!string.IsNullOrEmpty(parseContent)) { - MatchCollection CIDCollection = CIDRegex.Matches(ParseContent); - if (CIDCollection.Count > 0) + MatchCollection cidCollection = CIDRegex.Matches(parseContent); + if (cidCollection.Count > 0) { - GroupCollection CIDGroups = CIDCollection[0].Groups; + GroupCollection cidGroups = cidCollection[0].Groups; - if (CIDGroups.Count > 0) + if (cidGroups.Count > 0) { - return CIDGroups[1].Value; + return cidGroups[1].Value; } } } @@ -55,13 +55,13 @@ public static string HtmlParseCID() /// public static List HtmlParseLinks() { - List ResultDataList = new List(); + List resultDataList = new List(); - if (!string.IsNullOrEmpty(ParseContent)) + if (!string.IsNullOrEmpty(parseContent)) { - MatchCollection ResultDataListCollection = ResultDataListRegex.Matches(ParseContent); + MatchCollection resultDataListCollection = ResultDataListRegex.Matches(parseContent); - foreach (Match matchItem in ResultDataListCollection) + foreach (Match matchItem in resultDataListCollection) { GroupCollection ResultDataListGroups = matchItem.Groups; @@ -74,11 +74,11 @@ public static List HtmlParseLinks() queryLinksData.FileSHA1 = ResultDataListGroups[4].Value; queryLinksData.FileSize = ResultDataListGroups[5].Value; - ResultDataList.Add(queryLinksData); + resultDataList.Add(queryLinksData); } } } - return ResultDataList; + return resultDataList; } } } diff --git a/GetStoreApp/Helpers/Controls/Store/HttpRequestHelper.cs b/GetStoreApp/Helpers/Controls/Store/HttpRequestHelper.cs index 8d41a8ca8..7f978b3c2 100644 --- a/GetStoreApp/Helpers/Controls/Store/HttpRequestHelper.cs +++ b/GetStoreApp/Helpers/Controls/Store/HttpRequestHelper.cs @@ -1,5 +1,6 @@ using GetStoreApp.Models.Controls.Store; using GetStoreApp.Services.Root; +using Microsoft.UI.Xaml.Controls; using System; using System.Runtime.InteropServices; using System.Text; @@ -46,7 +47,7 @@ public static string GenerateRequestContent(string type, string url, string ring /// public static async Task HttpRequestAsync(string content) { - RequestModel HttpRequestResult = null; + RequestModel httpRequestResult = null; // 添加超时设置(半分钟后停止获取) CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(); @@ -124,7 +125,7 @@ public static async Task HttpRequestAsync(string content) } finally { - HttpRequestResult = new RequestModel + httpRequestResult = new RequestModel { RequestId = RequestId, RequestStatusCode = RequestStatusCode, @@ -134,32 +135,25 @@ public static async Task HttpRequestAsync(string content) cancellationTokenSource.Dispose(); } - return HttpRequestResult; + return httpRequestResult; } /// /// 检查请求后的状态信息 /// - public static int CheckRequestState(RequestModel HttpRequestData) + public static InfoBarSeverity CheckRequestState(RequestModel HttpRequestData) { // 服务器请求异常,返回状态值3 if (HttpRequestData.RequestId is not 0) { - return 3; + return InfoBarSeverity.Error; } // 服务器请求成功 else { // 成功下返回值为成功,否则返回警告 - if (HttpRequestData.RequestContent.Contains("The links were successfully received from the Microsoft Store server.", StringComparison.Ordinal)) - { - return 1; - } - else - { - return 2; - } + return HttpRequestData.RequestContent.Contains("The links were successfully received from the Microsoft Store server.", StringComparison.OrdinalIgnoreCase) ? InfoBarSeverity.Success : InfoBarSeverity.Warning; } } } diff --git a/GetStoreApp/Helpers/Converters/ValueConverterHelper.cs b/GetStoreApp/Helpers/Converters/ValueConverterHelper.cs index e57361d40..d6eba5888 100644 --- a/GetStoreApp/Helpers/Converters/ValueConverterHelper.cs +++ b/GetStoreApp/Helpers/Converters/ValueConverterHelper.cs @@ -41,21 +41,5 @@ public static Visibility BooleanToVisibilityReverseConvert(bool value) { return value is false ? Visibility.Visible : Visibility.Collapsed; } - - /// - /// 空字符串值与显示值转换 - /// - public static Visibility StringVisibilityConvert(string value) - { - return !string.IsNullOrEmpty(value) ? Visibility.Visible : Visibility.Collapsed; - } - - /// - /// 空字符串值与显示值转换(判断结果相反) - /// - public static Visibility StringReverseVisibilityConvert(string value) - { - return string.IsNullOrEmpty(value) ? Visibility.Visible : Visibility.Collapsed; - } } } diff --git a/GetStoreApp/Models/Controls/Store/HistoryModel.cs b/GetStoreApp/Models/Controls/Store/HistoryModel.cs index 6e05a3995..903bb69d7 100644 --- a/GetStoreApp/Models/Controls/Store/HistoryModel.cs +++ b/GetStoreApp/Models/Controls/Store/HistoryModel.cs @@ -18,7 +18,7 @@ public class HistoryModel public string HistoryKey { get; set; } /// - /// 查询链接控件:历史记录的应用名称 + /// 查询链接控件:历史记录的应用名称或类别ID /// public string HistoryAppName { get; set; } diff --git a/GetStoreApp/Program.cs b/GetStoreApp/Program.cs index a026d4eba..8e0ab8683 100644 --- a/GetStoreApp/Program.cs +++ b/GetStoreApp/Program.cs @@ -126,6 +126,7 @@ private static async Task InitializeResourcesAsync(bool isDesktopProgram) { ResourceService.LocalizeReosurce(); LinkFilterService.InitializeLinkFilterValue(); + QueryLinksModeService.InitializeQueryLinksMode(); await DownloadOptionsService.InitializeAsync(); } diff --git a/GetStoreApp/Properties/AssemblyInfo.cs b/GetStoreApp/Properties/AssemblyInfo.cs index 48a3ec701..6b9a0d04f 100644 --- a/GetStoreApp/Properties/AssemblyInfo.cs +++ b/GetStoreApp/Properties/AssemblyInfo.cs @@ -7,11 +7,11 @@ [assembly: AssemblyCompany("高怡飞")] [assembly: AssemblyCopyright("Copyright ©2022-2024 高怡飞, All Rights Reserved.")] [assembly: AssemblyDescription("获取商店应用")] -[assembly: AssemblyFileVersion("3.9.424.0")] -[assembly: AssemblyInformationalVersion("3.9.424.0")] +[assembly: AssemblyFileVersion("3.9.426.0")] +[assembly: AssemblyInformationalVersion("3.9.426.0")] [assembly: AssemblyProduct("获取商店应用")] [assembly: AssemblyTitle("获取商店应用")] -[assembly: AssemblyVersion("3.9.424.0")] +[assembly: AssemblyVersion("3.9.426.0")] // 设置程序集对 COM 组件的访问权限 [assembly: ComVisible(false)] diff --git a/GetStoreApp/Services/Controls/Download/DownloadXmlService.cs b/GetStoreApp/Services/Controls/Download/DownloadXmlService.cs index 89305aa47..e8d56b77a 100644 --- a/GetStoreApp/Services/Controls/Download/DownloadXmlService.cs +++ b/GetStoreApp/Services/Controls/Download/DownloadXmlService.cs @@ -86,7 +86,7 @@ await Task.Run(async () => } catch (Exception e) { - LogService.WriteLog(LoggingLevel.Warning, "InitializeWebKernel download record state failed.", e); + LogService.WriteLog(LoggingLevel.Warning, "Initialize download record state failed.", e); return; } } diff --git a/GetStoreApp/Services/Controls/Settings/QueryLinksModeService.cs b/GetStoreApp/Services/Controls/Settings/QueryLinksModeService.cs new file mode 100644 index 000000000..59cbc42a5 --- /dev/null +++ b/GetStoreApp/Services/Controls/Settings/QueryLinksModeService.cs @@ -0,0 +1,78 @@ +using GetStoreApp.Extensions.DataType.Constant; +using GetStoreApp.Services.Root; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; + +namespace GetStoreApp.Services.Controls.Settings +{ + /// + /// 查询链接方式选择设置服务 + /// + public static class QueryLinksModeService + { + private static string queryLinksModeSettingsKey = ConfigKey.QueryLinksModeKey; + + private static DictionaryEntry defaultQueryLinksMode; + + private static DictionaryEntry _queryLinksMode; + + public static DictionaryEntry QueryLinksMode + { + get { return _queryLinksMode; } + + private set + { + if (!Equals(_queryLinksMode, value)) + { + _queryLinksMode = value; + PropertyChanged?.Invoke(null, new PropertyChangedEventArgs(nameof(QueryLinksMode))); + } + } + } + + public static List QueryLinksModeList { get; private set; } + + public static event PropertyChangedEventHandler PropertyChanged; + + /// + /// 应用在初始化前获取设置存储的查询链接方式选择值 + /// + public static void InitializeQueryLinksMode() + { + QueryLinksModeList = ResourceService.QueryLinksModeList; + + defaultQueryLinksMode = QueryLinksModeList.Find(item => item.Value.ToString() is "Official"); + + QueryLinksMode = GetQueryLinksMode(); + } + + /// + /// 获取设置存储的查询链接方式选择值,如果设置没有存储,使用默认值 + /// + private static DictionaryEntry GetQueryLinksMode() + { + object queryLinksModeValue = LocalSettingsService.ReadSetting(queryLinksModeSettingsKey); + + if (queryLinksModeValue is null) + { + SetQueryLinksMode(defaultQueryLinksMode); + return defaultQueryLinksMode; + } + + DictionaryEntry selectedQueryLinksMode = QueryLinksModeList.Find(item => item.Value.Equals(queryLinksModeValue)); + + return selectedQueryLinksMode.Key is null ? defaultQueryLinksMode : selectedQueryLinksMode; + } + + /// + /// 查询链接方式发生修改时修改设置存储的查询链接方式值 + /// + public static void SetQueryLinksMode(DictionaryEntry queryLinksMode) + { + QueryLinksMode = queryLinksMode; + + LocalSettingsService.SaveSetting(queryLinksModeSettingsKey, queryLinksMode.Value); + } + } +} diff --git a/GetStoreApp/Services/Controls/Settings/WebKernelService.cs b/GetStoreApp/Services/Controls/Settings/WebKernelService.cs index 5425514e1..c6581fead 100644 --- a/GetStoreApp/Services/Controls/Settings/WebKernelService.cs +++ b/GetStoreApp/Services/Controls/Settings/WebKernelService.cs @@ -49,7 +49,7 @@ private static DictionaryEntry GetWebKernel() } /// - /// 历史记录显示数量发生修改时修改设置存储的微软商店页面历史记录显示数量值 + /// 网页浏览器内核发生修改时修改设置存储的网页浏览器内核值 /// public static void SetWebKernel(DictionaryEntry webKernel) { diff --git a/GetStoreApp/Services/Root/ConsoleLaunchService.cs b/GetStoreApp/Services/Root/ConsoleLaunchService.cs index a09a09902..8a321b510 100644 --- a/GetStoreApp/Services/Root/ConsoleLaunchService.cs +++ b/GetStoreApp/Services/Root/ConsoleLaunchService.cs @@ -105,7 +105,7 @@ private static void InitializeRequestContent() try { typeIndex = int.Parse(ConsoleHelper.ReadLine()); - if (typeIndex < 1 || typeIndex > 4) + if (typeIndex is < 1 or > 4) { typeIndex = 1; } @@ -123,7 +123,7 @@ private static void InitializeRequestContent() try { channelIndex = int.Parse(ConsoleHelper.ReadLine()); - if (channelIndex < 1 || channelIndex > 4) + if (channelIndex is < 1 or > 4) { channelIndex = 4; } diff --git a/GetStoreApp/Services/Root/ResourceService.cs b/GetStoreApp/Services/Root/ResourceService.cs index 76b369133..bbe920cd6 100644 --- a/GetStoreApp/Services/Root/ResourceService.cs +++ b/GetStoreApp/Services/Root/ResourceService.cs @@ -42,6 +42,8 @@ public static class ResourceService public static List WebKernelList { get; } = new List(); + public static List QueryLinksModeList { get; } = new List(); + public static List InstallModeList { get; } = new List(); public static List ThemeList { get; } = new List(); @@ -77,6 +79,7 @@ public static void LocalizeReosurce() InitializeSearchStoreInfoList(); InitializeBackdropList(); InitializeWebKernelList(); + InitializeQueryLinksModeList(); InitializeInstallModeList(); InitializeThemeList(); InitializeTraceCleanupList(); @@ -229,6 +232,15 @@ private static void InitializeWebKernelList() WebKernelList.Add(new DictionaryEntry(GetLocalized("Settings/WebKernelWebView2"), "WebView2")); } + /// + /// 初始化查询链接方式信息列表 + /// + private static void InitializeQueryLinksModeList() + { + QueryLinksModeList.Add(new DictionaryEntry(GetLocalized("Settings/QueryLinksModeOfficial"), "Official")); + QueryLinksModeList.Add(new DictionaryEntry(GetLocalized("Settings/QueryLinksModeThirdParty"), "ThirdParty")); + } + /// /// 初始化安装模式信息列表 /// diff --git a/GetStoreApp/Services/Shell/DownloadService.cs b/GetStoreApp/Services/Shell/DownloadService.cs index fedddc122..fb11f9851 100644 --- a/GetStoreApp/Services/Shell/DownloadService.cs +++ b/GetStoreApp/Services/Shell/DownloadService.cs @@ -1,4 +1,5 @@ using GetStoreApp.Helpers.Root; +using GetStoreApp.Models.Controls.Store; using GetStoreApp.Services.Controls.Settings; using GetStoreApp.Services.Root; using GetStoreApp.WindowsAPI.PInvoke.Kernel32; @@ -25,7 +26,7 @@ public static class DownloadService /// /// 下载相应的文件 /// - public static async Task QueryDownloadIndexAsync() + public static async Task QueryDownloadIndexAsync(List queryLinksList) { while (true) { @@ -43,7 +44,7 @@ public static async Task QueryDownloadIndexAsync() foreach (string indexItem in indexList) { int index = Convert.ToInt32(indexItem); - if (index > ParseService._queryLinksList.Count || index < 1) + if (index > queryLinksList.Count || index < 1) { checkResult = false; break; @@ -58,12 +59,12 @@ public static async Task QueryDownloadIndexAsync() if (ConsoleLaunchService.IsAppRunning) { ConsoleHelper.WriteLine(string.Format(ResourceService.GetLocalized("Console/DownloadingInformation"), index + 1, indexList.Count)); - DownloadFile(ParseService._queryLinksList[Convert.ToInt32(indexItem) - 1].FileName, ParseService._queryLinksList[Convert.ToInt32(indexItem) - 1].FileLink); + DownloadFile(queryLinksList[Convert.ToInt32(indexItem) - 1].FileName, queryLinksList[Convert.ToInt32(indexItem) - 1].FileLink); } } ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/DownloadCompleted")); string inputString = ConsoleHelper.ReadLine(); - if (inputString is "Y" || inputString is "y") + if (inputString is "Y" or "y") { continue; } @@ -78,7 +79,7 @@ public static async Task QueryDownloadIndexAsync() { ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/SerialNumberOutRange")); string inputString = ConsoleHelper.ReadLine(); - if (inputString is "Y" || inputString is "y") + if (inputString is "Y" or "y") { continue; } @@ -92,7 +93,7 @@ public static async Task QueryDownloadIndexAsync() { ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/SerialNumberError")); string inputString = ConsoleHelper.ReadLine(); - if (inputString is "Y" || inputString is "y") + if (inputString is "Y" or "y") { continue; } diff --git a/GetStoreApp/Services/Shell/ParseService.cs b/GetStoreApp/Services/Shell/ParseService.cs index 1fd6c3a26..f5088c2b3 100644 --- a/GetStoreApp/Services/Shell/ParseService.cs +++ b/GetStoreApp/Services/Shell/ParseService.cs @@ -14,29 +14,10 @@ namespace GetStoreApp.Services.Shell /// public static class ParseService { - public static List _queryLinksList = new List(); - /// /// 解析得到的数据 /// public static async Task ParseDataAsync(AppInfoModel appInfo, List queryLinksList) - { - _queryLinksList.Clear(); - ResultListFilter(ref queryLinksList); - foreach (QueryLinksModel queryLinksItem in queryLinksList) - { - _queryLinksList.Add(queryLinksItem); - } - - PrintAppInformation(appInfo); - PrintResultList(); - await DownloadService.QueryDownloadIndexAsync(); - } - - /// - /// 按指定条件过滤数据 - /// - private static void ResultListFilter(ref List queryLinksList) { // 按要求过滤列表内容 if (LinkFilterService.EncryptedPackageFilterValue) @@ -53,6 +34,14 @@ private static void ResultListFilter(ref List queryLinksList) { queryLinksList.RemoveAll(item => item.FileName.EndsWith("blockmap", StringComparison.OrdinalIgnoreCase)); } + + if (appInfo is not null) + { + PrintAppInformation(appInfo); + } + + PrintResultList(queryLinksList); + await DownloadService.QueryDownloadIndexAsync(queryLinksList); } /// @@ -63,12 +52,13 @@ private static void PrintAppInformation(AppInfoModel appInfo) ConsoleHelper.Write(ResourceService.GetLocalized("Console/AppName") + appInfo.Name + Environment.NewLine); ConsoleHelper.Write(ResourceService.GetLocalized("Console/AppPublisher") + appInfo.Publisher + Environment.NewLine); ConsoleHelper.Write(ResourceService.GetLocalized("Console/AppDescription") + Environment.NewLine + appInfo.Description + Environment.NewLine); + ConsoleHelper.Write(Environment.NewLine); } /// /// 向控制台输出获取到的结果列表 /// - private static void PrintResultList() + private static void PrintResultList(List queryLinksList) { string serialNumberHeader = ResourceService.GetLocalized("Console/SerialNumber"); string fileNameHeader = ResourceService.GetLocalized("Console/FileName"); @@ -78,37 +68,37 @@ private static void PrintResultList() int fileNameHeaderLength = CharExtension.GetStringDisplayLengthEx(fileNameHeader); int fileSizeHeaderLength = CharExtension.GetStringDisplayLengthEx(fileSizeHeader); - int serialNumberColumnLength = (serialNumberHeaderLength > _queryLinksList.Count.ToString().Length ? serialNumberHeaderLength : _queryLinksList.Count.ToString().Length) + 3; + int serialNumberColumnLength = (serialNumberHeaderLength > queryLinksList.Count.ToString().Length ? serialNumberHeaderLength : queryLinksList.Count.ToString().Length) + 3; int fileNameContentMaxLength = 0; - foreach (QueryLinksModel queryLinksItem in _queryLinksList) + foreach (QueryLinksModel queryLinksItem in queryLinksList) { if (queryLinksItem.FileName.Length > fileNameContentMaxLength) { fileNameContentMaxLength = queryLinksItem.FileName.Length; } } - int FileNameColumnLength = ((fileNameHeaderLength > fileNameContentMaxLength) ? fileNameHeaderLength : fileNameContentMaxLength) + 3; + int fileNameColumnLength = ((fileNameHeaderLength > fileNameContentMaxLength) ? fileNameHeaderLength : fileNameContentMaxLength) + 3; + ConsoleHelper.WriteLine(string.Format(ResourceService.GetLocalized("Console/QueryLinksCount"), queryLinksList.Count)); ConsoleHelper.Write(Environment.NewLine); - ConsoleHelper.WriteLine(string.Format(ResourceService.GetLocalized("Console/QueryLinksCollection"), _queryLinksList.Count)); // 打印标题 ConsoleHelper.Write(serialNumberHeader + new string(ConsoleLaunchService.RowSplitCharacter, serialNumberColumnLength - serialNumberHeaderLength)); - ConsoleHelper.Write(fileNameHeader + new string(ConsoleLaunchService.RowSplitCharacter, FileNameColumnLength - fileNameHeaderLength)); + ConsoleHelper.Write(fileNameHeader + new string(ConsoleLaunchService.RowSplitCharacter, fileNameColumnLength - fileNameHeaderLength)); ConsoleHelper.Write(fileSizeHeader + Environment.NewLine); // 打印标题与内容的分割线 ConsoleHelper.Write(new string(ConsoleLaunchService.ColumnSplitCharacter, serialNumberHeaderLength).PadRight(serialNumberColumnLength)); - ConsoleHelper.Write(new string(ConsoleLaunchService.ColumnSplitCharacter, fileNameHeaderLength).PadRight(FileNameColumnLength)); + ConsoleHelper.Write(new string(ConsoleLaunchService.ColumnSplitCharacter, fileNameHeaderLength).PadRight(fileNameColumnLength)); ConsoleHelper.Write(new string(ConsoleLaunchService.ColumnSplitCharacter, fileSizeHeaderLength) + Environment.NewLine); // 打印内容 - for (int resultDataIndex = 0; resultDataIndex < _queryLinksList.Count; resultDataIndex++) + for (int resultDataIndex = 0; resultDataIndex < queryLinksList.Count; resultDataIndex++) { ConsoleHelper.Write(Convert.ToString(resultDataIndex + 1) + new string(ConsoleLaunchService.RowSplitCharacter, serialNumberColumnLength - Convert.ToString(resultDataIndex + 1).Length)); - ConsoleHelper.Write(_queryLinksList[resultDataIndex].FileName + new string(ConsoleLaunchService.RowSplitCharacter, FileNameColumnLength - _queryLinksList[resultDataIndex].FileName.Length)); - ConsoleHelper.Write(_queryLinksList[resultDataIndex].FileSize + Environment.NewLine); + ConsoleHelper.Write(queryLinksList[resultDataIndex].FileName + new string(ConsoleLaunchService.RowSplitCharacter, fileNameColumnLength - queryLinksList[resultDataIndex].FileName.Length)); + ConsoleHelper.Write(queryLinksList[resultDataIndex].FileSize + Environment.NewLine); } ConsoleHelper.Write(Environment.NewLine); diff --git a/GetStoreApp/Services/Shell/RequestService.cs b/GetStoreApp/Services/Shell/RequestService.cs index 1f391880e..431be9fcc 100644 --- a/GetStoreApp/Services/Shell/RequestService.cs +++ b/GetStoreApp/Services/Shell/RequestService.cs @@ -2,7 +2,9 @@ using GetStoreApp.Helpers.Controls.Store; using GetStoreApp.Helpers.Root; using GetStoreApp.Models.Controls.Store; +using GetStoreApp.Services.Controls.Settings; using GetStoreApp.Services.Root; +using Microsoft.UI.Xaml.Controls; using System; using System.Collections.Generic; using System.Threading.Tasks; @@ -61,91 +63,151 @@ public static async Task GetLinksAsync() { // 解析链接对应的产品 ID string productId = selectedType.Equals(TypeList[0], StringComparison.OrdinalIgnoreCase) ? QueryLinksHelper.ParseRequestContent(linkText) : linkText; - + InfoBarSeverity state = InfoBarSeverity.Informational; bool requestState = true; + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/GettingNow")); - while (requestState) + if (QueryLinksModeService.QueryLinksMode.Equals(QueryLinksModeService.QueryLinksModeList[0])) { - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/GettingNow")); - - string cookie = await QueryLinksHelper.GetCookieAsync(); + while (requestState) + { + string cookie = await QueryLinksHelper.GetCookieAsync(); - List queryLinksList = new List(); - AppInfoModel appInfo = null; - int state = 0; + List queryLinksList = new List(); + AppInfoModel appInfo = null; - // 获取应用信息 - Tuple appInformationResult = await QueryLinksHelper.GetAppInformationAsync(productId); + // 获取应用信息 + Tuple appInformationResult = await QueryLinksHelper.GetAppInformationAsync(productId); - if (appInformationResult.Item1) - { - // 解析非商店应用数据 - if (string.IsNullOrEmpty(appInformationResult.Item2.CategoryID)) + if (appInformationResult.Item1) { - List nonAppxPackagesList = await QueryLinksHelper.GetNonAppxPackagesAsync(productId); - foreach (QueryLinksModel nonAppxPackage in nonAppxPackagesList) + // 解析非商店应用数据 + if (string.IsNullOrEmpty(appInformationResult.Item2.CategoryID)) { - queryLinksList.Add(nonAppxPackage); + List nonAppxPackagesList = await QueryLinksHelper.GetNonAppxPackagesAsync(productId); + foreach (QueryLinksModel nonAppxPackage in nonAppxPackagesList) + { + queryLinksList.Add(nonAppxPackage); + } + state = queryLinksList.Count is 0 ? InfoBarSeverity.Warning : InfoBarSeverity.Success; + } + // 解析商店应用数据 + else + { + string fileListXml = await QueryLinksHelper.GetFileListXmlAsync(cookie, appInformationResult.Item2.CategoryID, selectedChannel); + + if (!string.IsNullOrEmpty(fileListXml)) + { + List appxPackagesList = QueryLinksHelper.GetAppxPackages(fileListXml, selectedChannel); + foreach (QueryLinksModel appxPackage in appxPackagesList) + { + queryLinksList.Add(appxPackage); + } + state = queryLinksList.Count is 0 ? InfoBarSeverity.Warning : InfoBarSeverity.Success; + } } - state = queryLinksList.Count is 0 ? 2 : 1; + + appInfo = appInformationResult.Item2; } - // 解析商店应用数据 else { - string fileListXml = await QueryLinksHelper.GetFileListXmlAsync(cookie, appInformationResult.Item2.CategoryID, selectedChannel); + state = InfoBarSeverity.Error; + } - if (!string.IsNullOrEmpty(fileListXml)) - { - List appxPackagesList = QueryLinksHelper.GetAppxPackages(fileListXml, selectedChannel); - foreach (QueryLinksModel appxPackage in appxPackagesList) + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/GetCompleted")); + + switch (state) + { + case InfoBarSeverity.Success: { - queryLinksList.Add(appxPackage); + ConsoleHelper.SetTextColor(0x02); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestSuccessfully")); + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.ResetTextColor(); + requestState = false; + await ParseService.ParseDataAsync(appInfo, queryLinksList); + break; + } + case InfoBarSeverity.Warning: + { + ConsoleHelper.SetTextColor(0x06); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestFailed")); + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.ResetTextColor(); + PrintRequestFailedData(); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/AskContinue")); + string regainString = ConsoleHelper.ReadLine(); + requestState = regainString is "Y" or "y"; + break; + } + case InfoBarSeverity.Error: + { + ConsoleHelper.SetTextColor(0x04); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestError")); + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.ResetTextColor(); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/AskContinue")); + string regainString = ConsoleHelper.ReadLine(); + requestState = regainString is "Y" or "y"; + break; } - state = queryLinksList.Count is 0 ? 2 : 1; - } } - - appInfo = appInformationResult.Item2; } - else + } + // 第三方接口 + else if (QueryLinksModeService.QueryLinksMode.Equals(QueryLinksModeService.QueryLinksModeList[1])) + { + while (requestState) { - state = 3; - } + string generateContent = HtmlRequestHelper.GenerateRequestContent(selectedType, linkText, selectedChannel); - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/GetCompleted")); + // 获取网页反馈回的原始数据 + RequestModel httpRequestData = await HtmlRequestHelper.HttpRequestAsync(generateContent); - switch (state) - { - case 1: - { - ConsoleHelper.SetTextColor(0x02); - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestSuccessfully")); - ConsoleHelper.ResetTextColor(); - requestState = false; - await ParseService.ParseDataAsync(appInfo, queryLinksList); - break; - } - case 2: - { - ConsoleHelper.SetTextColor(0x06); - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestFailed")); - ConsoleHelper.ResetTextColor(); - PrintRequestFailedData(); - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/AskContinue")); - string RegainString = ConsoleHelper.ReadLine(); - requestState = RegainString is "Y" || RegainString is "y"; - break; - } - case 3: - { - ConsoleHelper.SetTextColor(0x04); - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestError")); - ConsoleHelper.ResetTextColor(); - ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/AskContinue")); - string RegainString = ConsoleHelper.ReadLine(); - requestState = RegainString is "Y" || RegainString is "y"; - break; - } + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/GetCompleted")); + + state = HtmlRequestHelper.CheckRequestState(httpRequestData); + + switch (state) + { + case InfoBarSeverity.Success: + { + ConsoleHelper.SetTextColor(0x02); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestSuccessfully")); + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.ResetTextColor(); + requestState = false; + HtmlParseHelper.InitializeParseData(httpRequestData); + List queryLinksList = HtmlParseHelper.HtmlParseLinks(); + await ParseService.ParseDataAsync(null, queryLinksList); + break; + } + case InfoBarSeverity.Warning: + { + ConsoleHelper.SetTextColor(0x06); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestFailed")); + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.ResetTextColor(); + PrintRequestFailedData(); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/AskContinue")); + string regainString = ConsoleHelper.ReadLine(); + requestState = regainString is "Y" or "y"; + break; + } + case InfoBarSeverity.Error: + { + ConsoleHelper.SetTextColor(0x04); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/RequestError")); + ConsoleHelper.Write(Environment.NewLine); + ConsoleHelper.ResetTextColor(); + ConsoleHelper.WriteLine(ResourceService.GetLocalized("Console/AskContinue")); + string regainString = ConsoleHelper.ReadLine(); + requestState = regainString is "Y" or "y"; + break; + } + } } } } diff --git a/GetStoreApp/Strings/en-us/Console.resw b/GetStoreApp/Strings/en-us/Console.resw index ae18d336a..2cc63252f 100644 --- a/GetStoreApp/Strings/en-us/Console.resw +++ b/GetStoreApp/Strings/en-us/Console.resw @@ -192,7 +192,7 @@ ProductID sample: 9WZDNCRFJBMP - + A total of {0} results were retrieved diff --git a/GetStoreApp/Strings/en-us/Settings.resw b/GetStoreApp/Strings/en-us/Settings.resw index a8dc0dfa9..c038c9b7f 100644 --- a/GetStoreApp/Strings/en-us/Settings.resw +++ b/GetStoreApp/Strings/en-us/Settings.resw @@ -330,6 +330,18 @@ Open configuration file + + Query links mode + + + Select the application interface channel to query the link + + + Official interface + + + Third party interface + Application restart diff --git a/GetStoreApp/Strings/en-us/Store.resw b/GetStoreApp/Strings/en-us/Store.resw index 56018dc1d..5f4abdaab 100644 --- a/GetStoreApp/Strings/en-us/Store.resw +++ b/GetStoreApp/Strings/en-us/Store.resw @@ -175,7 +175,7 @@ Fill in - App name + App name / category id Channel diff --git a/GetStoreApp/Strings/zh-hans-cn/Console.resw b/GetStoreApp/Strings/zh-hans-cn/Console.resw index 78d7f5b5b..b1e6a7e2d 100644 --- a/GetStoreApp/Strings/zh-hans-cn/Console.resw +++ b/GetStoreApp/Strings/zh-hans-cn/Console.resw @@ -192,7 +192,7 @@ 产品 ID 例子:9WZDNCRFJBMP - + 共检索到{0}个结果 diff --git a/GetStoreApp/Strings/zh-hans-cn/Settings.resw b/GetStoreApp/Strings/zh-hans-cn/Settings.resw index 97c7acd19..210baf91e 100644 --- a/GetStoreApp/Strings/zh-hans-cn/Settings.resw +++ b/GetStoreApp/Strings/zh-hans-cn/Settings.resw @@ -330,6 +330,18 @@ 打开配置文件 + + 查询链接方式 + + + 选择查询链接的应用接口渠道 + + + 官方接口 + + + 第三方接口 + 重启应用 diff --git a/GetStoreApp/Strings/zh-hans-cn/Store.resw b/GetStoreApp/Strings/zh-hans-cn/Store.resw index e3dd89753..47b5a2348 100644 --- a/GetStoreApp/Strings/zh-hans-cn/Store.resw +++ b/GetStoreApp/Strings/zh-hans-cn/Store.resw @@ -175,7 +175,7 @@ 填入 - 应用名称 + 应用名称 / 类别ID 通道 diff --git a/GetStoreApp/UI/Controls/Download/CompletedControl.xaml b/GetStoreApp/UI/Controls/Download/CompletedControl.xaml index d5b7f8f2b..628f43c91 100644 --- a/GetStoreApp/UI/Controls/Download/CompletedControl.xaml +++ b/GetStoreApp/UI/Controls/Download/CompletedControl.xaml @@ -80,7 +80,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/OpenFolderToolTip')}"> - + @@ -113,7 +113,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -123,7 +123,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -133,7 +133,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/DeleteOptionsToolTip')}"> - + @@ -161,7 +161,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -427,7 +427,12 @@ Command="{StaticResource DeleteCommand}" CommandParameter="{Binding}" Text="{x:Bind root:ResourceService.GetLocalized('Download/Delete')}" - ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/DeleteToolTip')}" /> + ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/DeleteToolTip')}"> + + + + + + ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/DeleteWithFileToolTip')}"> + + + + + @@ -449,7 +459,7 @@ Text="{x:Bind root:ResourceService.GetLocalized('Download/ShareFile')}"> - + diff --git a/GetStoreApp/UI/Controls/Download/DownloadingControl.xaml b/GetStoreApp/UI/Controls/Download/DownloadingControl.xaml index b079f8615..eeb855dda 100644 --- a/GetStoreApp/UI/Controls/Download/DownloadingControl.xaml +++ b/GetStoreApp/UI/Controls/Download/DownloadingControl.xaml @@ -122,7 +122,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -132,7 +132,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -143,7 +143,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/DeleteSelectedToolTip')}"> - + diff --git a/GetStoreApp/UI/Controls/Download/UnfinishedControl.xaml b/GetStoreApp/UI/Controls/Download/UnfinishedControl.xaml index 7ecef8d75..9059f8e42 100644 --- a/GetStoreApp/UI/Controls/Download/UnfinishedControl.xaml +++ b/GetStoreApp/UI/Controls/Download/UnfinishedControl.xaml @@ -74,7 +74,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/OpenFolderToolTip')}"> - + @@ -86,7 +86,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/ContinueAllToolTip')}"> - + @@ -119,7 +119,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -129,7 +129,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -140,7 +140,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Download/DeleteSelectedToolTip')}"> - + @@ -288,7 +288,7 @@ Visibility="{x:Bind converter:ValueCheckConverterHelper.DownloadFlagCheck(DownloadFlag, 2)}"> - + diff --git a/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml b/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml index d45d5ab93..de166f6dd 100644 --- a/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml +++ b/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml @@ -380,7 +380,8 @@ HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" Background="{ThemeResource CardBackgroundFillColorDefaultBrush}" - IsExpanded="True"> + IsExpanded="True" + Visibility="{x:Bind IsAppInfoVisible, Mode=OneWay}"> @@ -508,7 +509,7 @@ Grid.Column="0" Margin="0,0,12,0" FontSize="16" - Glyph="" /> + Glyph="" /> + Visibility="{x:Bind converter:ValueConverterHelper.BooleanToVisibilityReverseConvert(IsPackagedApp), Mode=OneWay}" /> + Visibility="{x:Bind IsPackagedApp, Mode=OneWay}" /> @@ -588,7 +589,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -598,7 +599,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -608,7 +609,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('Store/CopyOptionsToolTip')}"> - + @@ -636,7 +637,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + diff --git a/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml.cs b/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml.cs index 9d1a409d8..08c9ed2b4 100644 --- a/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml.cs +++ b/GetStoreApp/UI/Controls/Store/QueryLinksControl.xaml.cs @@ -201,6 +201,38 @@ public bool ResultControlVisable } } + private bool _isAppInfoVisible = false; + + public bool IsAppInfoVisible + { + get { return _isAppInfoVisible; } + + set + { + if (!Equals(_isAppInfoVisible, value)) + { + _resultCotnrolVisable = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsAppInfoVisible))); + } + } + } + + private bool _isPackagedApp = false; + + public bool IsPackagedApp + { + get { return _isPackagedApp; } + + set + { + if (!Equals(_isPackagedApp, value)) + { + _isPackagedApp = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsPackagedApp))); + } + } + } + private bool _isSelectMode = false; public bool IsSelectMode @@ -536,11 +568,11 @@ private void OnQueryLinksClicked(object sender, RoutedEventArgs args) private void OnCopyQueryedAppInfoClicked(object sender, RoutedEventArgs args) { StringBuilder appInformationBuilder = new StringBuilder(); - appInformationBuilder.Append(ResourceService.GetLocalized("Store/AppName")); + appInformationBuilder.Append(ResourceService.GetLocalized("Store/QueryedAppName")); appInformationBuilder.AppendLine(AppInfo.Name); - appInformationBuilder.Append(ResourceService.GetLocalized("Store/AppPublisher")); + appInformationBuilder.Append(ResourceService.GetLocalized("Store/QueryedAppPublisher")); appInformationBuilder.AppendLine(AppInfo.Publisher); - appInformationBuilder.AppendLine(ResourceService.GetLocalized("Store/AppDescription")); + appInformationBuilder.AppendLine(ResourceService.GetLocalized("Store/QueryedAppDescription")); appInformationBuilder.AppendLine(AppInfo.Description); bool copyResult = CopyPasteHelper.CopyTextToClipBoard(appInformationBuilder.ToString()); @@ -889,83 +921,171 @@ public void QueryLinks() IsQueryingLinks = true; SetControlState(InfoBarSeverity.Informational); - Task.Run(async () => + // 商店接口查询方式 + if (QueryLinksModeService.QueryLinksMode.Equals(QueryLinksModeService.QueryLinksModeList[0])) { - List queryLinksList = new List(); + Task.Run(async () => + { + List queryLinksList = new List(); - // 记录当前选定的选项和填入的内容 - int typeIndex = TypeList.FindIndex(item => item.InternalName == SelectedType.InternalName); - int channelIndex = ChannelList.FindIndex(item => item.InternalName == SelectedChannel.InternalName); - string link = LinkText; + // 记录当前选定的选项和填入的内容 + int typeIndex = TypeList.FindIndex(item => item.InternalName == SelectedType.InternalName); + int channelIndex = ChannelList.FindIndex(item => item.InternalName == SelectedChannel.InternalName); + string link = LinkText; - // 解析链接对应的产品 ID - string productId = SelectedType.Equals(TypeList[0]) ? QueryLinksHelper.ParseRequestContent(LinkText) : LinkText; + // 解析链接对应的产品 ID + string productId = SelectedType.Equals(TypeList[0]) ? QueryLinksHelper.ParseRequestContent(LinkText) : LinkText; - string cookie = await QueryLinksHelper.GetCookieAsync(); + string cookie = await QueryLinksHelper.GetCookieAsync(); - // 获取应用信息 - Tuple appInformationResult = await QueryLinksHelper.GetAppInformationAsync(productId); + // 获取应用信息 + Tuple appInformationResult = await QueryLinksHelper.GetAppInformationAsync(productId); - if (appInformationResult.Item1) - { - // 解析非商店应用数据 - if (string.IsNullOrEmpty(appInformationResult.Item2.CategoryID)) + if (appInformationResult.Item1) { - List nonAppxPackagesList = await QueryLinksHelper.GetNonAppxPackagesAsync(productId); - foreach (QueryLinksModel nonAppxPackage in nonAppxPackagesList) + // 解析非商店应用数据 + if (string.IsNullOrEmpty(appInformationResult.Item2.CategoryID)) { - queryLinksList.Add(nonAppxPackage); + List nonAppxPackagesList = await QueryLinksHelper.GetNonAppxPackagesAsync(productId); + foreach (QueryLinksModel nonAppxPackage in nonAppxPackagesList) + { + queryLinksList.Add(nonAppxPackage); + } } - } - // 解析商店应用数据 - else - { - string fileListXml = await QueryLinksHelper.GetFileListXmlAsync(cookie, appInformationResult.Item2.CategoryID, ChannelList[channelIndex].InternalName); - - if (!string.IsNullOrEmpty(fileListXml)) + // 解析商店应用数据 + else { - List appxPackagesList = QueryLinksHelper.GetAppxPackages(fileListXml, ChannelList[channelIndex].InternalName); - foreach (QueryLinksModel appxPackage in appxPackagesList) + string fileListXml = await QueryLinksHelper.GetFileListXmlAsync(cookie, appInformationResult.Item2.CategoryID, ChannelList[channelIndex].InternalName); + + if (!string.IsNullOrEmpty(fileListXml)) { - queryLinksList.Add(appxPackage); + List appxPackagesList = QueryLinksHelper.GetAppxPackages(fileListXml, ChannelList[channelIndex].InternalName); + foreach (QueryLinksModel appxPackage in appxPackagesList) + { + queryLinksList.Add(appxPackage); + } } } - } - // 按设置选项设置的内容过滤列表 - if (LinkFilterService.EncryptedPackageFilterValue) - { - queryLinksList.RemoveAll(item => - item.FileName.EndsWith(".eappx", StringComparison.OrdinalIgnoreCase) || - item.FileName.EndsWith(".emsix", StringComparison.OrdinalIgnoreCase) || - item.FileName.EndsWith(".eappxbundle", StringComparison.OrdinalIgnoreCase) || - item.FileName.EndsWith(".emsixbundle", StringComparison.OrdinalIgnoreCase) - ); - } + // 按设置选项设置的内容过滤列表 + if (LinkFilterService.EncryptedPackageFilterValue) + { + queryLinksList.RemoveAll(item => + item.FileName.EndsWith(".eappx", StringComparison.OrdinalIgnoreCase) || + item.FileName.EndsWith(".emsix", StringComparison.OrdinalIgnoreCase) || + item.FileName.EndsWith(".eappxbundle", StringComparison.OrdinalIgnoreCase) || + item.FileName.EndsWith(".emsixbundle", StringComparison.OrdinalIgnoreCase) + ); + } + + if (LinkFilterService.BlockMapFilterValue) + { + queryLinksList.RemoveAll(item => item.FileName.EndsWith("blockmap", StringComparison.OrdinalIgnoreCase)); + } - if (LinkFilterService.BlockMapFilterValue) + queryLinksList.Sort((item1, item2) => item1.FileName.CompareTo(item2.FileName)); + + DispatcherQueue.TryEnqueue(() => + { + IsQueryingLinks = false; + + if (queryLinksList.Count > 0) + { + UpdateHistory(appInformationResult.Item2.Name, typeIndex, channelIndex, link); + SetControlState(InfoBarSeverity.Success); + ResultControlVisable = true; + IsAppInfoVisible = true; + IsPackagedApp = !string.IsNullOrEmpty(appInformationResult.Item2.CategoryID); + + AppInfo.Name = appInformationResult.Item2.Name; + AppInfo.Publisher = appInformationResult.Item2.Publisher; + AppInfo.Description = appInformationResult.Item2.Description; + AppInfo.CategoryID = appInformationResult.Item2.CategoryID; + AppInfo.ProductID = appInformationResult.Item2.ProductID; + + lock (queryLinksLock) + { + QueryLinksCollection.Clear(); + foreach (QueryLinksModel resultItem in queryLinksList) + { + QueryLinksCollection.Add(resultItem); + Task.Delay(1); + } + } + } + else + { + SetControlState(InfoBarSeverity.Warning); + ResultControlVisable = false; + IsAppInfoVisible = false; + } + }); + } + else { - queryLinksList.RemoveAll(item => item.FileName.EndsWith("blockmap", StringComparison.OrdinalIgnoreCase)); + DispatcherQueue.TryEnqueue(() => + { + IsQueryingLinks = false; + SetControlState(InfoBarSeverity.Error); + ResultControlVisable = false; + }); } + }); + } - queryLinksList.Sort((item1, item2) => item1.FileName.CompareTo(item2.FileName)); + // 第三方接口查询方式 + else if (QueryLinksModeService.QueryLinksMode.Equals(QueryLinksModeService.QueryLinksModeList[1])) + { + Task.Run(async () => + { + // 记录当前选定的选项和填入的内容 + int typeIndex = TypeList.FindIndex(item => item.InternalName == SelectedType.InternalName); + int channelIndex = ChannelList.FindIndex(item => item.InternalName == SelectedChannel.InternalName); + string link = LinkText; - DispatcherQueue.TryEnqueue(() => + // 生成请求的内容 + string generateContent = HtmlRequestHelper.GenerateRequestContent(SelectedType.InternalName, link, SelectedChannel.InternalName); + + // 获取网页反馈回的原始数据 + RequestModel httpRequestData = await HtmlRequestHelper.HttpRequestAsync(generateContent); + + // 检查服务器返回获取的状态 + InfoBarSeverity requestState = HtmlRequestHelper.CheckRequestState(httpRequestData); + + if (requestState is InfoBarSeverity.Success) { - IsQueryingLinks = false; + HtmlParseHelper.InitializeParseData(httpRequestData); + string categoryId = HtmlParseHelper.HtmlParseCID(); + List queryLinksList = HtmlParseHelper.HtmlParseLinks(); - if (queryLinksList.Count > 0) + // 按设置选项设置的内容过滤列表 + if (LinkFilterService.EncryptedPackageFilterValue) + { + queryLinksList.RemoveAll(item => + item.FileName.EndsWith(".eappx", StringComparison.OrdinalIgnoreCase) || + item.FileName.EndsWith(".emsix", StringComparison.OrdinalIgnoreCase) || + item.FileName.EndsWith(".eappxbundle", StringComparison.OrdinalIgnoreCase) || + item.FileName.EndsWith(".emsixbundle", StringComparison.OrdinalIgnoreCase) + ); + } + + if (LinkFilterService.BlockMapFilterValue) + { + queryLinksList.RemoveAll(item => item.FileName.EndsWith("blockmap", StringComparison.OrdinalIgnoreCase)); + } + + queryLinksList.Sort((item1, item2) => item1.FileName.CompareTo(item2.FileName)); + + DispatcherQueue.TryEnqueue(() => { - UpdateHistory(appInformationResult.Item2.Name, typeIndex, channelIndex, link); + IsQueryingLinks = false; + IsAppInfoVisible = false; + IsPackagedApp = !string.IsNullOrEmpty(categoryId); + + UpdateHistory(categoryId, typeIndex, channelIndex, link); SetControlState(InfoBarSeverity.Success); ResultControlVisable = true; - AppInfo.Name = appInformationResult.Item2.Name; - AppInfo.Publisher = appInformationResult.Item2.Publisher; - AppInfo.Description = appInformationResult.Item2.Description; - AppInfo.CategoryID = appInformationResult.Item2.CategoryID; - AppInfo.ProductID = appInformationResult.Item2.ProductID; - lock (queryLinksLock) { QueryLinksCollection.Clear(); @@ -975,24 +1095,30 @@ public void QueryLinks() Task.Delay(1); } } - } - else + }); + } + else if (requestState is InfoBarSeverity.Warning) + { + DispatcherQueue.TryEnqueue(() => { + IsQueryingLinks = false; SetControlState(InfoBarSeverity.Warning); ResultControlVisable = false; - } - }); - } - else - { - DispatcherQueue.TryEnqueue(() => + IsAppInfoVisible = false; + }); + } + else if (requestState is InfoBarSeverity.Error) { - IsQueryingLinks = false; - SetControlState(InfoBarSeverity.Error); - ResultControlVisable = false; - }); - } - }); + DispatcherQueue.TryEnqueue(() => + { + IsQueryingLinks = false; + SetControlState(InfoBarSeverity.Error); + ResultControlVisable = false; + IsAppInfoVisible = false; + }); + } + }); + } } /// @@ -1064,6 +1190,7 @@ private void UpdateHistory(string appName, int selectedType, int selectedChannel { HistoryModel historyItem = historyList[index]; historyItem.CreateTimeStamp = timeStamp; + historyItem.HistoryAppName = appName; historyList.RemoveAt(index); historyList.Insert(0, historyItem); HistoryStorageService.SaveQueryLinksData(historyList); diff --git a/GetStoreApp/UI/Controls/Store/SearchStoreControl.xaml b/GetStoreApp/UI/Controls/Store/SearchStoreControl.xaml index 3e485994e..494c5f3b0 100644 --- a/GetStoreApp/UI/Controls/Store/SearchStoreControl.xaml +++ b/GetStoreApp/UI/Controls/Store/SearchStoreControl.xaml @@ -211,7 +211,7 @@ Grid.Column="0" Margin="0,0,12,0" FontSize="16" - Glyph="" /> + Glyph="" /> - + @@ -247,7 +247,7 @@ ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('UWPApp/RefreshToolTip')}"> - + diff --git a/GetStoreApp/Views/Pages/AboutPage.xaml b/GetStoreApp/Views/Pages/AboutPage.xaml index 8c213d987..2de991fe6 100644 --- a/GetStoreApp/Views/Pages/AboutPage.xaml +++ b/GetStoreApp/Views/Pages/AboutPage.xaml @@ -98,14 +98,24 @@ Padding="11,0" Click="{x:Bind OnShowReleaseNotesClicked}" Text="{x:Bind root:ResourceService.GetLocalized('About/ShowReleaseNotes')}" - ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('About/ShowReleaseNotesToolTip')}" /> + ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('About/ShowReleaseNotesToolTip')}"> + + + + + + ToolTipService.ToolTip="{x:Bind root:ResourceService.GetLocalized('About/ShowLicenseToolTip')}"> + + + + + @@ -324,7 +334,7 @@ Padding="5" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" - ItemsSource="{x:Bind ReferenceDict}" + ItemsSource="{x:Bind ReferenceList}" SelectionMode="None"> @@ -845,7 +855,7 @@ Padding="5" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" - ItemsSource="{x:Bind ThanksDict}" + ItemsSource="{x:Bind ThanksList}" SelectionMode="None"> diff --git a/GetStoreApp/Views/Pages/AboutPage.xaml.cs b/GetStoreApp/Views/Pages/AboutPage.xaml.cs index d90e999a1..aff827b22 100644 --- a/GetStoreApp/Views/Pages/AboutPage.xaml.cs +++ b/GetStoreApp/Views/Pages/AboutPage.xaml.cs @@ -55,23 +55,23 @@ public bool IsChecking } //项目引用信息 - private Hashtable ReferenceDict { get; } = new Hashtable() + private List ReferenceList { get; } = new List() { - { "Microsoft.Windows.CsWinRT","https://github.com/microsoft/cswinrt"}, - { "Microsoft.WindowsAppSDK","https://github.com/microsoft/windowsappsdk"}, - { "Microsoft.WindowsPackageManager.ComInterop","https://github.com/microsoft/winget-cli"}, - { "Mile.Aria2", "https://github.com/ProjectMile/Mile.Aria2"}, + new DictionaryEntry("Microsoft.Windows.CsWinRT","https://github.com/microsoft/cswinrt"), + new DictionaryEntry( "Microsoft.WindowsAppSDK","https://github.com/microsoft/windowsappsdk"), + new DictionaryEntry("Microsoft.WindowsPackageManager.ComInterop", "https://github.com/microsoft/winget-cli"), + new DictionaryEntry("Mile.Aria2", "https://github.com/ProjectMile/Mile.Aria2"), }; //项目感谢者信息 - private Hashtable ThanksDict { get; } = new Hashtable() + private List ThanksList { get; } = new List() { - { "AndromedaMelody","https://github.com/AndromedaMelody" }, - { "cnbluefire","https://github.com/cnbluefire" }, - { "飞翔","https://fionlen.azurewebsites.net" }, - { "MouriNaruto","https://github.com/MouriNaruto" }, - { "TaylorShi","https://github.com/TaylorShi" }, - { "wherewhere","https://github.com/wherewhere" }, + new DictionaryEntry("AndromedaMelody", "https://github.com/AndromedaMelody"), + new DictionaryEntry("cnbluefire", "https://github.com/cnbluefire"), + new DictionaryEntry("飞翔", "https://fionlen.azurewebsites.net"), + new DictionaryEntry("MouriNaruto", "https://github.com/MouriNaruto"), + new DictionaryEntry("TaylorShi", "https://github.com/TaylorShi"), + new DictionaryEntry("wherewhere", "https://github.com/wherewhere"), }; public event PropertyChangedEventHandler PropertyChanged; diff --git a/GetStoreApp/Views/Pages/SettingsPage.xaml b/GetStoreApp/Views/Pages/SettingsPage.xaml index 2e5eff87d..b540e844d 100644 --- a/GetStoreApp/Views/Pages/SettingsPage.xaml +++ b/GetStoreApp/Views/Pages/SettingsPage.xaml @@ -503,7 +503,7 @@ Grid.Column="0" Margin="0,0,12,0" FontSize="16" - Glyph="" /> + Glyph="" /> - + + Text="{x:Bind sys:Convert.ToString(WebKernelList[0].Key)}" /> + Text="{x:Bind sys:Convert.ToString(WebKernelList[1].Key)}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -631,7 +699,7 @@ Grid.Column="0" Margin="0,0,12,0" FontSize="16" - Glyph="" /> + Glyph="" /> + Glyph="" /> LanguageList { get; } = LanguageService.LanguageList; - private List HistoryLiteNumList { get; } = WebKernelService.WebKernelList; + private List WebKernelList { get; } = WebKernelService.WebKernelList; + + private List QueryLinksModeList { get; } = QueryLinksModeService.QueryLinksModeList; private List WinGetInstallModeList { get; } = WinGetConfigService.WinGetInstallModeList; @@ -460,11 +478,24 @@ private void OnWebKernelSelectClicked(object sender, RoutedEventArgs args) ToggleMenuFlyoutItem toggleMenuFlyoutItem = sender as ToggleMenuFlyoutItem; if (toggleMenuFlyoutItem.Tag is not null) { - WebKernelItem = HistoryLiteNumList[Convert.ToInt32(toggleMenuFlyoutItem.Tag)]; + WebKernelItem = WebKernelList[Convert.ToInt32(toggleMenuFlyoutItem.Tag)]; WebKernelService.SetWebKernel(WebKernelItem); } } + /// + /// 选择查询链接方式 + /// + private void OnQueryLinksModeSelectClicked(object sender, RoutedEventArgs args) + { + ToggleMenuFlyoutItem toggleMenuFlyoutItem = sender as ToggleMenuFlyoutItem; + if (toggleMenuFlyoutItem.Tag is not null) + { + QueryLinksModeItem = QueryLinksModeList[Convert.ToInt32(toggleMenuFlyoutItem.Tag)]; + QueryLinksModeService.SetQueryLinksMode(QueryLinksModeItem); + } + } + /// /// WinGet 程序包安装方式设置 /// @@ -837,11 +868,11 @@ private string LocalizeDisplayNumber(DictionaryEntry selectedBackdrop) { return selectedBackdrop.Key.ToString(); } - else if (index is 1 || index is 2) + else if (index is 1 or 2) { return ResourceService.GetLocalized("Settings/Mica") + " " + selectedBackdrop.Key.ToString(); } - else if (index is 3 || index is 4 || index is 5) + else if (index is 3 or 4 or 5) { return ResourceService.GetLocalized("Settings/DesktopAcrylic") + " " + selectedBackdrop.Key.ToString(); } diff --git a/GetStoreAppPackage/GetStoreAppPackage.wapproj b/GetStoreAppPackage/GetStoreAppPackage.wapproj index 43d9ca5ac..beb0df37c 100644 --- a/GetStoreAppPackage/GetStoreAppPackage.wapproj +++ b/GetStoreAppPackage/GetStoreAppPackage.wapproj @@ -38,7 +38,7 @@ 0 False DXFeatureLevel - x64|arm64 + x86|x64|arm64 Language=EN-US;ZH-HANS-CN True SHA256 diff --git a/GetStoreAppPackage/Package.appxmanifest b/GetStoreAppPackage/Package.appxmanifest index 8a6a48967..80a06f0cf 100644 --- a/GetStoreAppPackage/Package.appxmanifest +++ b/GetStoreAppPackage/Package.appxmanifest @@ -12,7 +12,7 @@ + Version="3.9.426.0" /> ms-resource:PackageDisplayName diff --git a/GetStoreAppWebView/GetStoreAppWebViewResource.res b/GetStoreAppWebView/GetStoreAppWebViewResource.res index 4d69756b4..bbe75a6fb 100644 Binary files a/GetStoreAppWebView/GetStoreAppWebViewResource.res and b/GetStoreAppWebView/GetStoreAppWebViewResource.res differ diff --git a/GetStoreAppWebView/Properties/AssemblyInfo.cs b/GetStoreAppWebView/Properties/AssemblyInfo.cs index 0d79a0ffc..08e3050d5 100644 --- a/GetStoreAppWebView/Properties/AssemblyInfo.cs +++ b/GetStoreAppWebView/Properties/AssemblyInfo.cs @@ -7,11 +7,11 @@ [assembly: AssemblyCompany("高怡飞")] [assembly: AssemblyCopyright("Copyright ©2022-2024 高怡飞, All Rights Reserved.")] [assembly: AssemblyDescription("网页浏览器")] -[assembly: AssemblyFileVersion("3.9.424.0")] -[assembly: AssemblyInformationalVersion("3.9.424.0")] +[assembly: AssemblyFileVersion("3.9.426.0")] +[assembly: AssemblyInformationalVersion("3.9.426.0")] [assembly: AssemblyProduct("网页浏览器")] [assembly: AssemblyTitle("网页浏览器")] -[assembly: AssemblyVersion("3.9.424.0")] +[assembly: AssemblyVersion("3.9.426.0")] // 设置程序集对 COM 组件的访问权限 [assembly: ComVisible(false)] diff --git a/GetStoreAppWebView/Views/Windows/WebWindow.xaml b/GetStoreAppWebView/Views/Windows/WebWindow.xaml index 97f4e0964..8cf165633 100644 --- a/GetStoreAppWebView/Views/Windows/WebWindow.xaml +++ b/GetStoreAppWebView/Views/Windows/WebWindow.xaml @@ -136,7 +136,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -147,7 +147,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -157,7 +157,7 @@ Style="{StaticResource AppBarButtonStyle}"> - + @@ -242,7 +242,7 @@ Text="{x:Bind root:ResourceService.GetLocalized('WebView/ClearWebCache')}"> - + diff --git a/Microsoft.Management.Deployment.Projection/Microsoft.Management.Deployment.Projection.csproj b/Microsoft.Management.Deployment.Projection/Microsoft.Management.Deployment.Projection.csproj index 317733c61..184d9504a 100644 --- a/Microsoft.Management.Deployment.Projection/Microsoft.Management.Deployment.Projection.csproj +++ b/Microsoft.Management.Deployment.Projection/Microsoft.Management.Deployment.Projection.csproj @@ -31,7 +31,7 @@ - + diff --git a/Microsoft.Management.Deployment.Projection/Properties/AssemblyInfo.cs b/Microsoft.Management.Deployment.Projection/Properties/AssemblyInfo.cs index 0427203b2..0f959cdb1 100644 --- a/Microsoft.Management.Deployment.Projection/Properties/AssemblyInfo.cs +++ b/Microsoft.Management.Deployment.Projection/Properties/AssemblyInfo.cs @@ -4,10 +4,10 @@ // 程序集信息设置 [assembly: AssemblyCompany("高怡飞")] [assembly: AssemblyCopyright("©Copyright ©2022-2024 高怡飞, All Rights Reserved.")] -[assembly: AssemblyFileVersion("3.9.424.0")] -[assembly: AssemblyInformationalVersion("3.9.424.0")] +[assembly: AssemblyFileVersion("3.9.426.0")] +[assembly: AssemblyInformationalVersion("3.9.426.0")] [assembly: AssemblyProduct("获取商店应用 WinGet WinRT 扩展")] -[assembly: AssemblyVersion("3.9.424.0")] +[assembly: AssemblyVersion("3.9.426.0")] // 设置程序集仅允许在Windows平台上可用 [assembly: SupportedOSPlatform("windows10.0.22621")]