Skip to content

Commit 7483052

Browse files
committed
feat(下载): 改进下载页面并添加版本自动获取功能
1 parent 2f0fe3e commit 7483052

2 files changed

Lines changed: 62 additions & 28 deletions

File tree

website/src/components/Download.astro

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,36 @@ interface Props {
55
66
const { t } = Astro.props;
77
8+
const GITHUB_REPO = "codedogQBY/ReadAny";
9+
const MIRROR_BASE = "https://ghfast.top";
10+
811
const downloads = [
912
{
10-
label: t("download.mac"),
11-
sublabel: t("download.mac.arm"),
13+
label: t("download.mac.arm"),
14+
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5"><path d="M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"/></svg>`,
15+
getDownloadUrl: (version: string) =>
16+
`${MIRROR_BASE}/https://github.com/${GITHUB_REPO}/releases/download/v${version}/ReadAny_aarch64.app.tar.gz`,
17+
available: true,
18+
},
19+
{
20+
label: t("download.mac.intel"),
1221
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5"><path d="M18.71 19.5c-.83 1.24-1.71 2.45-3.05 2.47-1.34.03-1.77-.79-3.29-.79-1.53 0-2 .77-3.27.82-1.31.05-2.3-1.32-3.14-2.53C4.25 17 2.94 12.45 4.7 9.39c.87-1.52 2.43-2.48 4.12-2.51 1.28-.02 2.5.87 3.29.87.78 0 2.26-1.07 3.81-.91.65.03 2.47.26 3.64 1.98-.09.06-2.17 1.28-2.15 3.81.03 3.02 2.65 4.03 2.68 4.04-.03.07-.42 1.44-1.38 2.83M13 3.5c.73-.83 1.94-1.46 2.94-1.5.13 1.17-.34 2.35-1.04 3.19-.69.85-1.83 1.51-2.95 1.42-.15-1.15.41-2.35 1.05-3.11z"/></svg>`,
13-
href: "https://github.com/codedogQBY/ReadAny/releases/latest",
22+
getDownloadUrl: (version: string) =>
23+
`${MIRROR_BASE}/https://github.com/${GITHUB_REPO}/releases/download/v${version}/ReadAny_x64.app.tar.gz`,
1424
available: true,
1525
},
1626
{
1727
label: t("download.windows"),
1828
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5"><path d="M0 3.449L9.75 2.1v9.451H0m10.949-9.602L24 0v11.4H10.949M0 12.6h9.75v9.451L0 20.699M10.949 12.6H24V24l-12.9-1.801"/></svg>`,
19-
href: "https://github.com/codedogQBY/ReadAny/releases/latest",
29+
getDownloadUrl: (version: string) =>
30+
`${MIRROR_BASE}/https://github.com/${GITHUB_REPO}/releases/download/v${version}/ReadAny_${version}_x64-setup.exe`,
2031
available: true,
2132
},
2233
{
2334
label: t("download.linux"),
2435
icon: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-5 h-5"><path d="M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-.92 4.91 1.203 2.155 3.067 3.26 4.32 4.07.77.497 1.46.938 1.6 1.38.165.467.105 1.18-.14 1.71-.21.45-.45.76-.47.98-.04.37.12.56.38.56.26 0 .59-.19.71-.47.17-.37.21-.95.08-1.41-.16-.57-.54-.99-.92-1.39-.66-.68-1.35-1.38-1.35-2.44 0-1.01.67-1.94 1.45-2.95.78-1.02 1.63-2.16 1.86-3.58.17-1.04.04-2.04-.36-2.88-.38-.8-.97-1.38-1.51-1.93-.59-.58-1.13-1.13-1.13-1.88 0-.67.4-1.29.97-1.71.59-.43 1.34-.64 2.09-.64.75 0 1.5.21 2.09.64.57.42.97 1.04.97 1.71 0 .75-.54 1.3-1.13 1.88-.54.55-1.13 1.13-1.51 1.93-.4.84-.53 1.84-.36 2.88.23 1.42 1.08 2.56 1.86 3.58.78 1.01 1.45 1.94 1.45 2.95 0 1.06-.69 1.76-1.35 2.44-.38.4-.76.82-.92 1.39-.13.46-.09 1.04.08 1.41.12.28.45.47.71.47.26 0 .42-.19.38-.56-.02-.22-.26-.53-.47-.98-.245-.53-.305-1.243-.14-1.71.14-.442.83-.883 1.6-1.38 1.253-.81 3.117-1.915 4.32-4.07 1.207-2.16-.035-3.859-.92-4.91-.75-1.067-.974-1.928-1.05-3.02-.065-1.491 1.056-5.965-3.17-6.298a6.821 6.821 0 0 0-.48-.021z"/></svg>`,
25-
href: "https://github.com/codedogQBY/ReadAny/releases/latest",
36+
getDownloadUrl: (version: string) =>
37+
`${MIRROR_BASE}/https://github.com/${GITHUB_REPO}/releases/download/v${version}/readany_${version}_amd64.deb`,
2638
available: true,
2739
},
2840
{
@@ -38,9 +50,26 @@ const downloads = [
3850
available: false,
3951
},
4052
];
53+
54+
let latestVersion = "1.0.0";
55+
56+
try {
57+
const response = await fetch(`https://api.github.com/repos/${GITHUB_REPO}/releases/latest`, {
58+
headers: {
59+
'Accept': 'application/vnd.github.v3+json',
60+
'User-Agent': 'ReadAny-Website'
61+
}
62+
});
63+
64+
if (response.ok) {
65+
const data = await response.json();
66+
latestVersion = data.tag_name.replace('v', '');
67+
}
68+
} catch (error) {
69+
console.error('Failed to fetch latest version:', error);
70+
}
4171
---
4272

43-
<!-- Vercel-style: Clean buttons with platform icons -->
4473
<section id="download" class="py-32 border-t border-border/50">
4574
<div class="mx-auto max-w-5xl px-6">
4675
<div class="max-w-2xl">
@@ -56,21 +85,27 @@ const downloads = [
5685
</div>
5786

5887
<div class="mt-12 flex flex-wrap gap-3">
59-
{downloads.map((download) => (
60-
<a
61-
href={download.available ? download.href : '#'}
62-
target={download.available ? '_blank' : undefined}
63-
rel={download.available ? 'noopener noreferrer' : undefined}
64-
class={`inline-flex items-center gap-2.5 rounded-full border px-5 py-2.5 text-sm font-medium transition-colors ${
65-
download.available
66-
? 'border-border bg-background hover:border-foreground/30 hover:bg-muted/50 cursor-pointer'
67-
: 'border-border/30 text-muted-foreground cursor-not-allowed opacity-60'
68-
}`}
69-
>
70-
<Fragment set:html={download.icon} />
71-
{download.label}
72-
</a>
73-
))}
88+
{downloads.map((download) => {
89+
const href = download.available && download.getDownloadUrl
90+
? download.getDownloadUrl(latestVersion)
91+
: download.href || '#';
92+
93+
return (
94+
<a
95+
href={href}
96+
target={download.available ? '_blank' : undefined}
97+
rel={download.available ? 'noopener noreferrer' : undefined}
98+
class={`inline-flex items-center gap-2.5 rounded-full border px-5 py-2.5 text-sm font-medium transition-colors ${
99+
download.available
100+
? 'border-border bg-background hover:border-foreground/30 hover:bg-muted/50 cursor-pointer'
101+
: 'border-border/30 text-muted-foreground cursor-not-allowed opacity-60'
102+
}`}
103+
>
104+
<Fragment set:html={download.icon} />
105+
{download.label}
106+
</a>
107+
);
108+
})}
74109
</div>
75110

76111
<div class="mt-8">

website/src/i18n/ui.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ export const ui = {
4848
"download.title": "Download",
4949
"download.subtitle": "Get started with ReadAny on your platform",
5050
"download.mac": "macOS",
51-
"download.mac.arm": "Apple Silicon",
52-
"download.mac.intel": "Intel",
51+
"download.mac.arm": "macOS (Apple Silicon)",
52+
"download.mac.intel": "macOS (Intel)",
5353
"download.windows": "Windows",
5454
"download.linux": "Linux",
5555
"download.ios": "iOS",
@@ -178,12 +178,11 @@ export const ui = {
178178
"支持 OpenAI、Anthropic Claude、Google Gemini、Ollama、DeepSeek 等多种 AI 服务。",
179179
"features.stats.title": "阅读统计",
180180
"features.stats.desc": "追踪阅读时间、进度和习惯,提供详细的统计和可视化。",
181-
"download.title": "下载",
182-
"download.subtitle": "在你的平台上开始使用 ReadAny",
181+
"download.title": "下载 ReadAny",
182+
"download.subtitle": "支持所有平台",
183183
"download.opensource": "源代码完全开源免费,但官方应用商店版本可能会收取一定费用,用于支持持续开发和覆盖证书成本。你始终可以免费自行编译使用。",
184-
"download.mac": "macOS",
185-
"download.mac.arm": "Apple Silicon",
186-
"download.mac.intel": "Intel",
184+
"download.mac.arm": "macOS (Apple Silicon)",
185+
"download.mac.intel": "macOS (Intel)",
187186
"download.windows": "Windows",
188187
"download.linux": "Linux",
189188
"download.ios": "iOS",

0 commit comments

Comments
 (0)