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};
89const 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
1819const 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