Skip to content

Commit 309eb9e

Browse files
author
You
committed
fix: build error
1 parent 25c826d commit 309eb9e

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

docs/guide/drivers/aliyundrive_open.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ import { api } from "@Api"
3232
const minutes = ref<string|number>("unknown")
3333
const max = ref<string|number>("unknown")
3434
const getLimit = async ()=>{
35-
const resp = await fetch(`${api()}/alist/ali_open/limit`)
36-
const res = await resp.json()
37-
minutes.value = res.minutes
38-
max.value = res.max
35+
try {
36+
const resp = await fetch(`${api()}/alist/ali_open/limit`)
37+
const res = await resp.json()
38+
minutes.value = res.minutes
39+
max.value = res.max
40+
} catch (error) {
41+
// Silently fail during build or when API is not available
42+
console.debug('Failed to fetch rate limit info:', error)
43+
}
44+
}
45+
// Only run in browser environment, not during SSR/build
46+
if (typeof window !== "undefined" && typeof fetch !== "undefined") {
47+
getLimit()
3948
}
40-
typeof fetch !== "undefined" && getLimit()
4149
</script>
4250
::: info Aliyundrive VIP
4351

docs/zh/guide/drivers/aliyundrive_open.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,20 @@ import { api } from "@Api"
3232
const minutes = ref<string|number>("unknown")
3333
const max = ref<string|number>("unknown")
3434
const getLimit = async ()=>{
35-
const resp = await fetch(`${api()}/alist/ali_open/limit`)
36-
const res = await resp.json()
37-
minutes.value = res.minutes
38-
max.value = res.max
35+
try {
36+
const resp = await fetch(`${api()}/alist/ali_open/limit`)
37+
const res = await resp.json()
38+
minutes.value = res.minutes
39+
max.value = res.max
40+
} catch (error) {
41+
// Silently fail during build or when API is not available
42+
console.debug('Failed to fetch rate limit info:', error)
43+
}
44+
}
45+
// Only run in browser environment, not during SSR/build
46+
if (typeof window !== "undefined" && typeof fetch !== "undefined") {
47+
getLimit()
3948
}
40-
typeof fetch !== "undefined" && getLimit()
4149
</script>
4250
::: info 阿里云盘会员
4351

0 commit comments

Comments
 (0)