|
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_arm64"; |
14 |
| -} |
15 |
| -
|
16 |
| -console.log(plat.value); |
17 |
| -
|
18 |
| -const res = await fetch( |
19 |
| - `https://ad-api.nn.ci/v0/app/latest` |
20 |
| -); |
21 |
| -const data = await res.json(); |
22 |
| -const version = data.version as string; |
23 |
| -
|
24 |
| -let text = { |
25 |
| - down: "Download", |
26 |
| - website: "Website", |
27 |
| -}; |
| 6 | +const proxy = "https://mirror.ghproxy.com/" |
| 7 | +const res = await fetch(`https://ad-api.nn.ci/v0/app/latest`) |
| 8 | +const data = await res.json() |
| 9 | +const version = data.version as string |
28 | 10 |
|
29 | 11 | const raw = [
|
30 |
| - { |
31 |
| - key: "win", |
32 |
| - label: "Windows", |
33 |
| - url: `https://mirror.ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_x64_en-US.msi`, |
34 |
| - }, |
35 | 12 | {
|
36 | 13 | key: "mac_arm64",
|
37 | 14 | label: "MacOS (Apple Silicon)",
|
38 |
| - url: `https://mirror.ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_aarch64.dmg`, |
| 15 | + url: `https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_aarch64.dmg`, |
39 | 16 | },
|
40 | 17 | {
|
41 | 18 | key: "mac_x64",
|
42 | 19 | label: "MacOS (Intel)",
|
43 |
| - url: `https://mirror.ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_x64.dmg`, |
| 20 | + url: `https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_x64.dmg`, |
| 21 | + }, |
| 22 | + { |
| 23 | + key: "win_x64", |
| 24 | + label: "Windows (X64)", |
| 25 | + url: `https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_x64_en-US.msi`, |
| 26 | + }, |
| 27 | + { |
| 28 | + key: "win_arm64", |
| 29 | + label: "Windows (ARM64)", |
| 30 | + url: `https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_arm64-setup.exe`, |
44 | 31 | },
|
45 | 32 | {
|
46 | 33 | key: "linux",
|
47 | 34 | label: "Linux",
|
48 |
| - url: `https://mirror.ghproxy.com/https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_${version}_amd64.deb`, |
| 35 | + url: `https://github.com/alist-org/desktop-release/releases/latest/download/alist-desktop_$version_amd64.deb`, |
49 | 36 | },
|
50 |
| -]; |
| 37 | +] as const |
| 38 | +
|
| 39 | +type Plat = (typeof raw)[number]["key"] |
| 40 | +
|
| 41 | +const platform = navigator.platform.toLowerCase() |
| 42 | +const plat = ref<Plat>("win_x64") |
| 43 | +if (platform.includes("win")) { |
| 44 | + plat.value = "win_x64" |
| 45 | +} else if (platform.includes("linux")) { |
| 46 | + plat.value = "linux" |
| 47 | +} else if (platform.includes("mac")) { |
| 48 | + plat.value = "mac_arm64" |
| 49 | +} |
| 50 | +
|
| 51 | +console.log(plat.value) |
| 52 | +
|
| 53 | +let text = { |
| 54 | + down: "Download", |
| 55 | + website: "Website", |
| 56 | +} |
51 | 57 |
|
52 | 58 | const fullPlat = computed(() => {
|
53 |
| - return raw.find((item) => item.key === plat.value)?.label; |
54 |
| -}); |
| 59 | + return raw.find((item) => item.key === plat.value)?.label |
| 60 | +}) |
55 | 61 |
|
56 | 62 | const options = computed(() => {
|
57 | 63 | return raw.map((item) => {
|
58 | 64 | return {
|
59 | 65 | ...item,
|
60 | 66 | label: `${item.label} ${plat.value === item.key ? "✅" : ""}`,
|
61 |
| - }; |
62 |
| - }); |
63 |
| -}); |
| 67 | + } |
| 68 | + }) |
| 69 | +}) |
64 | 70 |
|
65 | 71 | if (location.pathname.startsWith("/zh/")) {
|
66 | 72 | text = {
|
67 | 73 | down: "下载",
|
68 | 74 | website: "官网",
|
69 |
| - }; |
| 75 | + } |
70 | 76 | }
|
71 | 77 |
|
72 | 78 | function down() {
|
73 |
| - window.open(raw.find((item) => item.key === plat.value)?.url, "_blank"); |
| 79 | + const href = raw.find((item) => item.key === plat.value)?.url |
| 80 | + window.open(`${proxy}${href}`, "_blank") |
74 | 81 | }
|
75 | 82 |
|
76 | 83 | function handleSelect(key) {
|
77 |
| - plat.value = key; |
| 84 | + plat.value = key |
78 | 85 | }
|
79 | 86 |
|
80 | 87 | function openWebsite() {
|
81 |
| - window.open("https://ad.nn.ci/", "_blank"); |
| 88 | + window.open("https://ad.nn.ci/", "_blank") |
82 | 89 | }
|
83 | 90 | </script>
|
84 | 91 |
|
|
0 commit comments