Skip to content

Commit a89a140

Browse files
committed
适配字体分类
使用 WinGet 自带版本信息
1 parent 9ee7ba3 commit a89a140

13 files changed

Lines changed: 206 additions & 199 deletions

File tree

.github/workflows/build-and-package.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
runs-on: windows-2025-vs2026
2020
strategy:
2121
matrix:
22-
config: [x64, x86, ARM64]
22+
config: [x86, x64, ARM64]
2323

2424
env:
2525
Solution_Name: WinGetStore.slnx
@@ -43,15 +43,15 @@ jobs:
4343

4444
# Install the .NET Core App workload
4545
- name: Install .NET Core App
46-
uses: actions/setup-dotnet@v4
46+
uses: actions/setup-dotnet@v5
4747
with:
4848
dotnet-version: ${{ env.DOTNET_VERSION }}
4949

5050
# Add MSBuild to the PATH: https://github.com/microsoft/setup-msbuild
5151
- name: Setup MSBuild.exe
5252
uses: microsoft/setup-msbuild@v2
5353
with:
54-
msbuild-architecture: ${{ matrix.config }}
54+
msbuild-architecture: x64
5555

5656
# Restore the application to populate the obj folder with RuntimeIdentifiers
5757
- name: Restore the application
@@ -94,7 +94,7 @@ jobs:
9494

9595
# Upload the MSIX package: https://github.com/marketplace/actions/upload-a-build-artifact
9696
- name: Upload build artifacts
97-
uses: actions/upload-artifact@v4
97+
uses: actions/upload-artifact@v6
9898
with:
9999
name: MSIX Package (${{ matrix.config }})
100100
path: WinGetStore/AppxPackages/**

WinGetStore/Assets/Logos/Font.svg

Lines changed: 23 additions & 0 deletions
Loading

WinGetStore/Controls/PackageControl/PackageControl.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -148,31 +148,15 @@ protected override void OnApplyTemplate()
148148
{
149149
base.OnApplyTemplate();
150150

151-
if (ActionButton != null)
152-
{
153-
ActionButton.Click -= ActionButton_Click;
154-
}
155-
156-
if (InstallProgressControl != null)
157-
{
158-
InstallProgressControl.Click -= ActionButton_Click;
159-
}
160-
151+
ActionButton?.Click -= ActionButton_Click;
152+
InstallProgressControl?.Click -= ActionButton_Click;
161153
TemplateSettings.ShouldUpdatePackage -= TemplateSettings_ShouldUpdatePackage;
162154

163155
ActionButton = GetTemplateChild(ActionButtonName) as ButtonBase;
164156
InstallProgressControl = GetTemplateChild(InstallProgressControlName) as ButtonBase;
165157

166-
if (ActionButton != null)
167-
{
168-
ActionButton.Click += ActionButton_Click;
169-
}
170-
171-
if (InstallProgressControl != null)
172-
{
173-
InstallProgressControl.Click += ActionButton_Click;
174-
}
175-
158+
ActionButton?.Click += ActionButton_Click;
159+
InstallProgressControl?.Click += ActionButton_Click;
176160
TemplateSettings.ShouldUpdatePackage += TemplateSettings_ShouldUpdatePackage;
177161
}
178162

@@ -214,7 +198,7 @@ private async Task UpdateCatalogPackageAsync()
214198
InstallOptions installOptions = WinGetProjectionFactory.TryCreateInstallOptions();
215199
PackageManager packageManager = WinGetProjectionFactory.TryCreatePackageManager();
216200

217-
PackageInstallerInfo installerInfo = version.GetApplicableInstaller(installOptions);
201+
if (version.GetApplicableInstaller(installOptions) is not PackageInstallerInfo installerInfo) { return; }
218202
await templateSettings.SetValueAsync(PackageControlTemplateSettings.InstallerTypeProperty, installerInfo.InstallerType);
219203

220204
PackageCatalogInfo info = version.PackageCatalog.Info;

WinGetStore/Controls/SettingsCard/SettingsCard.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ private void RegisterAutomation()
6969
// We don't want to override an AutomationProperties.Name that is manually set, or if the Content basetype is of type ButtonBase (the ButtonBase.Content will be used then)
7070
if (Content is UIElement element
7171
&& string.IsNullOrEmpty(AutomationProperties.GetName(element))
72-
&& element is not ButtonBase or TextBlock)
72+
&& element is not (ButtonBase or TextBlock))
7373
{
7474
AutomationProperties.SetName(element, headerString);
7575
}

WinGetStore/Helpers/SettingsHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static T Deserialize<TValue>([StringSyntax(StringSyntaxAttribute.Json)] string j
101101
[JsonSerializable(typeof(DateTimeOffset))]
102102
#if CANARY
103103
[JsonSerializable(typeof(ArtifactsInfo))]
104-
[JsonSerializable(typeof(RunInfo))]
104+
[JsonSerializable(typeof(WorkflowRunsInfo))]
105105
#else
106106
[JsonSerializable(typeof(UpdateInfo))]
107107
#endif

WinGetStore/Helpers/UpdateHelper.cs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ namespace WinGetStore.Helpers
1717
public static class UpdateHelper
1818
{
1919
#if CANARY
20-
private const string GITHUB_API = "https://api.github.com/repos/{0}/{1}/actions/artifacts";
21-
private const string GITHUB_RUNS_API = "https://api.github.com/repos/{0}/{1}/actions/runs/{2}";
20+
private const string GITHUB_API = "https://api.github.com/repos/{0}/{1}/actions/runs";
2221

2322
public static ValueTask<UpdateInfo> CheckUpdateAsync(string username, string repository)
2423
{
@@ -58,55 +57,51 @@ public static async ValueTask<UpdateInfo> CheckUpdateAsync(string username, stri
5857
_ = response.EnsureSuccessStatusCode();
5958
if (response.StatusCode != HttpStatusCode.OK) { return null; }
6059
string responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
61-
ArtifactsInfo result = JsonSerializer.Deserialize(responseBody, SourceGenerationContext.Default.ArtifactsInfo);
60+
WorkflowRunsInfo result = JsonSerializer.Deserialize(responseBody, SourceGenerationContext.Default.WorkflowRunsInfo);
6261

6362
if (result != null)
6463
{
65-
Artifact artifact = result.Artifacts.FirstOrDefault(x => x.WorkflowRun.HeadBranch == "main");
66-
67-
if (artifact != null)
64+
WorkflowRun run = result.WorkflowRuns.FirstOrDefault(x => x is { HeadBranch: "main", Event: "push", Conclusion: "success" });
65+
if (run != null)
6866
{
69-
UpdateInfo updateInfo = new()
70-
{
71-
CreatedAt = artifact.CreatedAt,
72-
PublishedAt = artifact.UpdatedAt,
73-
Assets =
74-
[
75-
new Asset
76-
{
77-
Url = artifact.Url,
78-
Name = artifact.Name,
79-
Size = artifact.SizeInBytes,
80-
CreatedAt = artifact.CreatedAt,
81-
UpdatedAt = artifact.UpdatedAt,
82-
ExpiresAt = artifact.ExpiresAt,
83-
DownloadUrl = artifact.ArchiveDownloadUrl
84-
}
85-
]
86-
};
87-
8867
try
8968
{
90-
url = string.Format(GITHUB_RUNS_API, username, repository, artifact.WorkflowRun.ID);
91-
response = await client.GetAsync(url).ConfigureAwait(false);
69+
response = await client.GetAsync(run.ArtifactsUrl).ConfigureAwait(false);
9270
if (response.StatusCode == HttpStatusCode.OK)
9371
{
9472
responseBody = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
95-
RunInfo run = JsonSerializer.Deserialize(responseBody, SourceGenerationContext.Default.RunInfo);
96-
97-
SystemVersionInfo newVersionInfo = GetAsVersionInfo(artifact.CreatedAt, (int)run.RunNumber);
98-
updateInfo.ReleaseUrl = run.HTMLUrl;
99-
updateInfo.IsExistNewVersion = newVersionInfo > currentVersion;
100-
updateInfo.Version = newVersionInfo;
101-
updateInfo.Assets[0].DownloadUrl = $"https://github.com/{username}/{repository}/suites/{run.CheckSuiteID}/artifacts/{artifact.ID}";
73+
ArtifactsInfo artifacts = JsonSerializer.Deserialize(responseBody, SourceGenerationContext.Default.ArtifactsInfo);
74+
if (artifacts != null)
75+
{
76+
SystemVersionInfo newVersionInfo = GetAsVersionInfo(run.CreatedAt, run.RunNumber);
77+
return new UpdateInfo()
78+
{
79+
ReleaseUrl = run.HTMLUrl,
80+
CreatedAt = run.CreatedAt,
81+
PublishedAt = run.UpdatedAt,
82+
Assets =
83+
[
84+
.. artifacts.Artifacts.Select(artifact => new Asset
85+
{
86+
Url = artifact.Url,
87+
Name = artifact.Name,
88+
Size = artifact.SizeInBytes,
89+
CreatedAt = artifact.CreatedAt,
90+
UpdatedAt = artifact.UpdatedAt,
91+
ExpiresAt = artifact.ExpiresAt,
92+
DownloadUrl = $"https://github.com/{username}/{repository}/suites/{run.CheckSuiteID}/artifacts/{artifact.ID}"
93+
})
94+
],
95+
IsExistNewVersion = newVersionInfo > currentVersion,
96+
Version = newVersionInfo
97+
};
98+
}
10299
}
103100
}
104101
catch (Exception ex)
105102
{
106103
Microsoft.Extensions.Logging.LoggerExtensions.LogWarning(SettingsHelper.LoggerFactory.CreateLogger(nameof(UpdateHelper)), ex, "{message} (0x{hResult:X})", ex.Message, ex.HResult);
107104
}
108-
109-
return updateInfo;
110105
}
111106
}
112107

0 commit comments

Comments
 (0)