()
| 377 | |
| 378 | // 初始化账户系统(首次使用时调用) |
| 379 | export function initializeAccountSystem(): { |
| 380 | storage: AccountsStorage |
| 381 | migrated: boolean |
| 382 | } { |
| 383 | let storage = getStorage() |
| 384 | let migrated = false |
| 385 | |
| 386 | // 检查是否需要迁移持仓数据 |
| 387 | const allPositions = getAllPositions() |
| 388 | const hasUnassignedPositions = allPositions.some(p => !p.accountId) |
| 389 | |
| 390 | if (hasUnassignedPositions) { |
| 391 | migrateLegacyPositions() |
| 392 | migrated = true |
| 393 | } |
| 394 | |
| 395 | return { storage, migrated } |
| 396 | } |
| 397 | |
| 398 | // ==================== 持仓管理 API ==================== |
| 399 |
no test coverage detected