Files
MyGoNavi/frontend/src/utils/providerSecretDraft.ts
Syngnat fdcbadf918 🐛 fix(connection-modal): 支持编辑态回填已保存密码并保持默认遮罩
- 编辑连接前主动拉取可编辑配置,恢复主密码与 SSH 等已保存密钥
- 支持 AI 供应商编辑态回填 API Key,并保持默认遮罩展示
- 修正 AI 设置长错误提示换行展示,避免测试连接报错被裁切

Refs #489
2026-05-30 17:25:58 +08:00

30 lines
591 B
TypeScript

export type ProviderSecretDraftMode = 'replace' | 'clear';
export interface ProviderSecretDraftInput {
apiKeyInput?: string;
}
export interface ProviderSecretDraftResult {
mode: ProviderSecretDraftMode;
apiKey: string;
hasSecret: boolean;
}
export function resolveProviderSecretDraft(input: ProviderSecretDraftInput): ProviderSecretDraftResult {
const apiKey = String(input.apiKeyInput || '').trim();
if (apiKey) {
return {
mode: 'replace',
apiKey,
hasSecret: true,
};
}
return {
mode: 'clear',
apiKey: '',
hasSecret: false,
};
}