mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
fix(plugin-md-power): fix timeout when retrieving remote image size (#860)
This commit is contained in:
parent
ce32605aee
commit
09a95b7597
@ -294,7 +294,7 @@ export function resolveImagePath(app: App, src?: string | null, currentPath?: st
|
||||
* @param src - Image URL / 图片 URL
|
||||
* @returns Image size / 图片尺寸
|
||||
*/
|
||||
function fetchRemoteImageSize(src: string): Promise<ImgSize> {
|
||||
async function fetchRemoteImageSize(src: string): Promise<ImgSize> {
|
||||
const link = new URL(src)
|
||||
|
||||
const promise = new Promise<ImgSize>((resolve) => {
|
||||
@ -313,9 +313,9 @@ function fetchRemoteImageSize(src: string): Promise<ImgSize> {
|
||||
})
|
||||
|
||||
try {
|
||||
return withTimeout(() => promise, 3000)
|
||||
}
|
||||
catch {
|
||||
return Promise.resolve({ width: 0, height: 0 })
|
||||
return await withTimeout(() => promise, 3000)
|
||||
}
|
||||
catch {}
|
||||
|
||||
return { width: 0, height: 0 }
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user