From cf17576e1c1a7a94e166b2c11164152244054097 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Thu, 19 Jun 2025 15:40:54 +0700 Subject: [PATCH] fix: download link (#5365) --- docs/src/components/Download/CardDownload.tsx | 32 +++---------------- .../src/components/DropdownDownload/index.tsx | 29 ++++------------- 2 files changed, 11 insertions(+), 50 deletions(-) diff --git a/docs/src/components/Download/CardDownload.tsx b/docs/src/components/Download/CardDownload.tsx index 82d8f6c8b..a42c1d537 100644 --- a/docs/src/components/Download/CardDownload.tsx +++ b/docs/src/components/Download/CardDownload.tsx @@ -23,26 +23,25 @@ const systemsTemplate: SystemType[] = [ name: 'Mac ', label: 'Universal', logo: FaApple, - fileFormat: '{appname}-mac-universal-{tag}.dmg', + fileFormat: 'Jan_{tag}_universal.dmg', }, - { name: 'Windows', label: 'Standard (64-bit)', logo: FaWindows, - fileFormat: '{appname}-win-x64-{tag}.exe', + fileFormat: 'Jan_{tag}_x64-setup.exe', }, { name: 'Linux (AppImage)', label: 'AppImage', logo: FaLinux, - fileFormat: '{appname}-linux-x86_64-{tag}.AppImage', + fileFormat: 'Jan_{tag}_amd64.AppImage', }, { name: 'Linux (deb)', label: 'Deb', logo: FaLinux, - fileFormat: '{appname}-linux-amd64-{tag}.deb', + fileFormat: 'Jan_{tag}_amd64.deb', }, ] @@ -55,37 +54,16 @@ const groupTemnplate = [ export default function CardDownload({ lastRelease }: Props) { const [systems, setSystems] = useState(systemsTemplate) - const extractAppName = (fileName: string) => { - const regex = /^(.*?)-(?:mac|win|linux)-(?:arm64|x64|amd64|x86_64)-.*$/ - const match = fileName.match(regex) - return match ? match[1] : null - } - useEffect(() => { const updateDownloadLinks = async () => { try { - // Extract appname from the first asset name - const firstAssetName = lastRelease.assets[0].name - const appname = extractAppName(firstAssetName) - - if (!appname) { - console.error( - 'Failed to extract appname from file name:', - firstAssetName - ) - - return - } - // Remove 'v' at the start of the tag_name const tag = lastRelease.tag_name.startsWith('v') ? lastRelease.tag_name.substring(1) : lastRelease.tag_name const updatedSystems = systems.map((system) => { - const downloadUrl = system.fileFormat - .replace('{appname}', appname) - .replace('{tag}', tag) + const downloadUrl = system.fileFormat.replace('{tag}', tag) // Find the corresponding asset to get the file size const asset = lastRelease.assets.find( diff --git a/docs/src/components/DropdownDownload/index.tsx b/docs/src/components/DropdownDownload/index.tsx index 40b9220a0..d9c7851cd 100644 --- a/docs/src/components/DropdownDownload/index.tsx +++ b/docs/src/components/DropdownDownload/index.tsx @@ -28,31 +28,25 @@ const systemsTemplate: SystemType[] = [ { name: 'Download for Mac', logo: FaApple, - fileFormat: '{appname}-mac-universal-{tag}.dmg', + fileFormat: 'Jan_{tag}_universal.dmg', }, { name: 'Download for Windows', logo: FaWindows, - fileFormat: '{appname}-win-x64-{tag}.exe', + fileFormat: 'Jan_{tag}_x64-setup.exe', }, { name: 'Download for Linux (AppImage)', logo: FaLinux, - fileFormat: '{appname}-linux-x86_64-{tag}.AppImage', + fileFormat: 'Jan_{tag}_amd64.AppImage', }, { name: 'Download for Linux (deb)', logo: FaLinux, - fileFormat: '{appname}-linux-amd64-{tag}.deb', + fileFormat: 'Jan_{tag}_amd64.deb', }, ] -const extractAppName = (fileName: string) => { - const regex = /^(.*?)-(?:mac|win|linux)-(?:arm64|x64|x86_64|amd64)-.*$/ - const match = fileName.match(regex) - return match ? match[1] : null -} - const DropdownDownload = ({ lastRelease }: Props) => { const [systems, setSystems] = useState(systemsTemplate) const [defaultSystem, setDefaultSystem] = useState(systems[0]) @@ -131,25 +125,14 @@ const DropdownDownload = ({ lastRelease }: Props) => { useEffect(() => { const updateDownloadLinks = async () => { try { - const firstAssetName = await lastRelease.assets[0]?.name + console.log(lastRelease) - const appname = extractAppName(firstAssetName) - if (!appname) { - console.error( - 'Failed to extract appname from file name:', - firstAssetName - ) - changeDefaultSystem(systems) - return - } const tag = lastRelease.tag_name.startsWith('v') ? lastRelease.tag_name.substring(1) : lastRelease.tag_name const updatedSystems = systems.map((system) => { - const downloadUrl = system.fileFormat - .replace('{appname}', appname) - .replace('{tag}', tag) + const downloadUrl = system.fileFormat.replace('{tag}', tag) // Find the corresponding asset to get the file size const asset = lastRelease.assets.find(