1
1
<script setup lang="ts">
2
- import { NButtonGroup , NImage , NSpace , NButton , NDropdown } from ' naive-ui' ;
3
- import { computed , ref } from ' vue' ;
4
- import { api } from ' ./api'
2
+ import { NButtonGroup , NImage , NSpace , NButton , NDropdown } from " naive-ui" ;
3
+ import { computed , ref } from " vue" ;
4
+ import { api } from " ./api" ;
5
5
6
- const platform = navigator .platform .toLowerCase ()
7
- const plat = ref <" win" | ' linux' | ' mac' >( ' win' )
8
- if (platform .includes (' win' )) {
9
- plat .value = ' win'
10
- } else if (platform .includes (' linux' )) {
11
- plat .value = ' linux'
12
- } else if (platform .includes (' mac' )) {
13
- plat .value = ' mac'
6
+ const platform = navigator .platform .toLowerCase ();
7
+ const plat = ref <" win" | " linux" | " mac" >( " win" );
8
+ if (platform .includes (" win" )) {
9
+ plat .value = " win" ;
10
+ } else if (platform .includes (" linux" )) {
11
+ plat .value = " linux" ;
12
+ } else if (platform .includes (" mac" )) {
13
+ plat .value = " mac" ;
14
14
}
15
15
16
- console .log (plat .value )
16
+ console .log (plat .value );
17
17
18
- const res = await fetch (` ${api ()}/proxy/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop-proxy.json ` )
19
- const data = await res .json ()
20
- const version = (data .name as string ).slice (1 )
21
- const urls = {
22
- ' win' : ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_x64_en-US.msi ` ,
23
- ' linux' : ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_amd64.deb ` ,
24
- ' mac' : ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_x64.dmg `
25
- }
18
+ const res = await fetch (
19
+ ` ${api ()}/proxy/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop-proxy.json `
20
+ );
21
+ const data = await res .json ();
22
+ const version = (data .name as string ).slice (1 );
26
23
27
24
let text = {
28
- down: " Download"
29
- }
25
+ down: " Download" ,
26
+ };
30
27
31
28
const raw = [
32
- { key: ' win' , label: ' Windows' },
33
- { key: ' linux' , label: ' Linux' },
34
- { key: ' mac' , label: ' MacOS' }
35
- ]
29
+ {
30
+ key: " win" ,
31
+ label: " Windows" ,
32
+ url: ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_x64_en-US.msi ` ,
33
+ },
34
+ {
35
+ key: " mac_arm64" ,
36
+ label: " MacOS (Apple Silicon)" ,
37
+ url: ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_aarch64.dmg ` ,
38
+ },
39
+ {
40
+ key: " mac_x64" ,
41
+ label: " MacOS (Intel)" ,
42
+ url: ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_x64.dmg ` ,
43
+ },
44
+ {
45
+ key: " linux" ,
46
+ label: " Linux" ,
47
+ url: ` https://ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version }_amd64.deb ` ,
48
+ },
49
+ ];
36
50
37
51
const fullPlat = computed (() => {
38
- return raw .find (item => item .key === plat .value )?.label
39
- })
52
+ return raw .find (( item ) => item .key === plat .value )?.label ;
53
+ });
40
54
41
55
const options = computed (() => {
42
- return raw .map (item => {
56
+ return raw .map (( item ) => {
43
57
return {
44
58
... item ,
45
- label: ` ${item .label } ${plat .value === item .key ? ' ✅ ' : ' ' } `
46
- }
47
- })
48
- })
59
+ label: ` ${item .label } ${plat .value === item .key ? " ✅ " : " " } ` ,
60
+ };
61
+ });
62
+ });
49
63
50
64
if (location .pathname .startsWith (" /zh/" )) {
51
65
text = {
52
- down: " 下载"
53
- }
66
+ down: " 下载" ,
67
+ };
54
68
}
55
69
56
70
function down() {
57
- window .open (urls [ plat .value ] , " _blank" )
71
+ window .open (raw . find (( item ) => item . key === plat .value )?. url , " _blank" );
58
72
}
59
73
60
74
function handleSelect(key ) {
61
- plat .value = key
75
+ plat .value = key ;
62
76
}
63
-
64
77
</script >
65
78
66
79
<template >
67
80
<NSpace align =" center" vertical size =" large" >
68
81
<NButtonGroup class =" down" >
69
- <NDropdown trigger =" hover" :options =" options" @select =" handleSelect" size =" large" >
82
+ <NDropdown
83
+ trigger =" hover"
84
+ :options =" options"
85
+ @select =" handleSelect"
86
+ size =" large"
87
+ >
70
88
<NButton size =" large" type =" primary" tertiary >💻{{ fullPlat }}</NButton >
71
89
</NDropdown >
72
- <NButton size =" large" @click =" down" type =" info" secondary >{{ text.down }}</NButton >
90
+ <NButton size =" large" @click =" down" type =" info" secondary >{{
91
+ text.down
92
+ }}</NButton >
73
93
</NButtonGroup >
74
94
<NImage src =" /img/guide/desktop.png" ></NImage >
75
95
</NSpace >
@@ -81,4 +101,4 @@ function handleSelect(key) {
81
101
margin-top : 30px ;
82
102
margin-bottom : 30px ;
83
103
}
84
- </style >
104
+ </style >
0 commit comments