Skip to content

Commit 4956451

Browse files
committed
fix download url
1 parent 1e477b5 commit 4956451

File tree

9 files changed

+483
-6
lines changed

9 files changed

+483
-6
lines changed

docs/.vuepress/components/Desktop.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const proxy = "https://ghfast.top/"
77
let version: string | undefined
88
99
try {
10-
const res = await fetch(`https://ad-api.nn.ci/v0/app/latest`)
10+
const res = await fetch(`https://dapi.alistgo.com/v0/version/latest`)
1111
if (res.ok) {
1212
const data = await res.json()
1313
version = data.version as string
@@ -21,27 +21,27 @@ const raw = [
2121
{
2222
key: "mac_arm64",
2323
label: "MacOS (Apple Silicon)",
24-
url: `https://alistgo.com/download/Alist/alist-desktop_aarch64.dmg`,
24+
url: `https://alistgo.com/download/Alist/desktop-v${version}/alist-desktop_${version}_aarch64.dmg`,
2525
},
2626
{
2727
key: "mac_x64",
2828
label: "MacOS (Intel)",
29-
url: `https://alistgo.com/download/Alist/alist-desktop_x64.dmg`,
29+
url: `https://alistgo.com/download/Alist/desktop-v${version}/alist-desktop_${version}_x64.dmg`,
3030
},
3131
{
3232
key: "win_x64",
3333
label: "Windows (X64)",
34-
url: `https://alistgo.com/download/Alist/alist-desktop_x64-setup.exe`,
34+
url: `https://alistgo.com/download/Alist/desktop-v${version}/alist-desktop_${version}_x64-setup.exe`,
3535
},
3636
{
3737
key: "win_arm64",
3838
label: "Windows (ARM64)",
39-
url: `https://alistgo.com/download/Alist/alist-desktop_arm64-setup.exe`,
39+
url: `https://alistgo.com/download/Alist/desktop-v${version}/alist-desktop_${version}_arm64-setup.exe`,
4040
},
4141
{
4242
key: "linux",
4343
label: "Linux",
44-
url: `https://alistgo.com/download/Alist/alist-desktop_amd64.deb`,
44+
url: `https://alistgo.com/download/Alist/desktop-v${version}/alist-desktop_${version}_amd64.deb`,
4545
},
4646
] as const
4747
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<script setup lang="ts">
2+
import { ref, onMounted } from "vue"
3+
4+
// 全局版本状态,避免重复请求
5+
const globalVersionState = {
6+
version: ref<string>(""),
7+
loading: ref<boolean>(true),
8+
promise: null as Promise<void> | null
9+
}
10+
11+
// 如果还没有请求过,创建一个全局请求
12+
if (!globalVersionState.promise) {
13+
globalVersionState.promise = (async () => {
14+
try {
15+
const res = await fetch("https://dapi.alistgo.com/v0/version/latest")
16+
const data = await res.json()
17+
globalVersionState.version.value = data.version
18+
} catch (err) {
19+
console.error("fetch version failed", err)
20+
// 失败时设置默认版本,避免无限等待
21+
globalVersionState.version.value = "3.52.0"
22+
} finally {
23+
globalVersionState.loading.value = false
24+
}
25+
})()
26+
}
27+
28+
const version = globalVersionState.version
29+
const loading = globalVersionState.loading
30+
31+
const props = defineProps<{
32+
// 服务端下载使用:传入文件名后缀,例如 "windows-arm64.zip"
33+
filename?: string
34+
// 下载类型:server(默认) 或 desktop
35+
type?: "server" | "desktop"
36+
// 桌面版下载使用:完整文件名模板,使用 {ver} 作为版本占位
37+
// 例如:"alist-desktop_{ver}_aarch64.dmg"
38+
tpl?: string
39+
}>()
40+
41+
onMounted(async () => {
42+
// 等待全局版本加载完成
43+
await globalVersionState.promise
44+
})
45+
46+
function buildUrl() {
47+
const v = version.value
48+
const type = props.type ?? "server"
49+
50+
if (type === "desktop") {
51+
// 桌面版下载地址:
52+
// https://alistgo.com/download/Alist/desktop-v${version}/${tpl}
53+
// 例如:alist-desktop_{ver}_aarch64.dmg
54+
const filenameFromTpl = (props.tpl ?? "alist-desktop_{ver}_aarch64.dmg").replaceAll("{ver}", v)
55+
return `https://alistgo.com/download/Alist/desktop-v${v}/${filenameFromTpl}`
56+
}
57+
58+
// 服务端下载地址:
59+
// https://alistgo.com/download/Alist/v${version}/alist-${version}-${filename}
60+
const filename = props.filename ?? ""
61+
return `https://alistgo.com/download/Alist/v${v}/alist-${v}-${filename}`
62+
}
63+
64+
// i18n: 按路径判断中英文
65+
let downText = "Download"
66+
if (location.pathname.startsWith("/zh/")) {
67+
downText = "下载"
68+
}
69+
</script>
70+
71+
<template>
72+
<span v-if="loading" class="loading">{{ downText }}...</span>
73+
<a v-else :href="buildUrl()" target="_blank">{{ downText }}</a>
74+
</template>
75+
76+
<style scoped>
77+
a {
78+
color: var(--vp-c-brand);
79+
text-decoration: none;
80+
}
81+
82+
a:hover {
83+
text-decoration: underline;
84+
}
85+
86+
.loading {
87+
color: var(--vp-c-text-3);
88+
opacity: 0.7;
89+
}
90+
</style>

docs/.vuepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ export default defineUserConfig({
140140
"@Wopan/Token": path.resolve(__dirname, "./components/wopan/Token.vue"),
141141
"@Pricing": path.resolve(__dirname, "./components/Pricing.vue"),
142142
"@Desktop": path.resolve(__dirname, "./components/Desktop.vue"),
143+
"@DownloadLink": path.resolve(__dirname, "./components/DownloadLink.vue"),
143144
"@Changelog": path.resolve(__dirname, "./components/changelog/index.vue"),
144145
"@Api": path.resolve(__dirname, "./components/api/index.ts"),
145146
"@Dropbox/Request": path.resolve(
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Alist Manager Script for Windows
2+
# Version: 1.8.0 (自动编码兼容 PS5.1 + PS7+)
3+
# Author: Troray (改写 by ChatGPT)
4+
5+
# -----------------------------
6+
# 自动检测 PowerShell 版本并设置输出编码
7+
$psVersion = $PSVersionTable.PSVersion.Major
8+
9+
if ($psVersion -ge 7) {
10+
# PowerShell 7+ UTF-8
11+
chcp 65001 > $null
12+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
13+
$EncName = "UTF-8"
14+
} else {
15+
# PowerShell 5.1 / CMD GBK
16+
chcp 936 > $null
17+
[Console]::OutputEncoding = [System.Text.Encoding]::GetEncoding(936)
18+
$EncName = "GBK"
19+
}
20+
21+
# 提示用户当前编码(可选)
22+
Write-Host "当前终端编码: $EncName" -ForegroundColor Yellow
23+
# -----------------------------
24+
25+
param($Action, $InstallPath)
26+
if (-not $Action) { $Action = "menu" }
27+
if (-not $InstallPath) { $InstallPath = "C:\alist" }
28+
29+
# 颜色定义
30+
$Green = "Green"
31+
$Red = "Red"
32+
$Yellow = "Yellow"
33+
$White = "White"
34+
$ServiceName = "AlistService"
35+
36+
# -----------------------------
37+
# 输出函数
38+
function Write-Info($msg, $color="White") {
39+
$validColors = @("Black","DarkBlue","DarkGreen","DarkCyan","DarkRed",
40+
"DarkMagenta","DarkYellow","Gray","DarkGray","Blue",
41+
"Green","Cyan","Red","Magenta","Yellow","White")
42+
if ($validColors -contains $color) {
43+
[Console]::ForegroundColor = $color
44+
[Console]::WriteLine($msg)
45+
[Console]::ResetColor()
46+
} else {
47+
[Console]::WriteLine($msg)
48+
}
49+
}
50+
51+
# 下载文件
52+
function Download-File($url, $output) {
53+
Try {
54+
Invoke-WebRequest -Uri $url -OutFile $output -UseBasicParsing -TimeoutSec 30
55+
return $true
56+
} Catch {
57+
Write-Info "下载失败: $url" $Red
58+
return $false
59+
}
60+
}
61+
62+
# 获取最新版本
63+
function Get-LatestVersion {
64+
$apiUrl = "https://dapi.alistgo.com/v0/version/latest"
65+
Try {
66+
$json = Invoke-RestMethod -Uri $apiUrl -TimeoutSec 10
67+
return $json
68+
} Catch {
69+
return $null
70+
}
71+
}
72+
73+
# 安装 Alist
74+
function Install-Alist {
75+
if (-Not (Test-Path $InstallPath)) {
76+
New-Item -ItemType Directory -Path $InstallPath | Out-Null
77+
}
78+
79+
$latest = Get-LatestVersion
80+
if ($null -eq $latest) {
81+
Write-Info "获取版本信息失败,使用 GitHub 源" $Yellow
82+
$url = "https://github.com/alist-org/alist/releases/latest/download/alist-windows-amd64.zip"
83+
} else {
84+
$version = $latest.version
85+
Write-Info "最新版本: $version" $Green
86+
$url = "https://github.com/alist-org/alist/releases/download/v$version/alist-windows-amd64.zip"
87+
}
88+
89+
$tmpZip = "$env:TEMP\alist.zip"
90+
if (-Not (Download-File $url $tmpZip)) { exit 1 }
91+
92+
Expand-Archive -Path $tmpZip -DestinationPath $InstallPath -Force
93+
Remove-Item $tmpZip -Force
94+
95+
Write-Info "Alist 已安装到 $InstallPath" $Green
96+
Write-Info "运行: `"$InstallPath\alist.exe server`"" $Yellow
97+
}
98+
99+
# 更新 Alist
100+
function Update-Alist {
101+
if (-Not (Test-Path "$InstallPath\alist.exe")) {
102+
Write-Info "未检测到已安装的 Alist,请先安装" $Red
103+
exit 1
104+
}
105+
Write-Info "开始更新..." $Green
106+
Install-Alist
107+
}
108+
109+
# 卸载 Alist
110+
function Uninstall-Alist {
111+
if (Test-Path $InstallPath) {
112+
Remove-Item -Recurse -Force $InstallPath
113+
Write-Info "Alist 已卸载" $Green
114+
} else {
115+
Write-Info "未检测到安装目录 $InstallPath" $Yellow
116+
}
117+
}
118+
119+
# 注册服务
120+
function Service-Install {
121+
if (-Not (Test-Path "$InstallPath\alist.exe")) {
122+
Write-Info "请先安装 Alist 再注册服务" $Red
123+
exit 1
124+
}
125+
Write-Info "正在注册 Windows 服务 $ServiceName ..." $Green
126+
sc.exe create $ServiceName binPath= "`"$InstallPath\alist.exe`" server" start= auto DisplayName= "Alist Service" | Out-Null
127+
sc.exe description $ServiceName "Alist Web 文件管理" | Out-Null
128+
Write-Info "服务注册完成,已设置为开机自启" $Green
129+
}
130+
131+
# 删除服务
132+
function Service-Remove {
133+
Write-Info "正在删除 Windows 服务 $ServiceName ..." $Yellow
134+
sc.exe stop $ServiceName | Out-Null
135+
sc.exe delete $ServiceName | Out-Null
136+
Write-Info "服务已删除" $Green
137+
}
138+
139+
function Service-Start { sc.exe start $ServiceName }
140+
function Service-Stop { sc.exe stop $ServiceName }
141+
function Service-Restart { Service-Stop; Start-Sleep -Seconds 2; Service-Start }
142+
function Service-Status { sc.exe query $ServiceName }
143+
144+
# 菜单
145+
function Show-Menu {
146+
while ($true) {
147+
Clear-Host
148+
Write-Info "`n=== Alist Windows 管理脚本 ===`n" $Green
149+
Write-Info "1. 安装 Alist" $White
150+
Write-Info "2. 更新 Alist" $White
151+
Write-Info "3. 卸载 Alist" $White
152+
Write-Info "-------------------------" $White
153+
Write-Info "4. 注册为 Windows 服务 (开机自启)" $White
154+
Write-Info "5. 删除 Windows 服务" $White
155+
Write-Info "6. 启动服务" $White
156+
Write-Info "7. 停止服务" $White
157+
Write-Info "8. 重启服务" $White
158+
Write-Info "9. 查看服务状态" $White
159+
Write-Info "-------------------------" $White
160+
Write-Info "0. 退出" $White
161+
$choice = Read-Host "请输入选项"
162+
163+
switch ($choice) {
164+
"1" { Install-Alist; Pause }
165+
"2" { Update-Alist; Pause }
166+
"3" { Uninstall-Alist; Pause }
167+
"4" { Service-Install; Pause }
168+
"5" { Service-Remove; Pause }
169+
"6" { Service-Start; Pause }
170+
"7" { Service-Stop; Pause }
171+
"8" { Service-Restart; Pause }
172+
"9" { Service-Status; Pause }
173+
"0" { exit 0 }
174+
default { Write-Info "无效选择" $Red; Pause }
175+
}
176+
}
177+
}
178+
179+
# 主程序
180+
switch ($Action) {
181+
"install" { Install-Alist }
182+
"update" { Update-Alist }
183+
"uninstall" { Uninstall-Alist }
184+
"service-install" { Service-Install }
185+
"service-remove" { Service-Remove }
186+
"start" { Service-Start }
187+
"stop" { Service-Stop }
188+
"restart" { Service-Restart }
189+
"status" { Service-Status }
190+
"menu" { Show-Menu }
191+
default { Show-Menu }
192+
}
150 KB
Loading

0 commit comments

Comments
 (0)