Skip to content

Commit c14c8dd

Browse files
committed
update doc
1 parent c27d6f1 commit c14c8dd

11 files changed

Lines changed: 920 additions & 195 deletions

File tree

docs/.vuepress/components/DownloadLink.vue

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,16 @@
11
<script setup lang="ts">
2-
import { ref, onMounted } from "vue"
2+
import { inject } from "vue"
33
4-
// 全局版本状态,避免重复请求
5-
const globalVersionState = {
6-
version: ref<string>(""),
7-
loading: ref<boolean>(true),
8-
promise: null as Promise<void> | null
9-
}
4+
const VERSION_KEY = "alist-version"
5+
const VERSION_LOADING_KEY = "alist-version-loading"
106
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-
}
7+
// 从Provider获取全局状态
8+
const version = inject<ReturnType<typeof ref<string>>>(VERSION_KEY)
9+
const loading = inject<ReturnType<typeof ref<boolean>>>(VERSION_LOADING_KEY)
2710
28-
const version = globalVersionState.version
29-
const loading = globalVersionState.loading
11+
if (!version || !loading) {
12+
throw new Error("DownloadLink must be used within VersionProvider")
13+
}
3014
3115
const props = defineProps<{
3216
// 服务端下载使用:传入文件名后缀,例如 "windows-arm64.zip"
@@ -38,10 +22,7 @@ const props = defineProps<{
3822
tpl?: string
3923
}>()
4024
41-
onMounted(async () => {
42-
// 等待全局版本加载完成
43-
await globalVersionState.promise
44-
})
25+
// 不再需要onMounted钩子,因为我们在组件初始化时就处理了版本获取
4526
4627
function buildUrl() {
4728
const v = version.value
@@ -51,7 +32,7 @@ function buildUrl() {
5132
// 桌面版下载地址:
5233
// https://alistgo.com/download/Alist/desktop-v${version}/${tpl}
5334
// 例如:alist-desktop_{ver}_aarch64.dmg
54-
const filenameFromTpl = (props.tpl ?? "alist-desktop_{ver}_aarch64.dmg").replaceAll("{ver}", v)
35+
const filenameFromTpl = (props.tpl ?? "alist-desktop_{ver}_aarch64.dmg").replaceAll("{ver}", v || "3.52.0")
5536
return `https://alistgo.com/download/Alist/desktop-v${v}/${filenameFromTpl}`
5637
}
5738
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<script setup lang="ts">
2+
import { ref, provide } from "vue"
3+
4+
const VERSION_KEY = "alist-version"
5+
const VERSION_LOADING_KEY = "alist-version-loading"
6+
7+
// 创建全局状态
8+
const version = ref("")
9+
const loading = ref(true)
10+
11+
// 提供给子组件使用
12+
provide(VERSION_KEY, version)
13+
provide(VERSION_LOADING_KEY, loading)
14+
15+
// 只在根组件初始化时获取一次版本
16+
fetch("https://dapi.alistgo.com/v0/version/latest")
17+
.then(res => res.json())
18+
.then(data => {
19+
version.value = data.version
20+
})
21+
.catch(err => {
22+
console.error("fetch version failed", err)
23+
version.value = "3.52.0"
24+
})
25+
.finally(() => {
26+
loading.value = false
27+
})
28+
</script>
29+
30+
<template>
31+
<slot></slot>
32+
</template>

docs/.vuepress/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export default defineUserConfig({
141141
"@Pricing": path.resolve(__dirname, "./components/Pricing.vue"),
142142
"@Desktop": path.resolve(__dirname, "./components/Desktop.vue"),
143143
"@DownloadLink": path.resolve(__dirname, "./components/DownloadLink.vue"),
144+
"@VersionProvider": path.resolve(__dirname, "./components/VersionProvider.vue"),
144145
"@Changelog": path.resolve(__dirname, "./components/changelog/index.vue"),
145146
"@Api": path.resolve(__dirname, "./components/api/index.ts"),
146147
"@Dropbox/Request": path.resolve(

docs/.vuepress/public/alist-manager.ps1

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# Alist Manager Script for Windows
2-
# Version: 3.57.0(仅首次安装后随机密码)
1+
param($Action, $InstallPath)
32

43
# -----------------------------
54
# 自动检测 PowerShell 版本并设置输出编码
65
$psVersion = $PSVersionTable.PSVersion.Major
6+
7+
# UTF-8 编码对象(无 BOM)
8+
$global:Utf8NoBom = New-Object System.Text.UTF8Encoding($false)
9+
710
if ($psVersion -ge 7) {
811
chcp 65001 > $null
9-
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
12+
[Console]::OutputEncoding = $global:Utf8NoBom
1013
$EncName = "UTF-8"
1114
} else {
1215
chcp 936 > $null
@@ -16,7 +19,6 @@ if ($psVersion -ge 7) {
1619
Write-Host "当前终端编码: $EncName" -ForegroundColor Yellow
1720
# -----------------------------
1821

19-
param($Action, $InstallPath)
2022
if (-not $Action) { $Action = "menu" }
2123
if (-not $InstallPath) { $InstallPath = "C:\alist" }
2224

@@ -34,12 +36,22 @@ function Write-Info($msg, $color="White") {
3436
$validColors = @("Black","DarkBlue","DarkGreen","DarkCyan","DarkRed",
3537
"DarkMagenta","DarkYellow","Gray","DarkGray","Blue",
3638
"Green","Cyan","Red","Magenta","Yellow","White")
39+
40+
# 转码输出,避免乱码
41+
$outMsg = [System.Text.Encoding]::Default.GetString(
42+
[System.Text.Encoding]::Convert(
43+
[System.Text.Encoding]::UTF8,
44+
[Console]::OutputEncoding,
45+
[System.Text.Encoding]::UTF8.GetBytes($msg)
46+
)
47+
)
48+
3749
if ($validColors -contains $color) {
3850
[Console]::ForegroundColor = $color
39-
[Console]::WriteLine($msg)
51+
[Console]::WriteLine($outMsg)
4052
[Console]::ResetColor()
4153
} else {
42-
[Console]::WriteLine($msg)
54+
[Console]::WriteLine($outMsg)
4355
}
4456
}
4557

@@ -64,8 +76,6 @@ function Get-LatestVersion {
6476
}
6577
}
6678

67-
# -----------------------------
68-
# 获取真实物理网卡 IPv4
6979
function Get-LocalIP {
7080
$realNICs = Get-NetIPAddress -AddressFamily IPv4 | Where-Object {
7181
$_.IPAddress -ne "127.0.0.1" -and
@@ -80,7 +90,6 @@ function Get-LocalIP {
8090
return $ip
8191
}
8292

83-
# -----------------------------
8493
function Install-NSSM {
8594
if (-Not (Test-Path $nssmPath)) {
8695
$tmpZip = "$env:TEMP\nssm.zip"
@@ -123,7 +132,6 @@ function Install-Alist {
123132
$version = Get-LatestVersion
124133
Write-Info "最新版本: $version" $Green
125134

126-
# 官方镜像下载 URL(根据 CPU 架构)
127135
$filename = "alist-$version-windows-$arch.zip"
128136
$officialUrl = "https://alistgo.com/download/Alist/v$version/$filename"
129137
$tmpZip = "$env:TEMP\alist.zip"
@@ -132,7 +140,6 @@ function Install-Alist {
132140

133141
if (-not $success) {
134142
Write-Info "官方镜像下载失败!" $Yellow
135-
# 提示用户选择 GitHub 下载
136143
Write-Info "是否使用 GitHub 源下载?" $Green
137144
Write-Info "1. 使用 GitHub 默认地址" $Green
138145
Write-Info "2. 使用 GitHub 代理" $Green
@@ -157,13 +164,11 @@ function Install-Alist {
157164
}
158165
}
159166

160-
# 解压
161167
Expand-Archive -Path $tmpZip -DestinationPath $InstallPath -Force
162168
Remove-Item $tmpZip -Force
163169
Write-Info "Alist 已安装到 $InstallPath" $Green
164170
}
165171

166-
# -----------------------------
167172
function Invoke-AlistAdminRandom {
168173
if (-Not (Test-Path "$InstallPath\alist.exe")) {
169174
throw "未找到 $InstallPath\alist.exe,请先安装 Alist。"
@@ -185,7 +190,6 @@ function Invoke-AlistAdminRandom {
185190
return @{ Username = $username; Password = $password; Raw = $output }
186191
}
187192

188-
# -----------------------------
189193
function Service-InstallAndStart {
190194
if (-Not (Test-Path "$InstallPath\alist.exe")) {
191195
Write-Info "请先安装 Alist 再注册服务" $Red
@@ -232,7 +236,6 @@ function Service-Remove {
232236
}
233237
function Service-Status { Install-NSSM; & $nssmPath status $ServiceName }
234238

235-
# -----------------------------
236239
function Show-Menu {
237240
while ($true) {
238241
Clear-Host
@@ -267,7 +270,6 @@ function Show-Menu {
267270
}
268271
}
269272

270-
# -----------------------------
271273
switch ($Action) {
272274
"install" { Install-Alist }
273275
"update" { Install-Alist }
-11.9 KB
Binary file not shown.

docs/guide/install/desktop.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ MBD purchases can be viewed in a variety of different channels
4646

4747
![](/img/desktop/key_mbd.png)
4848

49-
Activation **`Not Required`** Select :black_square_button: **Lemon Squeezey**
50-
51-
![](/img/desktop/logIn_mbd.png)
52-
53-
@tab Lemon Squeezy
54-
<!-- :**https://app.lemonsqueezy.com/my-orders** -->
55-
Lemon Squeezy
56-
57-
![](/img/desktop/key_lemonsqueezy.png)
58-
59-
Activation **`required`** Select :white_check_mark: **Lemon Squeezey**
60-
61-
![](/img/desktop/login_lemonsqueezy.png)
62-
6349
:::
6450

6551
<br/>
@@ -78,11 +64,4 @@ Enter the `key` purchased on mbd to deactivate the device that is no longer in u
7864

7965
![](/img/desktop/mianbaoduo.png)
8066

81-
@tab Lemon Squeezy
82-
<!-- Log in to **https://app.lemonsqueezy.com/my-orders**
83-
log in with the email address you used when you purchased [:lemon:Lemon Squeezy](https://store.nn.ci/buy/51dca247-20df-4991-8104-54ca534bcc82) and -->
84-
follow the instructions below.
85-
86-
![](/img/desktop/lemonsqueezy.png)
87-
8867
:::

0 commit comments

Comments
 (0)