File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -89,5 +89,26 @@ export async function syncFromWebDAV(): Promise<void> {
8989 throw new Error ( 'WebDAV 未配置' )
9090
9191 const result = await webdavRequest ( config , 'GET' )
92- localStorage . setItem ( 'chatStorage' , result . data || '{}' )
92+ const data = result . data || '{}'
93+
94+ console . log ( `[WebDAV] Downloaded size: ${ ( data . length / 1024 ) . toFixed ( 2 ) } KB` )
95+
96+ // 检查当前 localStorage 使用情况
97+ let currentSize = 0
98+ for ( const key in localStorage ) {
99+ if ( localStorage . hasOwnProperty ( key ) )
100+ currentSize += ( localStorage [ key ] ?. length || 0 ) + key . length
101+ }
102+ console . log ( `[WebDAV] Current localStorage: ${ ( currentSize / 1024 ) . toFixed ( 2 ) } KB` )
103+
104+ try {
105+ localStorage . setItem ( 'chatStorage' , data )
106+ console . log ( '[WebDAV] Saved successfully' )
107+ }
108+ catch ( error : any ) {
109+ console . error ( '[WebDAV] Save error:' , error )
110+ if ( error . name === 'QuotaExceededError' )
111+ throw new Error ( `Safari存储空间不足 (需要${ ( data . length / 1024 ) . toFixed ( 1 ) } KB)。请在Safari设置中清除网站数据` )
112+ throw new Error ( `保存失败: ${ error . message } ` )
113+ }
93114}
You can’t perform that action at this time.
0 commit comments