|
1 | 1 | 'use client' |
2 | 2 |
|
| 3 | +import { formatVersion, type GitHubRelease } from '@/lib/github'; |
3 | 4 | import { cn } from "@/lib/utils"; |
4 | | -import { DownloadIcon } from "lucide-react"; |
5 | | -import CodeBlock from "../code-block"; |
6 | | -import Note from "../common/note"; |
| 5 | +import { DownloadIcon, ExternalLinkIcon } from "lucide-react"; |
7 | 6 | import PlatformHeader from "../common/platform-header"; |
8 | 7 | import { type PlatformInfoData } from "./platform-info"; |
9 | | -import { getDownloadUrlForPlatform, type GitHubRelease } from '@/lib/github'; |
10 | 8 |
|
11 | 9 | interface WindowsDownloadSectionProps { |
12 | 10 | platform: PlatformInfoData; |
13 | 11 | release: GitHubRelease | null; |
| 12 | + launcherRelease: GitHubRelease | null; |
14 | 13 | className?: string; |
15 | 14 | } |
16 | 15 |
|
17 | | -export default function WindowsDownloadSection({ platform, release, className }: WindowsDownloadSectionProps) { |
18 | | - // Get download URL from release assets or use fallback |
19 | | - const downloadUrl = release |
20 | | - ? getDownloadUrlForPlatform(release, 'windows', 'x86_64') |
21 | | - : null; |
22 | | - |
23 | | - const fallbackUrl = release?.html_url || 'https://github.com/rustfs/rustfs/releases/latest'; |
24 | | - const finalDownloadUrl = downloadUrl || fallbackUrl; |
25 | | - |
26 | | - // Extract filename from URL for code block |
27 | | - const getFilenameFromUrl = (url: string) => { |
28 | | - if (url.includes('github.com')) { |
29 | | - return 'rustfs.exe'; |
30 | | - } |
31 | | - const match = url.match(/([^\/]+\.exe)/); |
32 | | - return match ? match[1] : 'rustfs.exe'; |
33 | | - }; |
| 16 | +export default function WindowsDownloadSection({ platform, launcherRelease, className }: WindowsDownloadSectionProps) { |
| 17 | + const releaseUrl = launcherRelease?.html_url || 'https://github.com/rustfs/launcher/releases/latest'; |
| 18 | + const version = launcherRelease ? formatVersion(launcherRelease.tag_name) : 'latest'; |
| 19 | + const versionTag = launcherRelease?.tag_name || 'latest'; |
| 20 | + const versionWithoutV = versionTag.startsWith('v') ? versionTag.slice(1) : versionTag; |
| 21 | + const versionWithV = versionTag.startsWith('v') ? versionTag : `v${versionTag}`; |
| 22 | + const installerFilename = `rustfs-launcher-windows-x86_64-v${versionWithoutV}-setup.exe`; |
| 23 | + const directDownloadUrl = launcherRelease |
| 24 | + ? `https://dl.rustfs.com/artifacts/rustfs-launcher/release/rustfs-launcher-windows-x86_64-${versionWithV}-setup.exe` |
| 25 | + : 'https://dl.rustfs.com/artifacts/rustfs-launcher/release/rustfs-launcher-windows-x86_64-latest-setup.exe'; |
34 | 26 |
|
35 | 27 | return ( |
36 | 28 | <div className={cn("space-y-8", className)}> |
37 | 29 | {/* Platform Header */} |
38 | 30 | <PlatformHeader platform={platform} /> |
39 | 31 |
|
40 | | - {/* Binary Downloads */} |
| 32 | + {/* Installer Download */} |
41 | 33 | <div className="space-y-6"> |
42 | | - <h3 className="text-lg font-semibold text-foreground">{'Binary Downloads'}</h3> |
| 34 | + <h3 className="text-lg font-semibold text-foreground">{'Download from GitHub'}</h3> |
43 | 35 |
|
44 | | - {/* x86_64 Variant */} |
45 | 36 | <div className="space-y-4"> |
46 | | - <div className="flex items-center justify-between"> |
47 | | - <div> |
48 | | - <h4 className="font-medium text-foreground">x86_64</h4> |
49 | | - <p className="text-sm text-muted-foreground"> |
50 | | - {'Architecture'}: x86_64 |
51 | | - </p> |
| 37 | + <div className="p-6 bg-card rounded-lg border border-border"> |
| 38 | + <div className="space-y-4"> |
| 39 | + <div> |
| 40 | + <h4 className="font-medium text-foreground mb-2">{'Latest Version'}</h4> |
| 41 | + <p className="text-sm text-muted-foreground mb-4"> |
| 42 | + {launcherRelease ? `Current latest version: ${version}` : 'Fetching latest version information...'} |
| 43 | + </p> |
| 44 | + </div> |
| 45 | + |
| 46 | + <div className="space-y-3"> |
| 47 | + <div> |
| 48 | + <p className="text-sm font-medium text-foreground mb-2">{'Download Steps:'}</p> |
| 49 | + <ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground"> |
| 50 | + <li> |
| 51 | + {'Visit '} |
| 52 | + <a |
| 53 | + href={releaseUrl} |
| 54 | + target="_blank" |
| 55 | + rel="noopener noreferrer" |
| 56 | + className="inline-flex items-center space-x-1 text-primary hover:underline" |
| 57 | + > |
| 58 | + <span>{'GitHub Release page'}</span> |
| 59 | + <ExternalLinkIcon className="w-3 h-3" /> |
| 60 | + </a> |
| 61 | + </li> |
| 62 | + <li> |
| 63 | + {'Find and download '} |
| 64 | + <code className="px-1.5 py-0.5 bg-muted rounded text-xs font-mono text-foreground"> |
| 65 | + {installerFilename} |
| 66 | + </code> |
| 67 | + {' from the Assets section'} |
| 68 | + </li> |
| 69 | + <li>{'After downloading, double-click the installer to complete the installation'}</li> |
| 70 | + </ol> |
| 71 | + </div> |
| 72 | + |
| 73 | + <div className="pt-2"> |
| 74 | + <a |
| 75 | + href={releaseUrl} |
| 76 | + target="_blank" |
| 77 | + rel="noopener noreferrer" |
| 78 | + className="inline-flex items-center space-x-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors" |
| 79 | + > |
| 80 | + <span>{'Go to Release Page'}</span> |
| 81 | + <ExternalLinkIcon className="w-4 h-4" /> |
| 82 | + </a> |
| 83 | + </div> |
| 84 | + </div> |
52 | 85 | </div> |
53 | | - <a |
54 | | - href={finalDownloadUrl} |
55 | | - target="_blank" |
56 | | - rel="noopener noreferrer" |
57 | | - className="inline-flex items-center space-x-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors"> |
58 | | - <DownloadIcon className="w-4 h-4" /> |
59 | | - <span>{'Download'}</span> |
60 | | - </a> |
61 | 86 | </div> |
62 | 87 |
|
63 | | - <CodeBlock |
64 | | - code={[ |
65 | | - "# Download RustFS for Windows", |
66 | | - "# Option 1: Download from GitHub Releases", |
67 | | - `# Visit: ${fallbackUrl}`, |
68 | | - "", |
69 | | - "# Option 2: Using PowerShell", |
70 | | - downloadUrl |
71 | | - ? `Invoke-WebRequest -Uri "${downloadUrl}" -OutFile "${getFilenameFromUrl(downloadUrl)}"` |
72 | | - : "# Download from GitHub Releases page", |
73 | | - "", |
74 | | - "# Run RustFS", |
75 | | - ".\\rustfs.exe --version", |
76 | | - ]} |
77 | | - title={'Installation Commands'} |
78 | | - /> |
| 88 | + <div className="p-4 bg-muted/50 rounded-lg border border-border"> |
| 89 | + <p className="text-sm text-muted-foreground"> |
| 90 | + <strong className="text-foreground">{'Tip: '}</strong> |
| 91 | + {'The Launcher installer includes the RustFS binary. After installation, you can use it immediately.'} |
| 92 | + </p> |
| 93 | + </div> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + |
| 97 | + {/* Direct Download */} |
| 98 | + <div className="space-y-6"> |
| 99 | + <h3 className="text-lg font-semibold text-foreground">{'Download from Download Site'}</h3> |
| 100 | + |
| 101 | + <div className="space-y-4"> |
| 102 | + <div className="p-6 bg-card rounded-lg border border-border"> |
| 103 | + <div className="space-y-4"> |
| 104 | + <div> |
| 105 | + <h4 className="font-medium text-foreground mb-2">{'Latest Version'}</h4> |
| 106 | + <p className="text-sm text-muted-foreground mb-4"> |
| 107 | + {launcherRelease ? `Current latest version: ${version}` : 'Fetching latest version information...'} |
| 108 | + </p> |
| 109 | + </div> |
| 110 | + |
| 111 | + <div className="space-y-3"> |
| 112 | + <div> |
| 113 | + <p className="text-sm font-medium text-foreground mb-2">{'Download Steps:'}</p> |
| 114 | + <ol className="list-decimal list-inside space-y-2 text-sm text-muted-foreground"> |
| 115 | + <li>{'Click the download button or link below to download the installer'}</li> |
| 116 | + <li>{'After downloading, double-click the installer to complete the installation'}</li> |
| 117 | + </ol> |
| 118 | + </div> |
| 119 | + |
| 120 | + <div className="pt-2"> |
| 121 | + <a |
| 122 | + href={directDownloadUrl} |
| 123 | + target="_blank" |
| 124 | + rel="noopener noreferrer" |
| 125 | + className="inline-flex items-center space-x-2 px-4 py-2 bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 transition-colors" |
| 126 | + > |
| 127 | + <DownloadIcon className="w-4 h-4" /> |
| 128 | + <span>{'Download Windows x86_64 Installer'}</span> |
| 129 | + </a> |
| 130 | + </div> |
| 131 | + |
| 132 | + <div className="pt-2"> |
| 133 | + <p className="text-xs text-muted-foreground"> |
| 134 | + {'Download link: '} |
| 135 | + <a |
| 136 | + href={directDownloadUrl} |
| 137 | + target="_blank" |
| 138 | + rel="noopener noreferrer" |
| 139 | + className="ml-1 text-primary hover:underline break-all" |
| 140 | + > |
| 141 | + {directDownloadUrl} |
| 142 | + </a> |
| 143 | + </p> |
| 144 | + </div> |
| 145 | + </div> |
| 146 | + </div> |
| 147 | + </div> |
79 | 148 |
|
80 | | - <div className="space-y-2"> |
81 | | - <Note type="tip"> |
82 | | - {'Default credentials: rustfsadmin / rustfsadmin'} |
83 | | - </Note> |
84 | | - <Note type="info"> |
85 | | - {'Windows 10/11 x64 compatible'} |
86 | | - </Note> |
| 149 | + <div className="p-4 bg-muted/50 rounded-lg border border-border"> |
| 150 | + <p className="text-sm text-muted-foreground"> |
| 151 | + <strong className="text-foreground">{'Tip: '}</strong> |
| 152 | + {'The Launcher installer includes the RustFS binary. After installation, you can use it immediately.'} |
| 153 | + </p> |
87 | 154 | </div> |
88 | 155 | </div> |
89 | 156 | </div> |
|
0 commit comments