@@ -19,14 +19,36 @@ export function saveWebDAVConfig(config: WebDAVConfig): void {
1919
2020async function webdavRequest ( config : WebDAVConfig , method : string , data ?: string ) {
2121 const url = `${ config . url . replace ( / \/ $ / , '' ) } /${ WEBDAV_FILE_NAME } `
22+
23+ console . log ( `[WebDAV Client] Sending ${ method } request to ${ url } ` )
24+
2225 const res = await fetch ( '/api/webdav-proxy' , {
2326 method : 'POST' ,
2427 headers : { 'Content-Type' : 'application/json' } ,
2528 body : JSON . stringify ( { url, method, username : config . username , password : config . password , data } ) ,
29+ credentials : 'same-origin' , // Safari 兼容性
2630 } )
31+
32+ console . log ( `[WebDAV Client] Proxy response status: ${ res . status } ` )
33+
34+ if ( ! res . ok ) {
35+ const text = await res . text ( )
36+ console . error ( `[WebDAV Client] Proxy error response: ${ text } ` )
37+ throw new Error ( `代理服务器错误: ${ res . status } ` )
38+ }
39+
2740 const result = await res . json ( )
28- if ( ! result . success )
29- throw new Error ( result . error || '请求失败' )
41+ console . log ( `[WebDAV Client] Result:` , result )
42+
43+ if ( ! result . success ) {
44+ const error = result . error || '请求失败'
45+ console . error ( `[WebDAV Client] Request failed:` , error )
46+ if ( error . includes ( 'quota' ) || error . includes ( 'exceeded' ) )
47+ throw new Error ( '存储配额已满,请清理空间或升级账户' )
48+ if ( error . includes ( '509' ) )
49+ throw new Error ( '流量配额已用完,请等待下月重置或升级账户' )
50+ throw new Error ( error )
51+ }
3052 return result
3153}
3254
0 commit comments