mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
fix(website/download): fix URLs for download
This commit is contained in:
parent
7066fc3092
commit
cef832fda4
@ -9,7 +9,7 @@ export type Platform = 'macos' | 'windows' | 'linux';
|
|||||||
let version = rootPackageJson.version;
|
let version = rootPackageJson.version;
|
||||||
|
|
||||||
export function buildDesktopDownloadUrl(platform: Platform, format: string, architecture: Architecture): string {
|
export function buildDesktopDownloadUrl(platform: Platform, format: string, architecture: Architecture): string {
|
||||||
return `https://github.com/TriliumNext/Notes/releases/download/${version}/TriliumNextNotes-${version}-${platform}-${architecture}.${format}`;
|
return `https://github.com/TriliumNext/Notes/releases/download/v${version}/TriliumNextNotes-v${version}-${platform}-${architecture}.${format}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DownloadInfo {
|
export interface DownloadInfo {
|
||||||
@ -145,28 +145,18 @@ function getPlatform(): Platform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDownloadLink(platform: Platform, architecture: Architecture) {
|
|
||||||
const baseUrl = 'https://example.com/downloads';
|
|
||||||
let url;
|
|
||||||
if (platform === 'mac') {
|
|
||||||
url = `${baseUrl}/mac-${architecture}.dmg`;
|
|
||||||
} else if (platform === 'windows') {
|
|
||||||
url = `${baseUrl}/windows-${architecture}.exe`;
|
|
||||||
} else if (platform === 'linux') {
|
|
||||||
url = `${baseUrl}/linux-${architecture}.tar.gz`;
|
|
||||||
} else {
|
|
||||||
url = `${baseUrl}/other-${architecture}.zip`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
url: url,
|
|
||||||
platform: platform,
|
|
||||||
architecture: architecture
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getRecommendedDownload() {
|
export function getRecommendedDownload() {
|
||||||
const architecture = getArchitecture();
|
const architecture = getArchitecture();
|
||||||
const platform = getPlatform();
|
const platform = getPlatform();
|
||||||
return getDownloadLink(platform, architecture);
|
|
||||||
|
const downloadInfo = downloadMatrix.desktop[platform]?.downloads;
|
||||||
|
const recommendedDownload = Object.entries(downloadInfo || {}).find(d => d[1].recommended);
|
||||||
|
const format = recommendedDownload?.[0];
|
||||||
|
const url = buildDesktopDownloadUrl(platform, format || 'zip', architecture);
|
||||||
|
|
||||||
|
return {
|
||||||
|
architecture,
|
||||||
|
platform,
|
||||||
|
url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
<script>
|
<script>
|
||||||
import { getRecommendedDownload } from "$lib/download-helper";
|
import { getRecommendedDownload } from "$lib/download-helper";
|
||||||
|
|
||||||
let recommendedDownload = getRecommendedDownload();
|
const { url, platform, architecture } = getRecommendedDownload();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if recommendedDownload}
|
{#if url}
|
||||||
<a href="#" class="py-2 px-5 bg-violet-600 text-white font-semibold rounded-full shadow-md hover:bg-violet-700 focus:outline-none focus:ring focus:ring-violet-400 focus:ring-opacity-75">
|
<a href="{url}" class="py-2 px-5 bg-violet-600 text-white font-semibold rounded-full shadow-md hover:bg-violet-700 focus:outline-none focus:ring focus:ring-violet-400 focus:ring-opacity-75">
|
||||||
Download now
|
Download now
|
||||||
<span class="text-sm text-gray-300">
|
<span class="text-sm text-gray-300">
|
||||||
({recommendedDownload.platform} {recommendedDownload.architecture})
|
({platform} {architecture})
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
Loading…
x
Reference in New Issue
Block a user