(name: string)
| 174 | |
| 175 | //获取存储 |
| 176 | async function getStorageParams(name: string): Promise<ParametersType> { |
| 177 | const storage = searchStorage(name) |
| 178 | |
| 179 | switch (storage?.framework) { |
| 180 | case 'rclone': { |
| 181 | const result = await rclone_api_post('/config/get', { |
| 182 | name: storage?.name, |
| 183 | }) |
| 184 | return result || {} |
| 185 | } |
| 186 | case 'openlist': { |
| 187 | const params = ( |
| 188 | await openlist_api_get('/api/admin/storage/get', { |
| 189 | id: storage?.other?.openlist?.id, |
| 190 | }) |
| 191 | ).data |
| 192 | // 安全解析 addition 字段 |
| 193 | if (params.addition && typeof params.addition === 'string') { |
| 194 | try { |
| 195 | params.addition = JSON.parse(params.addition) |
| 196 | } catch (parseError) { |
| 197 | console.warn(`Failed to parse addition field for storage ${storage?.name}:`, parseError) |
| 198 | console.warn('Raw addition value:', params.addition) |
| 199 | // 保留原值,避免崩溃 |
| 200 | params.addition = {} |
| 201 | } |
| 202 | } else if (!params.addition) { |
| 203 | params.addition = {} |
| 204 | } |
| 205 | return params |
| 206 | } |
| 207 | } |
| 208 | return {} |
| 209 | } |
| 210 | |
| 211 | //转换存储路径 |
| 212 | const convertStoragePath = ( |
no test coverage detected