Skip to content

Commit 908f4a5

Browse files
committed
feat: download based arch
Signed-off-by: seven <[email protected]>
1 parent 96d04d5 commit 908f4a5

File tree

2 files changed

+18
-25
lines changed

2 files changed

+18
-25
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

docs/.vitepress/theme/components/download.vue

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script setup>
2-
const platform = {
3-
MacIntel: 'x64.dmg',
4-
Win32: 'Setup.exe',
5-
'Linux x86_64': '_amd64.deb',
6-
'Linux armv81': '_arm64.deb'
2+
const platforms = {
3+
'macos_x86': 'x64.dmg',
4+
'macos_arm': 'arm64.dmg',
5+
'windows_x86': 'Setup.exe',
6+
'linux_x86': '_amd64.deb',
7+
'linux_arm': '_arm64.deb'
78
};
89
const getLatestLinks = async () => {
910
const data = await fetch('https://api.github.com/repos/geek-fun/dockit/releases/latest')
@@ -16,11 +17,18 @@ const getLatestLinks = async () => {
1617
}
1718
1819
const downloadFn = async (event) => {
19-
// const links = await getLatestLinks();
20-
// const link = links.find((item) => item.name.includes(platform[window.navigator.platform]));
21-
// console.log('downloadFn', fetch(link.url))
22-
console.log('downloadFn',await navigator.userAgentData.getHighEntropyValues(['architecture']))
23-
console.log('downloadFnJson',{ nv: JSON.stringify(window.navigator)})
20+
const {architecture, platform} = await navigator.userAgentData.getHighEntropyValues(['architecture']);
21+
const links = await getLatestLinks();
22+
const link = links.find((item) => item.name.endsWith(platforms[`${platform}_${architecture}`.toLowerCase()]));
23+
if (link) {
24+
window.open(link.url, '_blank').focus();
25+
}else {
26+
console.error('downloadFn', 'no link found')
27+
}
28+
console.log('downloadFn', {
29+
links,
30+
entropyValues:{architecture, platform}
31+
})
2432
}
2533
</script>
2634
<template>

0 commit comments

Comments
 (0)