Skip to content

Commit 32052ef

Browse files
committed
feat: 更新测试版判断逻辑,优化下载按钮样式
1 parent 1045ed4 commit 32052ef

2 files changed

Lines changed: 40 additions & 31 deletions

File tree

main.js

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -81,29 +81,20 @@ document.addEventListener("DOMContentLoaded", function () {
8181
return match ? match[1] : null;
8282
}
8383

84-
// 判断是否为测试版(基于发布日期分界
84+
// 判断是否为测试版(基于版本号和prerelease标志
8585
function isBetaRelease(release, isBetaRepo) {
86-
// 2025/12/1 作为分界日期
87-
const boundaryDate = new Date('2025-12-01T00:00:00Z');
88-
const releaseDate = new Date(release.published_at);
89-
90-
if (releaseDate < boundaryDate) {
91-
// 2025/12/1 之前:根据仓库判断
92-
return isBetaRepo;
93-
} else {
94-
// 2025/12/1 及之后:版本号 < 1.7.18.0 时根据仓库判断,>= 1.7.18.0 时全部为测试版
95-
const versionMatch = release.tag_name.match(/(\d+)\.(\d+)\.(\d+)\.(\d+)/);
96-
if (versionMatch) {
97-
const [, major, minor, patch, build] = versionMatch.map(Number);
98-
// 比较 1.7.18.0
99-
if (major < 1 || (major === 1 && minor < 7) || (major === 1 && minor === 7 && patch < 18)) {
100-
return isBetaRepo;
101-
} else {
102-
return true; // >= 1.7.18.0 全部为测试版
103-
}
86+
// 先检查版本号
87+
const versionMatch = release.tag_name.match(/(\d+)\.(\d+)\.(\d+)/);
88+
if (versionMatch) {
89+
const [, major, minor, patch] = versionMatch.map(Number);
90+
// 版本 >= 1.7.18.0:根据 prerelease 标志判断
91+
if ((major > 1) || (major === 1 && minor > 7) || (major === 1 && minor === 7 && patch >= 18)) {
92+
return release.prerelease; // prerelease = true 为测试版,false 为正式版
10493
}
105-
return isBetaRepo;
10694
}
95+
96+
// 版本 < 1.7.18.0:根据仓库判断
97+
return isBetaRepo;
10798
}
10899

109100
// 测试智教下载源的可用性
@@ -245,6 +236,11 @@ document.addEventListener("DOMContentLoaded", function () {
245236
.map(a => {
246237
// 提取原始下载URL的版本号,如果失败则使用 tag_name
247238
const version = extractVersionFromUrl(a.browser_download_url) || r.tag_name;
239+
// 判断是安装版还是绿色版
240+
const isInstaller = a.browser_download_url.endsWith('.exe');
241+
const editionType = isInstaller ? '安装版' : '绿色版';
242+
// 格式化显示名称
243+
const displayName = `${version} ${editionType}`;
248244
const downloadUrl = convertDownloadUrl(a.browser_download_url, r._isBeta);
249245
return `
250246
<button data-download-url="${downloadUrl}"
@@ -253,7 +249,7 @@ document.addEventListener("DOMContentLoaded", function () {
253249
data-is-beta="${r._isBeta}"
254250
class="btn btn--tonal download-btn">
255251
<span class="material-symbols-outlined">download</span>
256-
<span>${a.name} (${(a.size / 1024 / 1024).toFixed(2)} MB)</span>
252+
<span>${displayName} (${(a.size / 1024 / 1024).toFixed(2)} MB)</span>
257253
</button>
258254
`;
259255
}).join('') || `<p class="typescale-body-medium card-subtitle">无可用附件</p>`;
@@ -379,17 +375,24 @@ document.addEventListener("DOMContentLoaded", function () {
379375
let effectiveUrl = originalUrl;
380376

381377
// 对于 .zip 文件,如果智教可用,先检查文件是否存在
382-
if (originalUrl.endsWith('.zip') && smartTeachAvailable) {
383-
const exists = await checkSmartTeachFileExists(originalUrl, isBeta);
384-
if (exists) {
385-
effectiveUrl = downloadUrl;
378+
if (originalUrl.endsWith('.zip')) {
379+
if (smartTeachAvailable) {
380+
const exists = await checkSmartTeachFileExists(originalUrl, isBeta);
381+
if (exists) {
382+
effectiveUrl = downloadUrl;
383+
} else if (fastestMirror) {
384+
// 文件不存在,使用最快镜像
385+
effectiveUrl = originalUrl.replace("https://github.com/", `${fastestMirror}/https://github.com/`);
386+
}
386387
} else if (fastestMirror) {
387-
// 文件不存在,使用最快镜像
388+
// 智教不可用,使用最快镜像
389+
effectiveUrl = originalUrl.replace("https://github.com/", `${fastestMirror}/https://github.com/`);
390+
}
391+
} else if (originalUrl.endsWith('.exe')) {
392+
// .exe 文件优先使用最快镜像
393+
if (fastestMirror) {
388394
effectiveUrl = originalUrl.replace("https://github.com/", `${fastestMirror}/https://github.com/`);
389395
}
390-
} else if (originalUrl.endsWith('.exe') && fastestMirror) {
391-
// .exe 文件使用最快镜像
392-
effectiveUrl = originalUrl.replace("https://github.com/", `${fastestMirror}/https://github.com/`);
393396
}
394397

395398
showDownloadModal(effectiveUrl, version);
@@ -512,13 +515,14 @@ document.addEventListener("DOMContentLoaded", function () {
512515
const releaseUrls = buildApiUrls(`${GITHUB_REPO_COMMUNITY}/releases`);
513516
releasesOfficial = await fetchDataWithMirrors(releaseUrls, "正式版本获取失败") || [];
514517

515-
// 为发行版设置 _isBeta 标志(基于发布日期分界)
518+
// 为发行版设置 _isBeta 标志
516519
const processedReleases = releasesOfficial.map(r => ({
517520
...r,
518521
_isBeta: isBetaRelease(r, false)
519522
}));
520523

521-
currentReleases = processedReleases;
524+
// 初始化时只显示非测试版的发行版
525+
currentReleases = processedReleases.filter(r => !r._isBeta);
522526
currentIndex = 0;
523527

524528
elements.releaseLoading.style.display = 'none';

style.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,11 @@ img {
497497
flex-wrap: wrap;
498498
}
499499

500+
.release-item-actions .download-btn {
501+
flex: 1;
502+
min-width: 200px;
503+
}
504+
500505
/* Features Section */
501506
.feature-card {
502507
display: flex;

0 commit comments

Comments
 (0)