(url, options = {})
| 274 | |
| 275 | // API调用函数 |
| 276 | async function apiCall(url, options = {}) { |
| 277 | try { |
| 278 | const response = await fetch(url, { |
| 279 | headers: { |
| 280 | 'Content-Type': 'application/json', |
| 281 | ...options.headers |
| 282 | }, |
| 283 | ...options |
| 284 | }); |
| 285 | |
| 286 | if (!response.ok) { |
| 287 | throw new Error(`HTTP error! status: ${response.status}`); |
| 288 | } |
| 289 | |
| 290 | return await response.json(); |
| 291 | } catch (error) { |
| 292 | console.error('API call failed:', error); |
| 293 | throw error; |
| 294 | } |
| 295 | } |
| 296 | |
| 297 | // 文件管理 |
| 298 | function setDefaultDirectory() { |
no outgoing calls
no test coverage detected