()
| 30 | * 加载 auth-profiles.json |
| 31 | */ |
| 32 | export function loadAuthProfiles(): AuthProfilesData { |
| 33 | const filePath = getAuthProfilesPath() |
| 34 | if (!fs.existsSync(filePath)) { |
| 35 | return { version: 1, profiles: {} } |
| 36 | } |
| 37 | |
| 38 | try { |
| 39 | const content = fs.readFileSync(filePath, 'utf-8') |
| 40 | const data = JSON.parse(content) as AuthProfilesData |
| 41 | if (!data.profiles || typeof data.profiles !== 'object') { |
| 42 | return { version: 1, profiles: {} } |
| 43 | } |
| 44 | return data |
| 45 | } catch { |
| 46 | return { version: 1, profiles: {} } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * 按 profile 名称获取 API Key |
no test coverage detected